Skip to content

PHP MCP SDKModel Context Protocol for PHP

Build intelligent AI agents and applications with seamless integration between LLMs and external data sources

PHP MCP SDK

Quick Start

Get up and running with PHP MCP SDK 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;

// Create the simplest possible MCP server
$server = new McpServer(
    new Implementation('hello-world-server', '1.0.0')
);

// Add a simple "say_hello" tool
$server->tool(
    'say_hello',
    'Says hello to someone',
    [
        'type' => 'object',
        'properties' => [
            'name' => [
                'type' => 'string',
                'description' => 'Name of the person to greet'
            ]
        ],
        'required' => ['name']
    ],
    function (array $args): array {
        $name = $args['name'] ?? 'World';
        return [
            'content' => [
                [
                    'type' => 'text',
                    'text' => "Hello, {$name}! 👋 Welcome to MCP!"
                ]
            ]
        ];
    }
);

// Start the server
async(function () use ($server) {
    echo "🚀 Hello World MCP Server starting...\n";
    $transport = new StdioServerTransport();
    $server->connect($transport)->await();
})->await();

Test with Claude Desktop

Add to your Claude Desktop configuration:

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

Why Choose PHP MCP SDK?

🎯 Comprehensive Examples

20+ working examples from simple "Hello World" to complex real-world applications like Blog CMS, Task Manager, and API Gateway.

🏗️ Framework Ready

Seamless integration with Laravel, Symfony, and other PHP frameworks through PSR-compliant design.

🤖 Agentic AI First

Built specifically for creating intelligent AI agents with multi-agent coordination and tool orchestration.

🏭 Enterprise Grade

Production-ready features including Docker deployment, microservices architecture, monitoring, and observability.

📖 Best-in-Class Documentation

The most comprehensive MCP SDK documentation in the ecosystem with tested examples and migration guides.

Real-World Applications

🏢 Enterprise API Gateway

Complete API orchestration system with authentication, rate limiting, and monitoring

View Example →

📝 Blog CMS

Full-featured content management system with user management and analytics

View Example →

🤖 AI Agent Orchestrator

Multi-agent system with specialized agents for different tasks and coordination

View Example →

Released under the MIT License.