MCP SDK PHP

v1.0.0Developer Toolsstable

Model Context Protocol SDK for PHP

mcp-sdk-phpmcpai-integration
Share:
367
Stars
0
Downloads
0
Weekly
0/5

What is MCP SDK PHP?

MCP SDK PHP is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to model context protocol sdk for php

Model Context Protocol SDK for PHP

This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • Model Context Protocol SDK for PHP

Use Cases

Build MCP servers in PHP.
Integrate Model Context Protocol.
Extend PHP applications with MCP.
logiscape

Maintainer

LicenseMIT
Languagephp
Versionv1.0.0
UpdatedMay 20, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx mcp-sdk-php

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use MCP SDK PHP

The MCP SDK for PHP is a Composer package that brings full Model Context Protocol support to the PHP ecosystem, allowing developers to build both MCP servers and clients in PHP 8.1+. It provides clean abstractions for exposing tools (callable functions), resources (data objects), and prompt templates to AI assistants. PHP developers can use it to add MCP capabilities to Laravel, Symfony, or standalone PHP applications without switching languages.

Prerequisites

  • PHP 8.1 or higher with the ext-curl and ext-json extensions enabled
  • Composer package manager installed
  • Optional: ext-pcntl extension for CLI process control (recommended for server use)
  • An MCP-compatible client such as Claude Desktop to consume your PHP MCP server
1

Install the SDK via Composer

Add the logiscape/mcp-sdk-php package to your PHP project using Composer.

composer require logiscape/mcp-sdk-php
2

Create a PHP MCP server file

Create a PHP file that instantiates McpServer, registers your tools, and calls run() to start serving over stdio.

<?php
require 'vendor/autoload.php';

use Mcp\Server\McpServer;

$server = new McpServer('my-mcp-server');

$server->tool('add-numbers', 'Adds two numbers together',
    function (float $a, float $b): string {
        return 'Sum: ' . ($a + $b);
    }
);

$server->run();
3

Add resources and prompt templates (optional)

Extend your server with resources that expose data and prompt templates that AI clients can use as conversation starters.

<?php
$server->resource('config', 'application/json', function(): string {
    return json_encode(['version' => '1.0', 'environment' => 'production']);
});

$server->prompt('summarize', 'Summarize a text block', [
    ['name' => 'text', 'description' => 'Text to summarize', 'required' => true]
]);
4

Test the server using the PHP MCP client

Verify your server works by connecting to it with the SDK's built-in client and calling one of your registered tools.

<?php
require 'vendor/autoload.php';

use Mcp\Client\Client;

$client = new Client();
$session = $client->connect('php', ['server.php']);
$result = $session->callTool('add-numbers', ['a' => 5, 'b' => 25]);
echo $result->content[0]->text;
5

Configure Claude Desktop to use your PHP server

Add your PHP MCP server to the Claude Desktop configuration file, using the php binary to run your server script.

{
  "mcpServers": {
    "my-php-server": {
      "command": "php",
      "args": ["/path/to/your/server.php"]
    }
  }
}

MCP SDK PHP Examples

Client configuration

Claude Desktop configuration for a PHP MCP server running via the php CLI.

{
  "mcpServers": {
    "my-php-server": {
      "command": "php",
      "args": ["/Users/you/projects/my-mcp-server/server.php"]
    }
  }
}

Prompts to try

Example prompts to interact with a PHP-based MCP server built with the logiscape SDK.

- "Call the add-numbers tool with a=15 and b=27"
- "List all tools available on the PHP MCP server"
- "Fetch the config resource from the server"
- "Use the summarize prompt template to summarize this paragraph: [your text]"

Troubleshooting MCP SDK PHP

ext-curl or ext-json extension not found during composer install

Enable the required PHP extensions in your php.ini file by uncommenting 'extension=curl' and 'extension=json', then restart your web server or CLI. Run 'php -m | grep curl' to verify.

Server hangs or exits immediately when Claude Desktop tries to connect

Ensure your server.php calls $server->run() at the end and does not exit prematurely. For CLI use, install ext-pcntl for proper signal handling. Also verify the php binary path in your config is correct (run 'which php' to find it).

Tool parameters are not being passed correctly

PHP type declarations in your tool callback must match the types declared in the tool schema. Use float, int, string, or bool type hints consistently. JSON numeric values are decoded as floats in PHP; type-juggling may be required.

Frequently Asked Questions about MCP SDK PHP

What is MCP SDK PHP?

MCP SDK PHP is a Model Context Protocol (MCP) server that model context protocol sdk for php It connects AI assistants to external tools and data sources through a standardized interface.

How do I install MCP SDK PHP?

Follow the installation instructions on the MCP SDK PHP GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with MCP SDK PHP?

MCP SDK PHP works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is MCP SDK PHP free to use?

Yes, MCP SDK PHP is open source and available under the MIT license. You can use it freely in both personal and commercial projects.

Browse More Developer Tools MCP Servers

Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "mcp-sdk-php": { "command": "npx", "args": ["-y", "mcp-sdk-php"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use MCP SDK PHP?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides