mcp
Create production-ready MCP servers in PHP with modern architecture, and flexible transport options.
claude mcp add --transport stdio llm-agents-php-mcp-server node path/to/server.php \ --env PHP_VERSION="8.3+" \ --env COMPOSER_HOME="path/to/composer/cache (optional)"
How to use
This PHP MCP Server SDK provides the core components to build an MCP 2025 compliant server using PHP 8.3+. It includes support for multiple transports (STDIO, HTTP with SSE, and streamable HTTP), a robust registry for tools and resources, a protocol handler, and middleware support. With this SDK you can register custom tools and content handlers, define sessions and dispatch routes, and plug in middleware such as CORS or authentication. The Quick Start example demonstrates wiring the server together with a simple tool and running it over STDIO. You can adapt the same architecture to build a full MCP server that communicates over HTTP or a streamable transport by swapping the transport layer while reusing the protocol, registry, and dispatcher components.
How to install
Prerequisites:
- PHP >= 8.3
- Composer
Installation steps:
- Install PHP MCP Server package:
composer require llm/mcp-server
- If you plan to integrate with a framework, install the corresponding bridge (examples include Spiral Framework bridge):
composer require spiral/mcp-server
- (Optional) Install development tooling and autoloading if you want to run examples directly:
composer dump-autoload
- Create your server script (for STDIO) or configure your chosen transport, then start the server via PHP:
php path/to/your/server.php
- Verify the MCP protocol communication by sending MCP messages through STDIN/STDOUT or through your HTTP transport as configured.
Additional notes
Tips and notes:
- Ensure PHP 8.3+ is used for full type safety features.
- Enable required PHP extensions: json, mbstring, and pcre.
- The SDK is designed to be transport-agnostic; you can swap STDIO for HTTP or Streamable HTTP by implementing or using the provided transport adapters.
- When testing, you can start with a minimal tool registry and a simple tool to confirm the MCP flow (tool registration, dispatch, and response).
- If using frameworks, prefer the dedicated bridge packages to leverage automatic discovery and validation.
- For production, consider configuring a persistent session store and a resilient event loop integration (ReactPHP-based).
Related MCP Servers
drift
Codebase intelligence for AI. Detects patterns & conventions + remembers decisions across sessions. MCP server for any IDE. Offline CLI.
laravel
A Laravel package for implementing secure Model Context Protocol servers using Streamable HTTP and SSE transport, providing real-time communication and a scalable tool system for enterprise environments.
php
基于 PHP 实现的 MCP (Model Control Protocol) 服务器框架,通过注解优雅地定义 MCP 服务,支持 Tool、Prompt、Resource 三种处理器,支持Stdio、Sse 两种 transport。
mcp-profiler-bundle
The Symfony MCP Profiler Bundle mimics the WebProfiler Bundle. It bridges the gap between Profiler data and your favorite MCP-enabled AI-powered IDE.
elementor
Comprehensive Elementor MCP Server plugin.
mcp
Model Context Protocol for Hyperf