laravel  by php-mcp

Laravel SDK for building MCP servers

Created 10 months ago
470 stars

Top 64.8% 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

6 months ago

Responsiveness

1 week

Pull Requests (30d)
0
Issues (30d)
1
Star History
2 stars in the last 30 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Kent Dodds Kent Dodds(Cofounder of Remix), and
10 more.

agentic by transitive-bullshit

0.0%
18k
AI agent stdlib for LLM-based TypeScript tooling
Created 3 years ago
Updated 2 weeks ago
Feedback? Help us improve.