laravel

by @php-mcp

Laravel MCP Server

Expose Laravel services, Eloquent models, and domain actions as MCP Tools, Resources, Templates, and Prompts via `php-mcp/laravel` (PHP 8.1+, Laravel 10.0+). It pairs PHP 8 attribute discovery and fluent `Mcp` routes with `stdio`, integrated HTTP, and a dedicated ReactPHP Streamable HTTP server.

Server facts

laravel MCP Server

GitHub stars

478

Last commit

Mar 29, 2026

Runtime

php

License

MIT

Project

Author
php-mcp
License
MIT

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`)
Documented launch / install command
composer require php-mcp/laravel:^3.0 -W

Install 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`.

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.

Claude Desktop configuration
{
  "mcpServers": {
    "my-laravel-app": {
      "command": "php",
      "args": [
        "/absolute/path/to/your/laravel/project/artisan",
        "mcp:serve",
        "--transport=stdio"
      ]
    }
  }
}

Read the Claude Desktop setup guide

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.

Cursor configuration
{
  "mcpServers": {
    "my-laravel-app": {
      "command": "php",
      "args": [
        "/absolute/path/to/your/laravel/project/artisan",
        "mcp:serve",
        "--transport=stdio"
      ]
    }
  }
}

Read the Cursor setup guide

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.

VS Code configuration
{
  "servers": {
    "my-laravel-app": {
      "type": "stdio",
      "command": "php",
      "args": [
        "/absolute/path/to/your/laravel/project/artisan",
        "mcp:serve",
        "--transport=stdio"
      ]
    }
  }
}

Read the VS Code setup guide

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.

Windsurf configuration
{
  "mcpServers": {
    "my-laravel-app": {
      "command": "php",
      "args": [
        "/absolute/path/to/your/laravel/project/artisan",
        "mcp:serve",
        "--transport=stdio"
      ]
    }
  }
}

Read the Windsurf setup guide

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.

Claude Code configuration
{
  "mcpServers": {
    "my-laravel-app": {
      "type": "stdio",
      "command": "php",
      "args": [
        "/absolute/path/to/your/laravel/project/artisan",
        "mcp:serve",
        "--transport=stdio"
      ]
    }
  }
}

Read the Claude Code setup guide

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.

Frequently asked questions

Install the package via `composer require php-mcp/laravel:^3.0 -W` in any Laravel >= 10.0 app (PHP >= 8.1), publish `config/mcp.php`, and define tools using `Mcp::tool(...)` or `#[McpTool]`. In Cursor's `mcpServers` JSON, set `command` to `php` with `args` pointing to your project's absolute `artisan` path, `mcp:serve`, and `--transport=stdio`.

Related MCP servers