MCP SDK PHP
Model Context Protocol SDK for PHP
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
Maintainer
Works with
Installation
Manual Installation
npx mcp-sdk-phpConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
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
Install the SDK via Composer
Add the logiscape/mcp-sdk-php package to your PHP project using Composer.
composer require logiscape/mcp-sdk-phpCreate 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();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]
]);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;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.
MCP SDK PHP Alternatives — Similar Developer Tools Servers
Looking for alternatives to MCP SDK PHP? 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 MCP SDK PHP 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 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.