back to home

modelcontextprotocol / php-sdk

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

1,413 stars
123 forks
29 issues
PHPTwigMakefile

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing modelcontextprotocol/php-sdk in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/modelcontextprotocol/php-sdk)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

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. Installation Quick Start This example demonstrates the most common usage pattern - a STDIO server using attribute discovery. • Define Your MCP Elements Create a class with MCP capabilities using attributes: • Create the Server Script Create your MCP server: • Configure Your MCP Client Add to your client configuration (e.g., Claude Desktop's ): • Test Your Server Key Features Attribute-Based Discovery Define MCP elements using PHP attributes with automatic discovery: Manual Registration Register capabilities programmatically: Multiple Transport Options **STDIO Transport** (Command-line integration): **HTTP Transport** (Web-based communication): Session Management By default, the SDK uses in-memory sessions. You can configure different session stores: Discovery Caching Use any PSR-16 cache implementation to cache discovery results and avoid running discovery on every server start: Documentation **Core Concepts:** • Server Builder - Complete ServerBuilder reference and configuration • Transports - STDIO and HTTP transport setup and usage • MCP Elements - Creating tools, resources, and prompts • Client Communication - Communicating back to the client from server-side • Events - Hooking into server lifecycle with events **Learning:** • Examples - Comprehensive example walkthroughs **External Resources:** • Model Context Protocol documentation • Model Context Protocol specification • Officially supported servers PHP Libraries Using the MCP SDK • pronskiy/mcp - Additional DX layer • symfony/mcp-bundle - Symfony integration bundle • josbeir/cakephp-synapse - CakePHP integration plugin 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 contributing guide to get started before you report issues and 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.