PHP SDK

v1.0.0Developer Toolsstable

The official PHP SDK for Model Context Protocol servers and clients. Maintained in collaboration with The PHP Foundation.

php-sdkmcpai-integration
Share:
1,505
Stars
0
Downloads
0
Weekly
0/5

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

Build MCP servers and clients using the official PHP SDK.
Leverage The PHP Foundation's maintained SDK.
LicenseNOASSERTION
Languagephp
Versionv1.0.0
UpdatedMay 21, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx php-sdk

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 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
1

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/sdk
2

Create 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);
3

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"]
    }
  }
}
4

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.

5

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; // 8

PHP 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.

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": { "php-sdk": { "command": "npx", "args": ["-y", "php-sdk"] } } }

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

Read the full setup guide →

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.

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