Server facts
laravel MCP Server
GitHub stars
478
Last commit
Mar 29, 2026
Runtime
php
License
MIT
Project
- Author
- php-mcp
- Repository
- github.com/php-mcp/laravel
- License
- MIT
- Category
- AI Models & Agents
Tech
- Runtime
- php
- Transports
- stdiostreamable-httpsse
- Remote access
- No
- Authentication
- Laravel middleware/CSRF config for HTTP; none for local stdio
Activity
- GitHub stars
- 478
- Last commit
- Data as of
Overview
PHP teams searching for a `laravel mcp` package can turn any Laravel 10.0+ codebase (PHP >= 8.1) into a compliant 2025-03-26 Model Context Protocol server with `php-mcp/laravel` v3.x, an MIT-licensed SDK wrapping `php-mcp/server`. Install via `composer require php-mcp/laravel:^3.0 -W` and publish `config/mcp.php` (plus optional session migrations) through Artisan. Developers define Tools, Resources, Resource Templates, and Prompts either manually with the fluent `Mcp` facade in `routes/mcp.php`—supporting class methods, invokable classes, and closures (v3.1+/v3.2+) with custom `inputSchema`—or automatically using PHP 8 attributes (`#[McpTool]`, `#[McpResource]`, `#[McpResourceTemplate]`, `#[McpPrompt]`, `#[Schema]`, and `#[CompletionProvider]`) cached via `php artisan mcp:discover` and inspected with `php artisan mcp:list`.
Handlers resolve dependencies straight from Laravel's service container, translate PHP exceptions into JSON-RPC errors, dispatch live client update events (`ToolsListChanged`, `ResourceUpdated`), and persist sessions in file, database, cache, or Redis stores. For local Cursor, Claude, or CLI workflows, run `php artisan mcp:serve --transport=stdio` (avoiding `STDOUT` writes in handlers). For remote clients, choose integrated Laravel HTTP routes (`GET/POST/DELETE /mcp`, adding `mcp` to CSRF exclusions and serving via Laravel Herd, Nginx+PHP-FPM, or Octane rather than `php artisan serve`) or launch the recommended standalone ReactPHP Streamable HTTP server (`php artisan mcp:serve --transport=http`, default `127.0.0.1:8090`) managed by Supervisor, systemd, or Docker.
Install & configure
Requirements
- PHP >= 8.1 with `json`, `mbstring`, and `pcre` extensions
- Laravel >= 10.0 application with Composer (`composer require php-mcp/laravel:^3.0 -W`)
- Laravel Herd, Nginx+PHP-FPM, Octane, or Supervisor/Docker when deploying HTTP/Streamable transports (not `php artisan serve`)
composer require php-mcp/laravel:^3.0 -WInstall with `composer require php-mcp/laravel:^3.0 -W`, publish config with `php artisan vendor:publish --provider="PhpMcp\Laravel\McpServiceProvider" --tag="mcp-config"`, register elements via `routes/mcp.php` or PHP 8 attributes, and serve with `php artisan mcp:serve --transport=stdio` or `--transport=http`.
Examples are translated from the published configuration. Supply your own credentials and verify requirements in the upstream README. Remote connectors are shown only where a supported configuration format is known.
Config file · macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Use Settings → Developer → Edit Config when available. Do not assume a Linux configuration path; check the client documentation for your platform. Remote servers use the app’s connector flow when supported, not the local stdio file shown here. Merge this example with existing settings; do not overwrite unrelated servers.
{
"mcpServers": {
"my-laravel-app": {
"command": "php",
"args": [
"/absolute/path/to/your/laravel/project/artisan",
"mcp:serve",
"--transport=stdio"
]
}
}
}Config file · Project: .cursor/mcp.json
User: ~/.cursor/mcp.json
The project path is relative to the workspace root. The tilde denotes your user home directory. Use Cursor’s MCP settings to confirm which configuration and scope your installed version is reading. Merge this example with existing settings; do not overwrite unrelated servers.
{
"mcpServers": {
"my-laravel-app": {
"command": "php",
"args": [
"/absolute/path/to/your/laravel/project/artisan",
"mcp:serve",
"--transport=stdio"
]
}
}
}Config file · Workspace: .vscode/mcp.json
For user scope, use the “MCP: Open User Configuration” command if available. Do not guess a user configuration path across operating systems, profiles, containers, or remote workspaces; check the client documentation. Merge this example with existing settings; do not overwrite unrelated servers.
{
"servers": {
"my-laravel-app": {
"type": "stdio",
"command": "php",
"args": [
"/absolute/path/to/your/laravel/project/artisan",
"mcp:serve",
"--transport=stdio"
]
}
}
}Config file · macOS/Linux: ~/.codeium/windsurf/mcp_config.json
Windows: %USERPROFILE%\.codeium\windsurf\mcp_config.json
Open the MCP configuration through Windsurf’s settings when possible to confirm the active file. Paths can differ in managed or future releases; check the client documentation if this location is not present. Merge this example with existing settings; do not overwrite unrelated servers.
{
"mcpServers": {
"my-laravel-app": {
"command": "php",
"args": [
"/absolute/path/to/your/laravel/project/artisan",
"mcp:serve",
"--transport=stdio"
]
}
}
}Config file · Project scope: .mcp.json at the repository root
The project file uses mcpServers. For user scope, use claude mcp add --scope user rather than assuming .mcp.json in your home directory is the user configuration. Check the client documentation for managed settings and storage details. Merge this example with existing settings; do not overwrite unrelated servers.
{
"mcpServers": {
"my-laravel-app": {
"type": "stdio",
"command": "php",
"args": [
"/absolute/path/to/your/laravel/project/artisan",
"mcp:serve",
"--transport=stdio"
]
}
}
}Examples are translated from the published configuration. Supply your own credentials and verify requirements in the upstream README. Remote connectors are shown only where a supported configuration format is known.
Use cases
- Expose Eloquent queries, order processing, and product search from an existing Laravel e-commerce backend as typed MCP tools for Claude or Cursor.
- Serve dynamic Markdown posts, app settings, and user profiles via `#[McpResourceTemplate]` URIs with Eloquent-backed `#[CompletionProvider]` autocomplete.
- Run a high-concurrency ReactPHP Streamable HTTP MCP server under Supervisor or Docker with Redis or database session persistence.
- Connect Cursor IDE locally to your Laravel codebase over `stdio` by pointing `mcpServers` at `php /path/to/artisan mcp:serve --transport=stdio`.
Strengths
- First-class Laravel integration covering service-container dependency injection, Artisan discovery/list/serve commands, daily log channels, events, and Redis/database/cache/file sessions.
- Flexible authoring supports both fluent `Mcp` facade registrations in `routes/mcp.php` (including closures) and auto-discovered PHP 8 attributes with `#[Schema]` validation.
- Supports `stdio`, integrated Laravel HTTP routes, and a dedicated ReactPHP Streamable HTTP server with resumability, event store, and optional JSON response mode.
- Implements the 2025-03-26 MCP specification with automatic JSON schema inference from PHP type hints and docblocks.
Limitations
- It is a developer SDK rather than a prebuilt turnkey server—you must author and register the MCP tools and resources for your own Laravel app.
- PHP's built-in `php artisan serve` cannot run persistent SSE streams because a single request locks the server process; use Herd, Nginx+PHP-FPM, Octane, or the dedicated HTTP server.
- Integrated HTTP routes require adding `mcp` (or `mcp/*` for legacy SSE) to Laravel's CSRF middleware exclusions, and `stdio` handlers must never print to `STDOUT`.
laravel setup notes
- laravel's example uses stdio, while its catalog transports are stdio / streamable-http / sse; use the example's connection type.