PHPackages                             php-mcp/server - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [DevOps &amp; Deployment](/categories/devops)
4. /
5. php-mcp/server

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

php-mcp/server
==============

PHP SDK for building Model Context Protocol (MCP) servers - Create MCP tools, resources, and prompts

3.3.0(10mo ago)828280.5k—4.6%61[11 issues](https://github.com/php-mcp/server/issues)[6 PRs](https://github.com/php-mcp/server/pulls)20MITPHPPHP &gt;=8.1CI passing

Since Apr 28Pushed 9mo ago14 watchersCompare

[ Source](https://github.com/php-mcp/server)[ Packagist](https://packagist.org/packages/php-mcp/server)[ RSS](/packages/php-mcp-server/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (18)Versions (19)Used By (20)

PHP MCP Server SDK
==================

[](#php-mcp-server-sdk)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d9322fa30d111fd68b37f44198ea883b348d0dae9a67723b7b0beb42db5ae2e4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068702d6d63702f7365727665722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/php-mcp/server)[![Total Downloads](https://camo.githubusercontent.com/2ff1305d0608b7b0103391c1301b854aa19453f597580fe2274ee1ed883e9e3e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068702d6d63702f7365727665722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/php-mcp/server)[![Tests](https://camo.githubusercontent.com/f4a8122b1502e6cdadc2707492de74a78a720d126dc8de08bf95b2c26e03c5f0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7068702d6d63702f7365727665722f74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265)](https://github.com/php-mcp/server/actions/workflows/tests.yml)[![License](https://camo.githubusercontent.com/207779997c3b73fc075a6d6f6523af6df2a5f753d09f17e426448dec6caac2d7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7068702d6d63702f7365727665722e7376673f7374796c653d666c61742d737175617265)](LICENSE)

**A comprehensive PHP SDK for building [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) servers. Create production-ready MCP servers in PHP with modern architecture, extensive testing, and flexible transport options.**

This SDK enables you to expose your PHP application's functionality as standardized MCP **Tools**, **Resources**, and **Prompts**, allowing AI assistants (like Anthropic's Claude, Cursor IDE, OpenAI's ChatGPT, etc.) to interact with your backend using the MCP standard.

🚀 Key Features
--------------

[](#-key-features)

- **🏗️ Modern Architecture**: Built with PHP 8.1+ features, PSR standards, and modular design
- **📡 Multiple Transports**: Supports `stdio`, `http+sse`, and new **streamable HTTP** with resumability
- **🎯 Attribute-Based Definition**: Use PHP 8 Attributes (`#[McpTool]`, `#[McpResource]`, etc.) for zero-config element registration
- **🔧 Flexible Handlers**: Support for closures, class methods, static methods, and invokable classes
- **📝 Smart Schema Generation**: Automatic JSON schema generation from method signatures with optional `#[Schema]` attribute enhancements
- **⚡ Session Management**: Advanced session handling with multiple storage backends
- **🔄 Event-Driven**: ReactPHP-based for high concurrency and non-blocking operations
- **📊 Batch Processing**: Full support for JSON-RPC batch requests
- **💾 Smart Caching**: Intelligent caching of discovered elements with manual override precedence
- **🧪 Completion Providers**: Built-in support for argument completion in tools and prompts
- **🔌 Dependency Injection**: Full PSR-11 container support with auto-wiring
- **📋 Comprehensive Testing**: Extensive test suite with integration tests for all transports

This package supports the **2025-03-26** version of the Model Context Protocol with backward compatibility.

📋 Requirements
--------------

[](#-requirements)

- **PHP** &gt;= 8.1
- **Composer**
- **For HTTP Transport**: An event-driven PHP environment (CLI recommended)
- **Extensions**: `json`, `mbstring`, `pcre` (typically enabled by default)

📦 Installation
--------------

[](#-installation)

```
composer require php-mcp/server
```

> **💡 Laravel Users**: Consider using [`php-mcp/laravel`](https://github.com/php-mcp/laravel) for enhanced framework integration, configuration management, and Artisan commands.

⚡ Quick Start: Stdio Server with Discovery
------------------------------------------

[](#-quick-start-stdio-server-with-discovery)

This example demonstrates the most common usage pattern - a `stdio` server using attribute discovery.

**1. Define Your MCP Elements**

Create `src/CalculatorElements.php`:

```
