laravel  by php-mcp

Laravel SDK for building MCP servers

created 3 months ago
299 stars

Top 90.1% on SourcePulse

GitHubView on GitHub
Project Summary

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

  • Install: composer require php-mcp/laravel
  • Publish Config: php artisan vendor:publish --provider="PhpMcp\Laravel\McpServiceProvider" --tag="mcp-config"
  • Publish Migrations (for DB sessions): php artisan vendor:publish --provider="PhpMcp\Laravel\McpServiceProvider" --tag="mcp-migrations" && php artisan migrate
  • Requirements: PHP >= 8.1, Laravel >= 10.0.

Highlighted Details

  • Supports manual registration via Mcp facade and attribute-based discovery (#[McpTool], #[McpResource], etc.).
  • Offers flexible transport options: STDIO, integrated HTTP, and a dedicated ReactPHP HTTP server.
  • Features advanced session management with Laravel-native handlers (file, database, cache, redis).
  • Includes schema validation via PHP attributes and completion providers for enhanced developer experience.
  • Integrates with Laravel's event system for dynamic updates to clients.

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.

Health Check
Last commit

3 weeks ago

Responsiveness

Inactive

Pull Requests (30d)
3
Issues (30d)
10
Star History
283 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.