Skip to content
Back to search

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.

Checked today

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
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/modelcontextprotocol--php-sdk/badge.svg)](/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

i

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.

  1. # MCP PHP SDK
  2. [![Latest Version](https://img.shields.io/packagist/v/mcp/sdk.svg)](https://packagist.org/packages/mcp/sdk)
  3. [![CI](https://github.com/modelcontextprotocol/php-sdk/actions/workflows/pipeline.yaml/badge.svg)](https://github.com/modelcontextprotocol/php-sdk/actions/workflows/pipeline.yaml)
  4. [![PHP Version](https://img.shields.io/packagist/php-v/mcp/sdk.svg)](https://packagist.org/packages/mcp/sdk)
  5. [![License](https://img.shields.io/packagist/l/mcp/sdk.svg)](LICENSE)
  6. The official PHP SDK for the Model Context Protocol (MCP). It provides a framework-agnostic API for implementing MCP
  7. servers and clients in PHP — tools, resources, prompts, STDIO and HTTP transports, sessions, authorization, and both
  8. protocol eras (the `initialize` handshake and the stateless `2026-07-28` revision).
  9. This project represents a collaboration between [the PHP Foundation](https://thephp.foundation/) and the [Symfony project](https://symfony.com/). It adopts
  10. development practices and standards from the Symfony project, including [Coding Standards](https://symfony.com/doc/current/contributing/code/standards.html) and the
  11. [Backward Compatibility Promise](https://symfony.com/doc/current/contributing/code/bc.html).
  12. 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
  13. planned next steps and features.
  14. ## Protocol Conformance
  15. Measured weekly against the [MCP Conformance Test Framework](https://github.com/modelcontextprotocol/conformance),
  16. as passing checks out of total. The `2026-07-28` scores run against the framework's `alpha` releases, so they move as
  17. upstream publishes new scenarios.
  18. | Revision | Server | Client |
  19. |:--------:|:------:|:------:|
  20. | `2026-07-28` | [![Server conformance 2026-07-28](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/modelcontextprotocol/php-sdk/badges/server-conformance-2026-07-28.json)](https://github.com/modelcontextprotocol/php-sdk/actions/workflows/conformance-weekly.yaml) | [![Client conformance 2026-07-28](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/modelcontextprotocol/php-sdk/badges/client-conformance-2026-07-28.json)](https://github.com/modelcontextprotocol/php-sdk/actions/workflows/conformance-weekly.yaml) |
  21. | `2025-11-25` | [![Server conformance 2025-11-25](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/modelcontextprotocol/php-sdk/badges/server-conformance-2025-11-25.json)](https://github.com/modelcontextprotocol/php-sdk/actions/workflows/conformance-weekly.yaml) | [![Client conformance 2025-11-25](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/modelcontextprotocol/php-sdk/badges/client-conformance-2025-11-25.json)](https://github.com/modelcontextprotocol/php-sdk/actions/workflows/conformance-weekly.yaml) |
  22. ## Installation
  23. ```bash
  24. composer require mcp/sdk
  25. ```
  26. ## Build a server
  27. A server is a plain PHP class plus a few lines of wiring:
  28. ```php
  29. <?php
  30. require __DIR__.'/vendor/autoload.php';
  31. use Mcp\Server\Capability\Attribute\McpResource;
  32. use Mcp\Server\Capability\Attribute\McpTool;
  33. use Mcp\Server\Server;
  34. use Mcp\Server\Transport\StdioTransport;
  35. class Calculator
  36. {
  37. /**
  38. * Adds two numbers.
  39. */
  40. #[McpTool]
  41. public function add(int $a, int $b): int
  42. {
  43. return $a + $b;
  44. }
  45. #[McpResource(uri: 'config://calculator/settings')]
  46. public function settings(): array
  47. {
  48. return ['precision' => 2];
  49. }
  50. }
  51. exit(Server::builder()
  52. ->setServerInfo('Calculator', '1.0.0')
  53. ->setDiscovery(__DIR__, ['.'], excludeDirs: ['vendor'])
  54. ->build()
  55. ->run(new StdioTransport()));
  56. ```
  57. The `setDiscovery()` call needs `symfony/finder`:
  58. ```bash
  59. composer require symfony/finder
  60. ```
  61. The walkthrough in [First server](docs/get-started/first-server.md) explains each piece, and
  62. [Try it with the Inspector](docs/get-started/inspector.md) shows it running.
  63. ## Build a client
  64. ```php
  65. use Mcp\Client\Client;
  66. use Mcp\Client\Transport\StdioTransport;
  67. $client = Client::builder()
  68. ->setClientInfo('My Application', '1.0.0')
  69. ->build();
  70. $client->connect(new StdioTransport(command: 'php', args: ['/path/to/server.php']));
  71. $tools = $client->listTools();
  72. $result = $client->callTool('add', ['a' => 5, 'b' => 3]);
  73. $client->disconnect();
  74. ```
  75. See [Transports](docs/client/transports.md) for STDIO and HTTP, [Connecting to a server](docs/client/connecting.md)
  76. for timeouts, and [Server-initiated requests](docs/client/server-requests.md) for the handlers that
  77. answer requests from the server.
  78. ## Documentation
  79. The full documentation is published at **[php.sdk.modelcontextprotocol.io](https://php.sdk.modelcontextprotocol.io/)**.
  80. - **[Get started](docs/get-started/index.md)** — Install the SDK and build your first server
  81. - **[Servers](docs/servers/index.md)** — Tools, resources, resource templates, prompts, and how to register them
  82. - **[Inside your handler](docs/handlers/index.md)** — Talking back to the client, logging, and asking for input
  83. - **[Running your server](docs/run/index.md)** — Server builder, STDIO and HTTP transports, framework integration, sessions, authorization
  84. - **[Clients](docs/client/index.md)** — Client SDK for connecting to and communicating with MCP servers
  85. - **[Protocol versions](docs/protocol-versions.md)** — The two protocol eras, and what revision `2026-07-28` changed
  86. - **[Advanced](docs/advanced/index.md)** — Events, protocol extensions (including MCP Apps), and custom message handlers
  87. - **[Deprecation policy](docs/deprecation-policy.md)** — How deprecated features are handled
  88. - **[SDK tier target](docs/sdk-tier.md)** — Where the SDK stands on the MCP SDK tiers
  89. - **[Examples](docs/examples.md)** — Runnable server and client examples
  90. - **[API Reference](https://php.sdk.modelcontextprotocol.io/api/)** — Generated class reference
  91. ## External Resources
  92. - **[Model Context Protocol Documentation](https://modelcontextprotocol.io)** — Official MCP documentation
  93. - **[Model Context Protocol Specification](https://modelcontextprotocol.io/specification)** — Protocol specification
  94. - **[Officially Supported Servers](https://github.com/modelcontextprotocol/servers)** — Reference server implementations
  95. ## PHP Libraries Using the MCP SDK
  96. - [api-platform/mcp](https://github.com/api-platform/mcp) — MCP integration for API Platform
  97. - [bnomei/kirby-mcp](https://github.com/bnomei/kirby-mcp) — MCP server for the Kirby CMS
  98. - [drupal/mcp_server](https://www.drupal.org/project/mcp_server) — MCP server for Drupal exposing configuration and entities as MCP elements
  99. - [josbeir/cakephp-synapse](https://github.com/josbeir/cakephp-synapse) — CakePHP plugin exposing application functionality over MCP
  100. - [nette/mcp-inspector](https://github.com/nette/mcp-inspector) — MCP server for introspecting Nette applications
  101. - [symfony/mcp-bundle](https://github.com/symfony/mcp-bundle) — Symfony integration bundle
  102. Building something on top of the SDK? Open a pull request to add it to this list.
  103. ## Contributing
  104. We are passionate about supporting contributors of all levels of experience and would love to see you get involved in
  105. the project. Start by [reporting issues](https://github.com/modelcontextprotocol/php-sdk/issues) or
  106. [sending pull requests](https://github.com/modelcontextprotocol/php-sdk/pulls). See
  107. [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, coding standards, and what to run before
  108. opening a PR.
  109. ## Credits
  110. 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.
  111. ## License
  112. 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 in

Free to use. If it’s helped, pass it on.