Laravel MCP
A Laravel package for implementing secure Model Context Protocol servers using Streamable HTTP and SSE transport, providing real-time communication and a scalable tool system for enterprise environments.
What is Laravel MCP?
Laravel MCP is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to laravel package for implementing secure model context protocol servers using streamable http and sse transport, providing real-time communication and a scalable tool system for enterprise environments...
A Laravel package for implementing secure Model Context Protocol servers using Streamable HTTP and SSE transport, providing real-time communication and a scalable tool system for enterprise environments.
This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- A Laravel package for implementing secure Model Context Prot
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx laravelConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Laravel MCP
The php-mcp/laravel package lets you build fully featured MCP servers inside a Laravel application, supporting Streamable HTTP, SSE, and STDIO transports. It provides auto-discovery of MCP tools, resources, resource templates, and prompts via PHP attributes, as well as a fluent Facade API for manual registration, making it the natural choice for PHP teams that want to expose Laravel application logic to AI assistants in enterprise environments.
Prerequisites
- PHP 8.1 or higher with Composer installed
- Laravel 10 or 11 application
- A database configured for Laravel migrations (used for optional session storage)
- An MCP client such as Claude Desktop or VS Code to test the server
Install the package via Composer
Add php-mcp/laravel to your application. The -W flag ensures all dependency constraints are resolved.
composer require php-mcp/laravel:^3.0 -WPublish the config and migrations
Publish the mcp.php configuration file and the session management migrations so you can customise transport, session storage, and logging.
php artisan vendor:publish --provider="PhpMcp\Laravel\McpServiceProvider" --tag="mcp-config"
php artisan vendor:publish --provider="PhpMcp\Laravel\McpServiceProvider" --tag="mcp-migrations"
php artisan migrateExclude MCP routes from CSRF protection
In Laravel 11 or later, add the mcp paths to your CSRF exclusion list inside bootstrap/app.php so HTTP transport requests are not rejected.
->withMiddleware(function (Middleware $middleware) {
$middleware->validateCsrfTokens(except: [
'mcp',
'mcp/*',
]);
})Register MCP tools and resources
Annotate your service methods with MCP attributes for auto-discovery, or use the Mcp Facade for manual registration. Auto-discovery is enabled by default via config/mcp.php.
use PhpMcp\Server\Attributes\McpTool;
class UserService
{
#[McpTool(name: 'create_user')]
public function createUser(string $email, string $password): array {
// your implementation
}
}Start the MCP server
Use the artisan command to start the server on your chosen transport. STDIO is used for most desktop MCP clients; HTTP is useful for remote or containerised deployments.
# STDIO transport (for desktop MCP clients)
php artisan mcp:serve --transport=stdio
# Dedicated HTTP server
php artisan mcp:serve --transport=http --host=0.0.0.0 --port=8090Discover and list registered elements
Run the discovery command to scan for attribute-annotated classes and verify everything is registered correctly before connecting a client.
php artisan mcp:discover
php artisan mcp:list toolsLaravel MCP Examples
Client configuration
Add this entry to claude_desktop_config.json for a Laravel app running the STDIO transport. Adjust the path to your artisan file.
{
"mcpServers": {
"laravel-mcp": {
"command": "php",
"args": ["/path/to/your/laravel-app/artisan", "mcp:serve", "--transport=stdio"]
}
}
}Prompts to try
After connecting your MCP client to a Laravel app with tools registered, try these prompts.
- "List all available MCP tools registered in this Laravel app."
- "Call the create_user tool to add a new account with email [email protected]."
- "Fetch the config://app/settings resource and summarise the application configuration."
- "Use the welcome_user prompt to generate a greeting for a new subscriber named Alice."Troubleshooting Laravel MCP
CSRF token mismatch errors when using HTTP transport
Ensure that 'mcp' and 'mcp/*' are added to the CSRF exception list in bootstrap/app.php (Laravel 11+) or in the VerifyCsrfToken middleware's $except array (Laravel 10).
Tools or resources are not discovered automatically
Run 'php artisan mcp:discover' to trigger the discovery scan, then 'php artisan mcp:list tools' to verify. Make sure auto-discovery is enabled in config/mcp.php and that your classes are in a scanned namespace.
Session not persisting between requests on HTTP transport
Check the session driver setting in config/mcp.php. For production, switch to 'redis' or 'database' instead of 'file' and ensure the corresponding service is running.
Frequently Asked Questions about Laravel MCP
What is Laravel MCP?
Laravel MCP is a Model Context Protocol (MCP) server that laravel package for implementing secure model context protocol servers using streamable http and sse transport, providing real-time communication and a scalable tool system for enterprise environments. It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Laravel MCP?
Follow the installation instructions on the Laravel MCP GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with Laravel MCP?
Laravel MCP works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Laravel MCP free to use?
Yes, Laravel MCP is open source and available under the MIT license. You can use it freely in both personal and commercial projects.
Laravel MCP Alternatives — Similar Developer Tools Servers
Looking for alternatives to Laravel MCP? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
★ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
★ 155.8kJava 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发
Gemini CLI
★ 104.5kA secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
Awesome MCP Servers
★ 87.3k⭐ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
★ 86.0kModel Context Protocol Servers
CC Switch
★ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
Browse More Developer Tools MCP Servers
Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Laravel MCP in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Laravel MCP?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.