PHP MCP SDK
PHP implementation of the Model Context Protocol (MCP), enabling seamless integration between LLM applications and external data sources and tools. โจ Features ๐ Complete MCP Protocol Support - Full implementation of the MCP specification ๐ง Type-Safe
What is PHP MCP SDK?
PHP MCP SDK is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to php implementation of the model context protocol (mcp), enabling seamless integration between llm applications and external data sources and tools. โจ features ๐ complete mcp protocol support - full i...
PHP implementation of the Model Context Protocol (MCP), enabling seamless integration between LLM applications and external data sources and tools. โจ Features ๐ Complete MCP Protocol Support - Full implementation of the MCP specification ๐ง Type-Safe
This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- PHP implementation of the Model Context Protocol (MCP), enab
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx php-mcp-sdkConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use PHP MCP SDK
The PHP MCP SDK is a complete PHP 8.1+ implementation of the Model Context Protocol specification, enabling developers to build both MCP servers and clients entirely in PHP. It provides a type-safe, async-first architecture built on Amphp for non-blocking I/O, supports STDIO, HTTP Streaming, and WebSocket transports, and includes OAuth 2.0 with PKCE for authentication. PHP developers use it to integrate Laravel and Symfony applications with LLMs, expose existing PHP APIs as MCP tools, or build PHP-native MCP clients that connect to any MCP server.
Prerequisites
- PHP 8.1 or higher with ext-json and ext-mbstring extensions enabled
- Composer (PHP package manager) installed
- Familiarity with PHP async programming (Amphp/Revolt) is helpful but not required for basic servers
- An MCP-compatible LLM client (Claude Desktop, Claude Code, etc.) for testing your server
Install the SDK via Composer
Add the PHP MCP SDK to your project using Composer. Use the stable release for production or dev-main to track the latest changes.
# Stable release
composer require dalehurley/php-mcp-sdk
# Latest development version
composer require dalehurley/php-mcp-sdk:dev-mainCreate a basic MCP server
Instantiate McpServer with an Implementation descriptor, register tools using the tool() method with a JSON Schema parameter definition, then connect via StdioServerTransport for local MCP communication.
<?php
require 'vendor/autoload.php';
use DaleHurley\PhpMcpSdk\McpServer;
use DaleHurley\PhpMcpSdk\Implementation;
use DaleHurley\PhpMcpSdk\Transport\StdioServerTransport;
$server = new McpServer(new Implementation('my-server', '1.0.0'));
$server->tool(
'greet',
'Returns a greeting for the given name',
[
'type' => 'object',
'properties' => [
'name' => ['type' => 'string', 'description' => 'Name to greet']
],
'required' => ['name']
],
function(array $args): array {
return ['content' => [['type' => 'text', 'text' => 'Hello, ' . $args['name'] . '!']]];
}
);
$transport = new StdioServerTransport();
$server->connect($transport);
$server->run();Register your PHP server in an MCP client
Add the PHP server to your claude_desktop_config.json so Claude Desktop can launch it. The command should invoke PHP with the path to your server script.
{
"mcpServers": {
"my-php-server": {
"command": "php",
"args": ["/absolute/path/to/your/server.php"]
}
}
}Build an MCP client (optional)
Use the Client class to connect to any MCP server from PHP code. This is useful for PHP applications that need to call MCP-exposed tools programmatically.
<?php
use DaleHurley\PhpMcpSdk\Client;
use DaleHurley\PhpMcpSdk\Implementation;
use DaleHurley\PhpMcpSdk\Transport\StdioClientTransport;
$client = new Client(new Implementation('my-client', '1.0.0'));
$transport = new StdioClientTransport(['command' => 'php', 'args' => ['server.php']]);
yield $client->connect($transport);
$tools = yield $client->listTools();
$result = yield $client->callTool('greet', ['name' => 'World']);Run tests and static analysis
Use the bundled Composer scripts to run the test suite and PHPStan static analysis to verify your server implementation is correct.
composer test
composer phpstan
# Run all checks at once
composer checkPHP MCP SDK Examples
Client configuration for a PHP MCP server
claude_desktop_config.json entry for a PHP-based MCP server. PHP must be available on PATH. Adjust the path to your server script.
{
"mcpServers": {
"my-php-server": {
"command": "php",
"args": ["/Users/yourname/projects/my-mcp-server/server.php"]
}
}
}Prompts to try after building your PHP server
Once you have registered tools in your PHP MCP server, test them with prompts like these.
- "Use the greet tool to say hello to Alice"
- "Call the get_user tool with ID 42 and summarize the result"
- "List all available tools on the PHP MCP server"
- "Use the database_query tool to fetch all active products"
- "Invoke the send_email tool to send a welcome message to [email protected]"Troubleshooting PHP MCP SDK
Composer install fails with extension errors (ext-json, ext-mbstring)
Enable the required PHP extensions. On Ubuntu/Debian: `sudo apt install php8.1-json php8.1-mbstring`. On macOS with Homebrew PHP: extensions are usually included. Check with `php -m | grep -E 'json|mbstring'`.
Server does not respond or MCP client shows connection errors
Test the server script directly in a terminal with `php server.php` and check for PHP errors. Ensure the script exits correctly on EOF and does not output anything before the MCP handshake (e.g., no var_dump or echo statements outside tool handlers).
Async/yield syntax causes errors in the client
The client API uses Amphp coroutines (yield-based). Wrap client code in an Amp\async() call or an Amp\Loop::run() block. Install the required Amphp packages via Composer if they are not pulled in automatically as dependencies.
Frequently Asked Questions about PHP MCP SDK
What is PHP MCP SDK?
PHP MCP SDK is a Model Context Protocol (MCP) server that php implementation of the model context protocol (mcp), enabling seamless integration between llm applications and external data sources and tools. โจ features ๐ complete mcp protocol support - full implementation of the mcp specification ๐ง type-safe It connects AI assistants to external tools and data sources through a standardized interface.
How do I install PHP MCP SDK?
Follow the installation instructions on the PHP MCP SDK GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with PHP MCP SDK?
PHP MCP SDK works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is PHP MCP SDK free to use?
Yes, PHP MCP SDK is open source and available under the MIT license. You can use it freely in both personal and commercial projects.
PHP MCP SDK Alternatives โ Similar Developer Tools Servers
Looking for alternatives to PHP MCP SDK? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
โ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
โ 155.8kJava ้ข่ฏ & ๅ็ซฏ้็จ้ข่ฏๆๅ๏ผ่ฆ็่ฎก็ฎๆบๅบ็กใๆฐๆฎๅบใๅๅธๅผใ้ซๅนถๅใ็ณป็ป่ฎพ่ฎกไธ AI ๅบ็จๅผๅ
Gemini CLI
โ 104.5kA secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
Awesome MCP Servers
โ 87.3kโญ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
โ 86.0kModel Context Protocol Servers
CC Switch
โ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
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.
Set Up PHP MCP SDK in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use PHP MCP SDK?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.