GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - modelcontextprotocol/php-sdk: The official PHP SDK for Model Context Protocol servers and clients. Maintained in collaboration with The PHP Foundation.

BranchesTags
Open more actions menu

Latest commit

 

History

471 Commits
471 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.phpdoc/template
.phpdoc/template
 
 
adr
adr
 
 
docs
docs
 
 
examples
examples
 
 
src
src
 
 
tests
tests
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.php-cs-fixer.dist.php
.php-cs-fixer.dist.php
 
 
AGENTS.md
AGENTS.md
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
ROADMAP.md
ROADMAP.md
 
 
SECURITY.md
SECURITY.md
 
 
composer.json
composer.json
 
 
deptrac.yaml
deptrac.yaml
 
 
mkdocs.yml
mkdocs.yml
 
 
phpdoc.dist.xml
phpdoc.dist.xml
 
 
phpstan-baseline.neon
phpstan-baseline.neon
 
 
phpstan.dist.neon
phpstan.dist.neon
 
 
phpunit.xml.dist
phpunit.xml.dist
 
 
requirements-docs.txt
requirements-docs.txt
 
 

Repository files navigation

MCP PHP SDK

Latest Version CI PHP Version 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 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.

Protocol Conformance

Measured weekly against the MCP Conformance Test Framework, 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 Server conformance 2026-07-28 Client conformance 2026-07-28
2025-11-25 Server conformance 2025-11-25 Client conformance 2025-11-25

Installation

composer require mcp/sdk

Build a server

A server is a plain PHP class plus a few lines of wiring:

<?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:

composer require symfony/finder

The walkthrough in First server explains each piece, and Try it with the Inspector shows it running.

Build a client

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 for STDIO and HTTP, Connecting to a server for timeouts, and Server-initiated requests for the handlers that answer requests from the server.

Documentation

The full documentation is published at php.sdk.modelcontextprotocol.io.

  • Get started — Install the SDK and build your first server
  • Servers — Tools, resources, resource templates, prompts, and how to register them
  • Inside your handler — Talking back to the client, logging, and asking for input
  • Running your server — Server builder, STDIO and HTTP transports, framework integration, sessions, authorization
  • Clients — Client SDK for connecting to and communicating with MCP servers
  • Protocol versions — The two protocol eras, and what revision 2026-07-28 changed
  • Advanced — Events, protocol extensions (including MCP Apps), and custom message handlers
  • Deprecation policy — How deprecated features are handled
  • SDK tier target — Where the SDK stands on the MCP SDK tiers
  • Examples — Runnable server and client examples
  • API Reference — Generated class reference

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/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 or sending pull requests. See 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 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.

About

The official PHP SDK for Model Context Protocol servers and clients. Maintained in collaboration with The PHP Foundation.

php.sdk.modelcontextprotocol.io

Topics

mcpmcp-clientmcp-serverphp

Resources

Readme
License

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

1.7k stars

Watchers

24 watching

Forks

203 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.