A comprehensive PHP SDK for building Model Context Protocol (MCP) servers. Create production-ready MCP servers in PHP with modern architecture, extensive testing, and flexible transport options.
This SDK enables you to expose your PHP application's functionality as standardized MCP Tools, Resources, and Prompts, allowing AI assistants (like Anthropic's Claude, Cursor IDE, OpenAI's ChatGPT, etc.) to interact with your backend using the MCP standard.
- ๐๏ธ Modern Architecture: Built with PHP 8.1+ features, PSR standards, and modular design
- ๐ก Multiple Transports: Supports
stdio,http+sse, and new streamable HTTP with resumability - ๐ฏ Attribute-Based Definition: Use PHP 8 Attributes (
#[McpTool],#[McpResource], etc.) for zero-config element registration - ๐ง Flexible Handlers: Support for closures, class methods, static methods, and invokable classes
- ๐ Smart Schema Generation: Automatic JSON schema generation from method signatures with optional
#[Schema]attribute enhancements - โก Session Management: Advanced session handling with multiple storage backends
- ๐ Event-Driven: ReactPHP-based for high concurrency and non-blocking operations
- ๐ Batch Processing: Full support for JSON-RPC batch requests
- ๐พ Smart Caching: Intelligent caching of discovered elements with manual override precedence
- ๐งช Completion Providers: Built-in support for argument completion in tools and prompts
- ๐ Dependency Injection: Full PSR-11 container support with auto-wiring
- ๐ Comprehensive Testing: Extensive test suite with integration tests for all transports
This package supports the 2025-03-26 version of the Model Context Protocol with backward compatibility.
- PHP >= 8.1
- Composer
- For HTTP Transport: An event-driven PHP environment (CLI recommended)
- Extensions:
json,mbstring,pcre(typically enabled by default)