laravel/mcp
Build MCP servers in Laravel so AI clients can securely interact with your app via the Model Context Protocol. Quick setup, Laravel-native conventions, and official Laravel documentation support for exposing tools, resources, and prompts to MCP-compatible clients.
Laravel MCP is a highly specialized package designed to integrate Model Context Protocol (MCP) into Laravel applications, enabling AI clients to interact with Laravel APIs via structured JSON-RPC and OAuth2-based tool registration. Its architecture aligns well with:
Key architectural strengths:
Potential misfits:
| Integration Aspect | Feasibility | Notes |
|---|---|---|
| Laravel Core | High | Designed for Laravel; integrates with routing, middleware, and service container. |
| OAuth2/OIDC | High | Built-in OAuth client registration and discovery. |
| JSON-RPC | High | Supports requests/responses, notifications, and streaming. |
| Tool Registration | Medium-High | Requires defining tools as resources (annotations/attributes) or via Mcp::tool(). |
| Authentication | High | Supports MCP session IDs, OAuth2, and tool-specific auth. |
| Content Types | Medium | Supports structured JSON, images, audio, and HTML (via MCP UI App). |
| Testing | High | Includes test utilities for resources, URI templates, and JSON-RPC. |
| Octane/Real-Time | Medium | Streaming support exists but may need tuning for high-throughput scenarios. |
| Custom Protocols | Low | MCP-specific; extending beyond JSON-RPC/OAuth2 requires significant effort. |
Key dependencies:
| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Protocol Drift | Medium | MCP is evolving (e.g., spec updates in 2025). Monitor MCP spec and Laravel MCP releases. |
| Tool Registration Complexity | Medium | Requires understanding of MCP’s Tool and Resource definitions. Use stubs and docs. |
| Performance Overhead | Low-Medium | JSON-RPC and OAuth2 add latency. Benchmark under load; consider Octane for high-throughput. |
| Security Misconfigurations | High | OAuth2 misconfigurations (e.g., loose client registration) could expose APIs. Use Laravel’s auth guards and MCP’s validation. |
| Content Type Limitations | Low | Limited to MCP-supported types (JSON, images, audio, HTML). Custom types require extension. |
| Debugging | Medium | MCP Inspector CLI helps, but JSON-RPC errors may need deep inspection of request/response payloads. |
| Vendor Lock-in | Low | MCP is a standard; migration to another MCP server would be straightforward. |
Critical questions for the TPM:
Laravel MCP is optimized for:
Compatibility Matrix:
| Stack Component | Compatibility | Notes |
|---|---|---|
| Laravel Framework | High | Tested on Laravel 10/11; requires PHP 8.2+. |
| Laravel Passport | High | OAuth2 client registration is built on Passport’s endpoints. |
| Laravel Sanctum | Medium | Sanctum’s token-based auth can coexist but requires MCP session ID handling. |
| Laravel Octane | Medium | Streaming support exists but may need tuning for high concurrency. |
| Database | High | No direct DB dependencies; tools/resources are defined in code. |
| Storage (S3, etc.) | High | Required for image/audio content types. |
| Queue Workers | Medium | Async tool processing is possible but not a core feature. |
| Third-Party AI Clients | High | Any MCP-compatible client (e.g., LangChain, CrewAI) will work. |
#[Tool] attribute or Mcp::tool().mcp:register CLI or manual OAuth2 flow.MCP-Session-Id header).composer require laravel/mcp.php artisan vendor:publish --provider="Laravel\Mcp\McpServiceProvider".config/mcp.php (e.g., host, port, protocol version).#[Tool], #[Resource].Mcp::tool()->name()->description()->action().use Laravel
How can I help you explore Laravel packages today?