PHP MCP
A complete PHP implementation of the Model Context Protocol (MCP) with server and client support, STDIO and HTTP transports, and framework integration
What is PHP MCP?
PHP MCP is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to complete php implementation of the model context protocol (mcp) with server and client support, stdio and http transports, and framework integration
A complete PHP implementation of the Model Context Protocol (MCP) with server and client support, STDIO and HTTP transports, and framework integration
This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- A complete PHP implementation of the Model Context Protocol
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx phpConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use PHP MCP
php-mcp is a complete PHP implementation of the Model Context Protocol that lets you build both MCP servers and MCP clients entirely in PHP, without a Node.js or Python runtime. It supports STDIO and HTTP (JSON-RPC) transports, provides annotation-based tool/resource/prompt registration via PHP attributes, and integrates with PHP dependency injection containers. PHP developers can use it to add MCP-compatible AI tool interfaces to existing Laravel, Symfony, or plain PHP applications without leaving the PHP ecosystem.
Prerequisites
- PHP 7.4 or later (PHP 8.0+ recommended)
- Composer for dependency management
- Required PHP extensions: json, mbstring, openssl, pcntl, curl
- An MCP client such as Claude Desktop or Cursor to connect to your server
Install the package via Composer
Add php-mcp to your PHP project using Composer. The package is published on Packagist under the name dtyq/php-mcp.
composer require dtyq/php-mcpVerify required PHP extensions
Check that all required extensions are enabled in your php.ini. The pcntl extension is required for STDIO transport and is usually available on Linux/macOS but disabled on Windows.
php -m | grep -E 'json|mbstring|openssl|pcntl|curl'Define a tool using the McpTool attribute
Annotate a PHP method with #[McpTool] to register it as a callable MCP tool. Parameters are validated against a JSON Schema derived from PHP type hints.
<?php
use Dtyq\PhpMcp\Attribute\McpTool;
class MyTools
{
#[McpTool(description: 'Add two numbers together')]
public function add(int $a, int $b): array
{
return ['result' => $a + $b];
}
}Bootstrap the MCP server
Create an Application instance, register your tool classes, and start the server in STDIO mode. The server will listen on stdin/stdout for MCP protocol messages.
<?php
use Dtyq\PhpMcp\Application;
$app = new Application($container, ['sdk_name' => 'my-php-mcp-server']);
$app->registerTool(new MyTools());
$app->runStdio();Configure your MCP client to use the PHP server
Add a configuration entry for your PHP MCP server in your MCP client's config file, pointing to your PHP script with the php binary.
Test the connection
Restart your MCP client and ask the AI to list available tools. Your PHP-defined tools should appear by name with their descriptions.
PHP MCP Examples
Client configuration
Claude Desktop config to run a PHP MCP server script via the system PHP binary.
{
"mcpServers": {
"php-mcp": {
"command": "php",
"args": ["/absolute/path/to/your/server.php"]
}
}
}Prompts to try
Example prompts once your PHP MCP server is running and connected.
- "What tools does the PHP server expose?"
- "Call the add tool with a=5 and b=7"
- "Use the PHP server to validate this JSON schema"
- "Fetch the list of resources available from the PHP MCP server"
- "Call the greet tool with name='World'"Troubleshooting PHP MCP
pcntl extension not found on Windows
The pcntl extension is not available on Windows. Use HTTP transport mode instead of STDIO, or run the server inside WSL2 (Windows Subsystem for Linux) where pcntl is available.
composer require fails with version conflicts
Ensure your PHP version is 7.4 or later and that the platform constraint in composer.json matches your environment. Run composer diagnose to identify extension or version mismatches.
MCP client cannot communicate with the PHP server
Verify the absolute path to your server.php script is correct in the MCP config. Run php /absolute/path/to/server.php manually in a terminal to check for PHP parse errors before connecting an MCP client.
Frequently Asked Questions about PHP MCP
What is PHP MCP?
PHP MCP is a Model Context Protocol (MCP) server that complete php implementation of the model context protocol (mcp) with server and client support, stdio and http transports, and framework integration It connects AI assistants to external tools and data sources through a standardized interface.
How do I install PHP MCP?
Follow the installation instructions on the PHP MCP GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with PHP MCP?
PHP MCP works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is PHP MCP free to use?
Yes, PHP MCP is open source and available under the MIT license. You can use it freely in both personal and commercial projects.
PHP MCP Alternatives — Similar Developer Tools Servers
Looking for alternatives to PHP MCP? 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 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?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.