laravel/mcp
Build MCP servers inside Laravel so AI clients can safely interact with your app via the Model Context Protocol. Includes tools to expose app capabilities, run requests, and integrate quickly using Laravel’s conventions and docs.
Laravel MCP is a highly specialized package designed to integrate Laravel applications with the Model Context Protocol (MCP), enabling AI clients to interact with Laravel via structured APIs. Key architectural strengths:
405 Allow headers for unsupported methods).Fit for Use Cases: ✅ AI Agent Integration: Ideal for exposing Laravel backends to AI agents (e.g., retrieval-augmented generation, workflow automation). ✅ Interactive Tools: Supports HTML/JS resources (via MCP UI App) for browser-based agent interactions. ✅ Multi-Modal Data: Handles images, audio, and structured data (e.g., via Laravel Storage). ❌ Not a General API Layer: Overkill for traditional REST/gRPC APIs; MCP is AI-specific.
| Component | Feasibility | Notes |
|---|---|---|
| Laravel Core | High | Designed for Laravel 10/11; uses service providers, facades, and routes. |
| Eloquent Models | High | Auto-converts models to MCP tools with hasMany, belongsTo, etc. |
| API Routes | Medium | Requires MCP-specific route registration (not RESTful). |
| Authentication | High | Supports OAuth2 (RFC 7591) and session IDs. |
| Third-Party Clients | High | Works with MCP-compliant clients (e.g., Python, JavaScript libraries). |
| Existing APIs | Low | MCP is not backward-compatible with REST/gRPC; requires parallel routes. |
Key Dependencies:
| Risk Area | Severity | Mitigation |
|---|---|---|
| Protocol Complexity | Medium | MCP’s JSON-RPC + extensions may require learning curve for non-AI teams. |
| Performance Overhead | Low | Streaming and caching are optimized, but OAuth flows add latency. |
| Security Misconfigurations | High | OAuth misconfigurations (e.g., incorrect redirect URIs) can expose endpoints. |
| Tool Registration Errors | Medium | Debugging ModelNotFound exceptions requires MCP-specific error handling. |
| Client Compatibility | Medium | AI clients must support MCP spec 2025-06-18+; older clients may fail. |
| State Management | High | Sessions and MCP-Session-Id headers must be handled correctly. |
Critical Questions for TPM:
| Stack Component | Compatibility | Notes |
|---|---|---|
| Laravel Framework | Native | Designed for Laravel; uses ServiceProvider, Route::mcp(), etc. |
| Eloquent ORM | High | Auto-generates MCP tools from models with relationships. |
| Laravel Octane | High | Supports streaming under Octane (fixed in v0.5.6). |
| Laravel Sanctum/Passport | Medium | OAuth2 layer is built-in, but may conflict with existing auth systems. |
| Queue Workers | Medium | Async tool execution possible but not natively supported. |
| Frontend Frameworks | High (UI App) | MCP UI App supports interactive HTML resources (e.g., React/Vue). |
| Third-Party AI SDKs | High | Works with LangChain, AutoGen, or custom MCP clients. |
Non-Compatible Stacks:
Assessment Phase (2-4 weeks)
Proof of Concept (2-3 weeks)
laravel/mcp and expose 1-2 critical models as tools.Core Integration (4-6 weeks)
/api/mcp/tools).oauth-server package).UI/App Integration (3-4 weeks, if needed)
Optimization (Ongoing)
Route::mcp(); ensure no overlap with existing routes.withHeaders()).| Aspect | Effort | Notes |
|---|---|---|
| Package Updates | Low | MIT license; updates are frequent (monthly). |
| Tool Management | Medium | Adding/removing tools requires route registration and model annotations. |
| OAuth Maintenance | High | Client registration, token rotation, and redirect URI validation needed. |
| Error Handling | Medium | Custom exceptions (e.g., ModelNotFound) require MCP-aware logging. |
| Documentation | High | MCP is niche; internal docs for tool contracts (inputs/outputs) are critical. |
Maintenance Tasks:
How can I help you explore Laravel packages today?