Skip to content

PHP MCP SDKBuild AI Agents with PHP

The most complete Model Context Protocol implementation for PHP. Connect LLMs to your data, APIs, and tools with a production-ready async SDK.

PHP MCP SDK

Quick Start โ€‹

Get up and running in minutes:

bash
composer require dalehurley/php-mcp-sdk

Create Your First MCP Server โ€‹

php
#!/usr/bin/env php
<?php
require_once __DIR__ . '/vendor/autoload.php';

use MCP\Server\McpServer;
use MCP\Server\Transport\StdioServerTransport;
use MCP\Types\Implementation;
use function Amp\async;

$server = new McpServer(
    new Implementation('hello-world-server', '1.0.0')
);

$server->tool(
    'say_hello',
    'Says hello to someone',
    [
        'type' => 'object',
        'properties' => [
            'name' => ['type' => 'string', 'description' => 'Name to greet']
        ],
        'required' => ['name']
    ],
    function (array $args): array {
        return [
            'content' => [['type' => 'text', 'text' => "Hello, {$args['name']}!"]]
        ];
    }
);

async(function () use ($server) {
    $transport = new StdioServerTransport();
    $server->connect($transport)->await();
})->await();

Connect to Claude Desktop โ€‹

Add to your claude_desktop_config.json:

json
{
  "mcpServers": {
    "hello-world": {
      "command": "php",
      "args": ["/path/to/your/server.php"]
    }
  }
}

Try It Online โ€‹

Explore PHP MCP SDK without any local setup:

โ–ถ

PHP Sandbox

Run PHP code instantly in your browser with 3v4l.org โ€” no installation needed.

Open PHP Sandbox โ†’
๐Ÿ”

MCP Inspector

Visually test and debug your MCP server using the official MCP Inspector tool.

MCP Inspector โ†’
๐Ÿ“‹

Hello World Example

A complete, runnable Hello World example to copy, paste, and start customising.

View Example โ†’

By the Numbers โ€‹

20+
Working Examples
4
Framework Integrations
3
Transport Options
PHP 8.1+
Minimum Requirement
MIT
Open Source License
100%
MCP Spec Coverage

Use Cases โ€‹

What are developers building with PHP MCP SDK?

๐Ÿค–

AI-Powered Chatbots

Connect Claude, GPT-4, or any LLM to your PHP application data โ€” databases, APIs, CMS content โ€” and let AI answer questions in real time.

๐Ÿ“Š

Business Intelligence Agents

Give AI agents read access to your ERP, CRM, or analytics platform so non-technical users can query complex data with natural language.

๐Ÿ”ง

Developer Tooling

Build MCP servers that expose code analysis, CI/CD pipelines, and deployment tools directly into AI coding assistants like Claude Code.

๐Ÿข

Enterprise Automation

Automate complex multi-step workflows with AI orchestration across microservices โ€” approvals, notifications, data transformation, and more.

๐Ÿ›’

E-commerce Intelligence

Let AI agents interact with your product catalog, inventory, and order systems to assist customers and automate merchandising tasks.

๐Ÿ“

Content Management

Build AI-assisted CMS tools that can draft, edit, categorise, and publish content while accessing your full content library as context.

Performance Highlights โ€‹

PHP MCP SDK is designed for production workloads:

Non-Blocking I/O

Built on Amphp โ€” PHP's battle-tested async framework. Handle multiple concurrent MCP sessions without the overhead of multi-threading.

No blocking calls ยท Event-loop driven ยท Coroutine-based

Efficient Transport

HTTP Streaming uses chunked transfer for low-latency, memory-efficient message delivery. STDIO transport has near-zero overhead for local use.

Chunked streaming ยท Connection pooling ยท Keep-alive support

Memory Optimised

Resources are streamed and never fully loaded into memory. Large file and database operations stay lean regardless of dataset size.

Lazy loading ยท Generator-based streaming ยท Configurable limits

What's New in v1.0.0 โ€‹

NEW
Full MCP Specification Coverage โ€” Tools, resources, prompts, sampling, roots, and elicitation all implemented to spec.
NEW
OAuth 2.0 + PKCE Authentication โ€” Production-ready auth flow with token refresh and secure storage.
NEW
Laravel & Symfony Integrations โ€” First-class framework support with service providers, facades, and DI container integration.
NEW
Agentic AI Toolkit โ€” Multi-agent orchestration, tool chaining, and agent-to-agent communication primitives.
NEW
20+ Production Examples โ€” From Hello World to enterprise microservices, with Docker deployment configs included.
View full changelog โ†’

Why Choose PHP MCP SDK? โ€‹

Complete MCP Coverage โ€‹

The full Model Context Protocol spec โ€” not a partial port. Tools, resources, prompts, sampling, roots, and elicitation are all implemented and tested.

Framework-First Design โ€‹

PSR-compliant throughout. Drop-in support for Laravel and Symfony means you spend time on features, not plumbing.

Agentic AI Ready โ€‹

Built from the ground up for AI agents. Multi-agent coordination, tool orchestration, and complex workflow automation are first-class citizens.

Enterprise Grade โ€‹

Docker deployment, microservices architecture, monitoring, observability, and security hardening guides โ€” ready for production from day one.

The Best Documentation in the Ecosystem โ€‹

20+ working code examples, comprehensive API reference, integration guides, and troubleshooting resources. If you're stuck, the answer is in the docs.

Real-World Applications โ€‹

๐Ÿข Enterprise API Gateway

Complete API orchestration with authentication, rate limiting, and distributed monitoring across microservices.

View Example โ†’

๐Ÿ“ Blog CMS

AI-assisted content management system with user management, media handling, and analytics integration.

View Example โ†’

๐Ÿค– AI Agent Orchestrator

Multi-agent system with specialised agents for research, writing, coding, and task management with human-in-the-loop workflows.

View Example โ†’

๐Ÿ“Š Data Pipeline

High-throughput data processing pipeline with AI-powered transformation, validation, and enrichment.

View Example โ†’

๐Ÿ”ฌ Code Analyser

Automated code review and quality analysis tool powered by AI with custom rule engines and reporting.

View Example โ†’

โœ… Task Manager

AI-enhanced project management with natural language task creation, prioritisation, and automated status updates.

View Example โ†’

Badges โ€‹

Add these to your project's README to show PHP MCP SDK integration:

markdown
[![PHP MCP SDK](https://img.shields.io/badge/PHP%20MCP%20SDK-v1.0.0-646cff)](https://phpmcpsdk.com)
[![PHP Version](https://img.shields.io/badge/PHP-8.1%2B-777BB4)](https://php.net)
[![MCP Protocol](https://img.shields.io/badge/MCP-Protocol%20Compliant-00A86B)](https://modelcontextprotocol.io)
[![License](https://img.shields.io/badge/License-MIT-green)](https://github.com/dalehurley/php-mcp-sdk/blob/main/LICENSE)