Skip to content
FossShelf
Home / Categories / For Engineers

Php Sdk

Official PHP SDK for the Model Context Protocol

Replaces —

1.68K starsApache-2.0 and MIT (dual, transitional)last commit 13 Nov 2026

Who it's for

PHP backend exposing tools to an AI host

A team with an existing PHP service wants to let an LLM-powered host call their business logic as MCP tools. They annotate service methods with `#[McpTool]`, start the server over STDIO or HTTP, and the host connects without any custom protocol code.

Symfony or Laravel application adding MCP support

A framework-based PHP application integrates MCP through `symfony/mcp-bundle` or equivalent community packages, exposing application entities, configuration, or domain actions as resources and tools to AI assistants.

You are not using a supported PHP framework and do not want to write integration glue.

PHP application consuming MCP servers

A PHP application acts as an MCP client, connecting to external MCP servers to call their tools or read their resources, using the client SDK's builder API and transport options.

You only need to build a server and have no interest in consuming external MCP servers.

CMS or platform exposing content as MCP resources

A Drupal site or Kirby CMS installation uses the available MCP modules to expose pages, configuration, and entities as MCP resources, making site content queryable by any MCP-compatible AI host.

Your platform does not have an existing MCP integration module and you prefer not to build one.

The problem

PHP developers building applications that integrate with LLMs have no standardized way to expose tools, data sources, or prompts to AI hosts. Without a shared protocol and a framework-agnostic library, every integration requires custom serialization, transport logic, and schema generation, making it difficult to connect PHP applications to the growing ecosystem of MCP-compatible AI hosts and clients.

How it works

Attribute-driven server definition

Annotate plain PHP class methods with `#[McpTool]` and `#[McpResource]` to expose them as MCP capabilities. JSON Schema is derived from PHP type hints automatically, removing manual schema authoring.

STDIO and Streamable HTTP transports

Ships with both standard MCP transports out of the box. STDIO suits process-based hosts; Streamable HTTP suits web deployments. Optional PSR packages connect the HTTP transport to any PSR-compatible framework.

Client SDK

A matching client API lets PHP applications connect to any MCP server, list tools, call them, read resources, and handle server-initiated requests, all through the same builder pattern used by the server side.

Dual protocol revision support

Implements both the `initialize`-handshake protocol era and the stateless `2026-07-28` revision. Conformance against both revisions is verified weekly using the official MCP Conformance Test Framework.

Framework integration

Community libraries connect the SDK to Symfony (`symfony/mcp-bundle`), API Platform (`api-platform/mcp`), Drupal (`drupal/mcp_server`), Kirby CMS, CakePHP, and Nette, enabling MCP in existing applications without restructuring.

Symfony-grade development standards

Developed under Symfony's coding standards and backward compatibility promise. Once the 1.0 release ships, the BC promise applies to public APIs, giving library authors a stable upgrade path.

Features

  • Attribute-driven server definition
  • STDIO and Streamable HTTP transports
  • Client SDK
  • Dual protocol revision support
  • Framework integration
  • Symfony-grade development standards

How to install

composer require mcp/sdk

Recommended for this setup

Strengths

  • Minimal boilerplate: A complete MCP server requires a PHP class with type-hinted methods and three lines of wiring. The SDK derives schemas from native PHP types, handles protocol negotiation, and manages transport, so application code focuses solely on business logic.
  • Official and specification-aligned: Produced by the PHP Foundation and Symfony project as the official SDK, not a community fork. Weekly conformance runs against the MCP Conformance Test Framework provide public, verifiable evidence of spec alignment for both server and client roles.
  • Framework-agnostic core: The core SDK has no mandatory framework dependency. Symfony Finder is optional for attribute discovery; PSR packages are optional for HTTP. This keeps the library usable in vanilla PHP, Laravel, Symfony, or any other stack.
  • Broad ecosystem coverage: The growing list of libraries built on the SDK -- covering Symfony, API Platform, Drupal, Kirby, CakePHP, and Nette -- means most existing PHP applications have a direct integration path without writing custom glue code.

Trade-offs

  • Pre-1.0 and experimental: The SDK is explicitly marked experimental until the first major release. Public APIs may change before 1.0 ships. The roadmap documents what is still planned, so teams building production systems should review it before committing.
  • Attribute discovery requires symfony/finder: The auto-discovery mechanism that scans directories for `#[McpTool]` and `#[McpResource]` attributes depends on `symfony/finder`. Without it the server starts but registers no capabilities, which may not be obvious to newcomers.
  • PHP 8.1 minimum: Named arguments, attributes, and intersection types used by the SDK require PHP 8.1 or later. Projects running on older PHP versions cannot use it.

Tech stack

Languages
PHP, Makefile, Shell, JavaScript, Twig
Frameworks
—
Databases
—
Tooling
—

FAQ

Is this the official PHP SDK for MCP?

Yes. It is the official PHP SDK for the Model Context Protocol, produced as a collaboration between the PHP Foundation and the Symfony project, and hosted under the `modelcontextprotocol` GitHub organization.

Is the SDK stable enough for production use?

The SDK is explicitly experimental until the first major release. The Symfony backward compatibility promise will apply to public APIs once 1.0 ships. Teams should review the roadmap and changelog before using it in production.

What transports does it support?

STDIO and Streamable HTTP. Optional PSR packages connect the HTTP transport to any PSR-compatible HTTP server or client. The transport is passed when starting the server or connecting the client.

Do I need to write JSON Schema for my tools?

No. The SDK derives JSON Schema from PHP type hints on method parameters. A method declared as `add(int $a, int $b): int` produces the correct schema automatically.

Which PHP version is required?

PHP 8.1 or later. The SDK uses PHP attributes, named arguments, and other PHP 8.1 features that are not available in earlier versions.

Similar tools

More in Engineers