Download the PHP package mcp/sdk without Composer
On this page you can find all versions of the php package mcp/sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package sdk
Short Description Model Context Protocol SDK for Client and Server applications in PHP
License Apache-2.0
Informations about the package sdk
MCP PHP SDK
The official PHP SDK for Model Context Protocol (MCP). It provides a framework-agnostic API for implementing MCP servers and clients in PHP.
This project represents a collaboration between the PHP Foundation and the Symfony project. It adopts development practices and standards from the Symfony project, including Coding Standards and the Backward Compatibility Promise.
Until the first major release, this SDK is considered experimental, please see the roadmap for planned next steps and features.
Table of Contents
- Installation
- Overview
- Server SDK
- Client SDK
- Documentation
- External Resources
- PHP Libraries Using the MCP SDK
- Contributing
- Credits
- License
Installation
Overview
The MCP PHP SDK provides both server and client implementations for the Model Context Protocol, enabling you to:
- Build MCP Servers: Expose your PHP application's functionality (tools, resources, prompts) to AI agents
- Build MCP Clients: Connect to and interact with MCP servers from your PHP applications
Server SDK
Build MCP servers to expose your PHP application's capabilities to AI agents like Claude, Codex, and others.
Quick Start
Server Capabilities
- Tools: Executable functions that AI agents can call
- Resources: Data sources that can be read (files, configs, databases)
- Resource Templates: Dynamic resources with URI parameters
- Prompts: Pre-defined templates for AI interactions
- Server-Initiated Communication: Elicitations, sampling, logging, progress notifications
Registration Methods
There are multiple ways to register your MCP capabilities—choose the approach that best fits your application's architecture:
1. Attribute-Based Discovery — Define capabilities using PHP attributes for automatic discovery:
2. Manual Registration — Register capabilities programmatically without attributes:
3. Hybrid Approach — Combine both methods for maximum flexibility:
Transports
Choose the transport that matches your deployment environment:
1. STDIO Transport — For command-line integration and local processes:
2. HTTP Transport — For web-based servers and distributed systems:
Session Management
Configure session storage to maintain state between requests. Choose the backend that fits your infrastructure:
In-Memory (default, suitable for STDIO):
File-Based (suitable for single-server HTTP deployments):
PSR-16 Cache (for example with Redis for scaled deployments):
→ Server Documentation
Client SDK
Connect to MCP servers from your PHP applications to access their tools, resources, and prompts.
Quick Start
Client Capabilities
- Tool Calling: List and execute tools from any MCP server
- Resource Access: Read static and dynamic resources
- Prompt Management: List and retrieve prompt templates
- Completion Support: Request argument completion suggestions
Advanced Features
-
Progress Tracking: Real-time progress during long operations
-
Sampling Support: Handle server LLM sampling requests
- Logging Notifications: Receive server log messages
Transports
Connect to MCP servers using the transport that matches your setup:
1. STDIO Transport — Connect to local server processes:
2. HTTP Transport — Connect to remote or web-based servers:
→ Client Documentation
Documentation
Core Concepts
- Server Builder — Complete ServerBuilder reference and configuration
- Client — Client SDK for connecting to and communicating with MCP servers
- Transports — STDIO and HTTP transport setup and usage
- MCP Elements — Creating tools, resources, prompts, and templates
- Server-Client Communication — Sampling, logging, progress, and notifications
- Protocol Extensions — Opt-in protocol extensions announced during capability negotiation, including MCP Apps (HTML UI resources)
- Authorization — OAuth and authorization setup for HTTP transport
- Events — Hooking into server lifecycle with events
Learning & Examples
- Examples — Comprehensive example walkthroughs for servers and clients
- ROADMAP.md — Planned features and development roadmap
External Resources
- Model Context Protocol Documentation — Official MCP documentation
- Model Context Protocol Specification — Protocol specification
- Officially Supported Servers — Reference server implementations
PHP Libraries Using the MCP SDK
- api-platform/mcp — MCP integration for API Platform
- bnomei/kirby-mcp — MCP server for the Kirby CMS
- drupal/mcp_server — MCP server for Drupal exposing configuration and entities as MCP elements
- josbeir/cakephp-synapse — CakePHP plugin exposing application functionality over MCP
- nette/mcp-inspector — MCP server for introspecting Nette applications
- symfony/ai-mate — AI development assistant MCP server for Symfony projects
- symfony/mcp-bundle — Symfony integration bundle
Building something on top of the SDK? Open a pull request to add it to this list.
Contributing
We are passionate about supporting contributors of all levels of experience and would love to see you get involved in the project.
See the send pull requests.
Credits
The starting point for this SDK was the PHP-MCP project, initiated by Kyrian Obikwelu, and the Symfony AI initiative. We are grateful for the work done by both projects and their contributors, which created a solid foundation for this SDK.
License
This project is licensed under the Apache License, Version 2.0 for new contributions, with existing code under the MIT License — see the LICENSE file for details.
All versions of sdk with dependencies
ext-fileinfo Version *
opis/json-schema Version ^2.4
php-http/discovery Version ^1.20
phpdocumentor/reflection-docblock Version ^5.6 || ^6.0
psr/clock Version ^1.0
psr/container Version ^1.0 || ^2.0
psr/event-dispatcher Version ^1.0
psr/http-client Version ^1.0
psr/http-factory Version ^1.1
psr/http-message Version ^1.1 || ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
psr/log Version ^1.0 || ^2.0 || ^3.0
symfony/uid Version ^5.4 || ^6.4 || ^7.3 || ^8.0