Laravel SDK for building MCP servers
Top 90.1% on SourcePulse
This SDK provides a comprehensive Laravel-native wrapper for building Model Context Protocol (MCP) servers, enabling developers to expose their Laravel application's functionality as standardized MCP elements (Tools, Resources, Prompts) for AI assistants. It targets Laravel developers seeking to integrate their applications with AI agents like Claude, Cursor IDE, and ChatGPT.
How It Works
The SDK leverages Laravel's service container, configuration, and Artisan commands to provide a seamless development experience. MCP elements can be defined either manually using a fluent Mcp
facade or automatically via PHP 8 attributes. It supports multiple transport mechanisms: STDIO for command-line integration, integrated HTTP for development and existing web servers, and a dedicated, high-performance ReactPHP HTTP server recommended for production.
Quick Start & Requirements
composer require php-mcp/laravel
php artisan vendor:publish --provider="PhpMcp\Laravel\McpServiceProvider" --tag="mcp-config"
php artisan vendor:publish --provider="PhpMcp\Laravel\McpServiceProvider" --tag="mcp-migrations" && php artisan migrate
Highlighted Details
Mcp
facade and attribute-based discovery (#[McpTool]
, #[McpResource]
, etc.).Maintenance & Community
The project is actively maintained by php-mcp. Further community and contribution details can be found in the CONTRIBUTING.md
file.
Licensing & Compatibility
The project is released under the MIT License, allowing for commercial use and integration with closed-source applications.
Limitations & Caveats
The integrated HTTP transport using PHP's built-in server or standard SSE can tie up worker processes; a dedicated HTTP server or async PHP (Octane with Swoole/RoadRunner) is recommended for production. When using STDIO transport, direct writes to STDOUT are reserved for JSON-RPC communication and should be avoided.
3 weeks ago
Inactive