PHP MCP SDK

v1.0.0โ€ขDeveloper Toolsโ€ขstable

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

mcpmcp-clientmcp-servermcp-serversmcp-tools
Share:
25
Stars
0
Downloads
0
Weekly
0/5

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

Implement complete MCP protocol in PHP applications.
Build type-safe MCP servers and clients with PHP.
Support STDIO and HTTP transports for MCP integration.
dalehurley

Maintainer

LicenseMIT
Languagephp
Versionv1.0.0
UpdatedMar 30, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx php-mcp-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 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
1

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-main
2

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

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

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']);
5

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 check

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

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

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

Read the full setup guide โ†’

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.

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