PHP SDK
The official PHP SDK for Model Context Protocol servers and clients. Maintained in collaboration with The PHP Foundation.
What is PHP SDK?
PHP SDK is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to official php sdk for model context protocol servers and clients. maintained in collaboration with the php foundation.
The official PHP SDK for Model Context Protocol servers and clients. Maintained in collaboration with The PHP Foundation.
This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- The official PHP SDK for Model Context Protocol servers and
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx php-sdkConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use PHP SDK
The official PHP SDK for the Model Context Protocol, maintained in collaboration with The PHP Foundation, lets PHP developers build both MCP servers and clients using idiomatic PHP. It supports tools, resources, resource templates, and prompts as first-class capabilities, plus server-initiated features like elicitations, sampling, logging, and progress notifications. Developers use it to expose PHP application logic—database queries, business logic, APIs—as callable MCP tools that AI assistants can invoke directly.
Prerequisites
- PHP 8.1 or later installed
- Composer package manager installed
- An MCP-compatible client such as Claude Desktop or Claude Code
- Basic familiarity with PHP namespaces and attributes
Install the SDK via Composer
Add the official MCP PHP SDK to your project using Composer. This pulls in all required dependencies and makes the MCP namespace available.
composer require mcp/sdkCreate a server entry point
Create a PHP file that defines your server capabilities using the ServerBuilder API and the #[McpTool] attribute on public methods. The discovery mechanism auto-registers annotated classes.
<?php
use Mcp\Server;
use Mcp\Server\Transport\StdioTransport;
use Mcp\Capability\Attribute\McpTool;
class MyCapabilities {
#[McpTool]
public function add(int $a, int $b): int { return $a + $b; }
#[McpTool]
public function greet(string $name): string { return "Hello, $name!"; }
}
$server = Server::builder()
->setServerInfo('My PHP Server', '1.0.0')
->setDiscovery(__DIR__, ['.'])
->build();
$transport = new StdioTransport();
$server->run($transport);Configure Claude Desktop to use the server
Add the PHP server to your claude_desktop_config.json so Claude Desktop launches it as a subprocess via stdio transport.
{
"mcpServers": {
"my-php-server": {
"command": "php",
"args": ["/absolute/path/to/your/server.php"]
}
}
}Add resource and prompt capabilities
Beyond tools, the SDK supports Resources (data sources like files or database rows) and Prompts (pre-defined conversation templates). Add these by implementing the corresponding capability interfaces or using additional attributes in your capability class.
Build a PHP MCP client (optional)
Use the ClientBuilder to connect to any MCP server from PHP code, useful for testing your server or orchestrating multi-server workflows.
<?php
use Mcp\Client;
use Mcp\Client\Transport\StdioTransport;
$client = Client::builder()
->setClientInfo('My App', '1.0.0')
->build();
$transport = new StdioTransport(command: 'php', args: ['/path/to/server.php']);
$client->connect($transport);
$result = $client->callTool('add', ['a' => 5, 'b' => 3]);
echo $result; // 8PHP SDK Examples
Client configuration
Claude Desktop configuration to run your PHP MCP server as a local subprocess.
{
"mcpServers": {
"php-mcp-server": {
"command": "php",
"args": ["/path/to/server.php"]
}
}
}Prompts to try
After connecting Claude Desktop to your PHP MCP server, try these prompts to exercise your tools.
- "Add 42 and 58 using the calculator tool"
- "List all available tools on the PHP server"
- "Read the configuration resource from my PHP server"
- "Call the greet tool with my name"Troubleshooting PHP SDK
Claude Desktop shows the server as disconnected or fails to start it
Verify the absolute path to server.php is correct and that the `php` binary is in your system PATH. Test by running `php /path/to/server.php` directly in a terminal.
Tools are not discovered or do not appear in Claude
Ensure the class containing #[McpTool] methods is in a file inside the directory passed to setDiscovery(), and that the class is autoloadable via Composer. Run `composer dump-autoload` after adding new classes.
Composer install fails with version conflicts
The SDK requires PHP 8.1+. Check your PHP version with `php --version`. If using an older version, upgrade PHP or use a Docker container with php:8.1-cli.
Frequently Asked Questions about PHP SDK
What is PHP SDK?
PHP SDK is a Model Context Protocol (MCP) server that official php sdk for model context protocol servers and clients. maintained in collaboration with the php foundation. It connects AI assistants to external tools and data sources through a standardized interface.
How do I install PHP SDK?
Follow the installation instructions on the PHP SDK GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with PHP SDK?
PHP SDK works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is PHP SDK free to use?
Yes, PHP SDK is open source and available under the NOASSERTION license. You can use it freely in both personal and commercial projects.
PHP SDK Alternatives — Similar Developer Tools Servers
Looking for alternatives to PHP 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 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 SDK?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.