php-sdk
The official PHP SDK for Model Context Protocol servers and clients. Maintained in collaboration with The PHP Foundation.
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Check it deeper on your machine
It has changed since its scan on 11 Nov 2026.
As a Claude Code plugin, install it and then ask Claude Code:
/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/modelcontextprotocol/php-sdk with scanskillsafety
Or from a terminal, clone it and run it:
git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/modelcontextprotocol/php-sdk'
It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.
Badge for your README
Markdown
[](/listings/modelcontextprotocol--php-sdk)HTML
<a href="/listings/modelcontextprotocol--php-sdk"><img src="/api/listings/modelcontextprotocol--php-sdk/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
composer require mcp/sdk
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
README.md · README · 153 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.
- # MCP PHP SDK
- [](https://packagist.org/packages/mcp/sdk)
- [](https://github.com/modelcontextprotocol/php-sdk/actions/workflows/pipeline.yaml)
- [](https://packagist.org/packages/mcp/sdk)
- [](LICENSE)
- The official PHP SDK for the Model Context Protocol (MCP). It provides a framework-agnostic API for implementing MCP
- servers and clients in PHP — tools, resources, prompts, STDIO and HTTP transports, sessions, authorization, and both
- protocol eras (the `initialize` handshake and the stateless `2026-07-28` revision).
- This project represents a collaboration between [the PHP Foundation](https://thephp.foundation/) and the [Symfony project](https://symfony.com/). It adopts
- development practices and standards from the Symfony project, including [Coding Standards](https://symfony.com/doc/current/contributing/code/standards.html) and the
- [Backward Compatibility Promise](https://symfony.com/doc/current/contributing/code/bc.html).
- Until the first major release, this SDK is considered [experimental](https://symfony.com/doc/current/contributing/code/experimental.html), please see the [roadmap](./ROADMAP.md) for
- planned next steps and features.
- ## Protocol Conformance
- Measured weekly against the [MCP Conformance Test Framework](https://github.com/modelcontextprotocol/conformance),
- as passing checks out of total. The `2026-07-28` scores run against the framework's `alpha` releases, so they move as
- upstream publishes new scenarios.
- | Revision | Server | Client |
- |:--------:|:------:|:------:|
- | `2026-07-28` | [](https://github.com/modelcontextprotocol/php-sdk/actions/workflows/conformance-weekly.yaml) | [](https://github.com/modelcontextprotocol/php-sdk/actions/workflows/conformance-weekly.yaml) |
- | `2025-11-25` | [](https://github.com/modelcontextprotocol/php-sdk/actions/workflows/conformance-weekly.yaml) | [](https://github.com/modelcontextprotocol/php-sdk/actions/workflows/conformance-weekly.yaml) |
- ## Installation
- ```bash
- composer require mcp/sdk
- ```
- ## Build a server
- A server is a plain PHP class plus a few lines of wiring:
- ```php
- <?php
- require __DIR__.'/vendor/autoload.php';
- use Mcp\Server\Capability\Attribute\McpResource;
- use Mcp\Server\Capability\Attribute\McpTool;
- use Mcp\Server\Server;
- use Mcp\Server\Transport\StdioTransport;
- class Calculator
- {
- /**
- * Adds two numbers.
- */
- #[McpTool]
- public function add(int $a, int $b): int
- {
- return $a + $b;
- }
- #[McpResource(uri: 'config://calculator/settings')]
- public function settings(): array
- {
- return ['precision' => 2];
- }
- }
- exit(Server::builder()
- ->setServerInfo('Calculator', '1.0.0')
- ->setDiscovery(__DIR__, ['.'], excludeDirs: ['vendor'])
- ->build()
- ->run(new StdioTransport()));
- ```
- The `setDiscovery()` call needs `symfony/finder`:
- ```bash
- composer require symfony/finder
- ```
- The walkthrough in [First server](docs/get-started/first-server.md) explains each piece, and
- [Try it with the Inspector](docs/get-started/inspector.md) shows it running.
- ## Build a client
- ```php
- use Mcp\Client\Client;
- use Mcp\Client\Transport\StdioTransport;
- $client = Client::builder()
- ->setClientInfo('My Application', '1.0.0')
- ->build();
- $client->connect(new StdioTransport(command: 'php', args: ['/path/to/server.php']));
- $tools = $client->listTools();
- $result = $client->callTool('add', ['a' => 5, 'b' => 3]);
- $client->disconnect();
- ```
- See [Transports](docs/client/transports.md) for STDIO and HTTP, [Connecting to a server](docs/client/connecting.md)
- for timeouts, and [Server-initiated requests](docs/client/server-requests.md) for the handlers that
- answer requests from the server.
- ## Documentation
- The full documentation is published at **[php.sdk.modelcontextprotocol.io](https://php.sdk.modelcontextprotocol.io/)**.
- - **[Get started](docs/get-started/index.md)** — Install the SDK and build your first server
- - **[Servers](docs/servers/index.md)** — Tools, resources, resource templates, prompts, and how to register them
- - **[Inside your handler](docs/handlers/index.md)** — Talking back to the client, logging, and asking for input
- - **[Running your server](docs/run/index.md)** — Server builder, STDIO and HTTP transports, framework integration, sessions, authorization
- - **[Clients](docs/client/index.md)** — Client SDK for connecting to and communicating with MCP servers
- - **[Protocol versions](docs/protocol-versions.md)** — The two protocol eras, and what revision `2026-07-28` changed
- - **[Advanced](docs/advanced/index.md)** — Events, protocol extensions (including MCP Apps), and custom message handlers
- - **[Deprecation policy](docs/deprecation-policy.md)** — How deprecated features are handled
- - **[SDK tier target](docs/sdk-tier.md)** — Where the SDK stands on the MCP SDK tiers
- - **[Examples](docs/examples.md)** — Runnable server and client examples
- - **[API Reference](https://php.sdk.modelcontextprotocol.io/api/)** — Generated class reference
- ## External Resources
- - **[Model Context Protocol Documentation](https://modelcontextprotocol.io)** — Official MCP documentation
- - **[Model Context Protocol Specification](https://modelcontextprotocol.io/specification)** — Protocol specification
- - **[Officially Supported Servers](https://github.com/modelcontextprotocol/servers)** — Reference server implementations
- ## PHP Libraries Using the MCP SDK
- - [api-platform/mcp](https://github.com/api-platform/mcp) — MCP integration for API Platform
- - [bnomei/kirby-mcp](https://github.com/bnomei/kirby-mcp) — MCP server for the Kirby CMS
- - [drupal/mcp_server](https://www.drupal.org/project/mcp_server) — MCP server for Drupal exposing configuration and entities as MCP elements
- - [josbeir/cakephp-synapse](https://github.com/josbeir/cakephp-synapse) — CakePHP plugin exposing application functionality over MCP
- - [nette/mcp-inspector](https://github.com/nette/mcp-inspector) — MCP server for introspecting Nette applications
- - [symfony/mcp-bundle](https://github.com/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. Start by [reporting issues](https://github.com/modelcontextprotocol/php-sdk/issues) or
- [sending pull requests](https://github.com/modelcontextprotocol/php-sdk/pulls). See
- [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, coding standards, and what to run before
- opening a PR.
- ## Credits
- The starting point for this SDK was the [PHP-MCP](https://github.com/php-mcp/server) project, initiated by [Kyrian Obikwelu](https://github.com/CodeWithKyrian), and the [Symfony AI initiative](https://github.com/symfony/ai). 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](LICENSE) file for details.
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.