SOLFIND
Web Lens
Portal home

GitHub - modelcontextprotocol/php-sdk: The official PHP SDK for Model Context Protocol servers and clients. Maintained in collaboration with The PHP Foundation. · GitHub

https://github.com/modelcontextprotocol/php-sdk • 352 KB fetched
Open original page


GitHub - modelcontextprotocol/php-sdk: The official PHP SDK for Model Context Protocol servers and clients. Maintained in collaboration with The PHP Foundation. · GitHub Skip to content Navigation Menu Sign in Appearance settings * Platform * AI CODE CREATION * GitHub Copilot Write better code with AI * GitHub Copilot app Direct agents from issue to merge * MCP Registry Integrate external tools * DEVELOPER WORKFLOWS * Actions Automate any workflow * Codespaces Instant dev environments * Issues Plan and track work * Code Review Manage code changes * Code Quality Enforce quality at merge * APPLICATION SECURITY * GitHub Advanced Security Find and fix vulnerabilities * Code security Secure your code as you build * Secret protection Stop leaks before they start * EXPLORE * Why GitHub * Documentation * Blog * Changelog * Marketplace View all features * Solutions * BY COMPANY SIZE * Enterprises * Small and medium teams * Startups * Nonprofits * BY USE CASE * App Modernization * DevSecOps * DevOps * CI/CD * View all use cases * BY INDUSTRY * Healthcare * Financial services * Manufacturing * Government * View all industries View all solutions * Resources * EXPLORE BY TOPIC * AI * Software Development * DevOps * Security * View all topics * EXPLORE BY TYPE * Customer stories * Events & webinars * Ebooks & reports * Business insights * GitHub Skills * SUPPORT & SERVICES * Documentation * Customer support * Community forum * Trust center * Partners View all resources * Open Source * COMMUNITY * GitHub Sponsors Fund open source developers * PROGRAMS * Security Lab * Maintainer Community * GitHub Stars * Archive Program * REPOSITORIES * Topics * Trending * Collections * Enterprise * ENTERPRISE SOLUTIONS * Enterprise platform AI-powered developer platform * AVAILABLE ADD-ONS * GitHub Advanced Security Enterprise-grade security features * Copilot for Business Enterprise-grade AI features * Premium Support Enterprise-grade 24/7 support * Pricing Search / Sign in Sign up Appearance settings You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert Uh oh! There was an error while loading. Please reload this page . modelcontextprotocol / php-sdk Public * Notifications You must be signed in to change notification settings * Fork 169 * Star 1.6k * Code * Issues 56 * Pull requests 13 * Actions * Projects * Security and quality 1 * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security and quality * Insights main Branches Tags Go to file Code Open more actions menu Latest commit   History 289 Commits 289 Commits Folders and files Name Name 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     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     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     View all files Repository files navigation * * README * Code of conduct * Contributing * License * Security More items MCP PHP SDK 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 2025-11-25 Installation composer require mcp/sdk Build a server A server is a plain PHP class plus three lines of wiring: use Mcp \ Capability \ Attribute \ McpResource ; use Mcp \ Capability \ Attribute \ McpTool ; use Mcp \ 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 walkthrough in First server explains each piece, and Try it with the Inspector shows it running. Build a client use Mcp \ 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 Connecting to a server for transports, timeouts, and the handlers that answer server-initiated requests. 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 * 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/ai-mate — AI development assistant MCP server for Symfony projects * 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 mcp mcp-client mcp-server php Resources Readme License Code of conduct Code of conduct Contributing Contributing Security policy Security policy Activity Custom properties Stars 1.6k stars Watchers 24 watching Forks 169 forks Report repository Releases Used by Contributors Languages Footer (c) 2026 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Community * Docs * Contact * Manage cookies * Do not share my personal information You can’t perform that action at this time.

Links found on this page

  1. Skip to content [direct]
  2. Sign in [direct]
  3. GitHub Copilot Write better code with AI [direct]
  4. GitHub Copilot app Direct agents from issue to merge [direct]
  5. MCP Registry Integrate external tools [direct]
  6. Actions Automate any workflow [direct]
  7. Codespaces Instant dev environments [direct]
  8. Issues Plan and track work [direct]
  9. Code Review Manage code changes [direct]
  10. Code Quality Enforce quality at merge [direct]
  11. GitHub Advanced Security Find and fix vulnerabilities [direct]
  12. Code security Secure your code as you build [direct]
  13. Secret protection Stop leaks before they start [direct]
  14. Why GitHub [direct]
  15. Documentation [direct]
  16. Blog [direct]
  17. Changelog [direct]
  18. Marketplace [direct]
  19. View all features [direct]
  20. Enterprises [direct]
  21. Small and medium teams [direct]
  22. Startups [direct]
  23. Nonprofits [direct]
  24. App Modernization [direct]
  25. DevSecOps [direct]
  26. DevOps [direct]
  27. CI/CD [direct]
  28. View all use cases [direct]
  29. Healthcare [direct]
  30. Financial services [direct]
  31. Manufacturing [direct]
  32. Government [direct]
  33. View all industries [direct]
  34. View all solutions [direct]
  35. AI [direct]
  36. Software Development [direct]
  37. DevOps [direct]
  38. Security [direct]
  39. View all topics [direct]
  40. Customer stories [direct]
  41. Events & webinars [direct]
  42. Ebooks & reports [direct]
  43. Business insights [direct]
  44. GitHub Skills [direct]
  45. Customer support [direct]
  46. Community forum [direct]
  47. Trust center [direct]
  48. Partners [direct]
  49. View all resources [direct]
  50. GitHub Sponsors Fund open source developers [direct]
  51. Security Lab [direct]
  52. Maintainer Community [direct]
  53. GitHub Stars [direct]
  54. Archive Program [direct]
  55. Topics [direct]
  56. Trending [direct]
  57. Collections [direct]
  58. Copilot for Business Enterprise-grade AI features [direct]
  59. Premium Support Enterprise-grade 24/7 support [direct]
  60. Pricing [direct]
  61. Sign up [direct]
  62. modelcontextprotocol [direct]
  63. Notifications [direct]
  64. Issues 56 [direct]
  65. Pull requests 13 [direct]
  66. Actions [direct]
  67. Projects [direct]
  68. Security and quality 1 [direct]
  69. Insights [direct]
  70. Branches [direct]
  71. Tags [direct]
  72. 289 Commits [direct]
  73. .github [direct]
  74. .phpdoc/ template [direct]
  75. adr [direct]
  76. docs [direct]
  77. examples [direct]
  78. src [direct]
  79. tests [direct]
  80. .gitattributes [direct]