Get the FREE Ultimate OpenClaw Setup Guide →

laravel

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.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio opgginc-laravel-mcp-server php artisan serve --host=0.0.0.0 --port=8000 \
  --env APP_ENV="production" \
  --env APP_KEY="base64:GENERATE_YOUR_APP_KEY" \
  --env DB_HOST="127.0.0.1" \
  --env DB_PORT="3306" \
  --env DB_DATABASE="laravel_mcp" \
  --env DB_PASSWORD="your_db_password" \
  --env DB_USERNAME="your_db_user" \
  --env DB_CONNECTION="mysql"

How to use

The Laravel MCP Server provides a route-first MCP endpoint registration for Laravel and Lumen projects. Once installed, you define MCP endpoints using the Route::mcp(...) API and attach server metadata, configured tools, resources, templates, prompts, and other MCP components to each route. The server communicates over a streamable HTTP transport and performs all MCP interactions through registered tool classes, enabling clients to discover tools, execute them, and fetch results via JSON-RPC on the defined /mcp route. To start serving, run the local Laravel application (for example with php artisan serve or your preferred web server) and ensure the mcp endpoint is reachable at the configured host/port. Tools like HelloWorldTool or VersionCheckTool can be registered per endpoint and expose their input/output schemas via the MCP tool interface.

How to install

Prerequisites:

  • PHP >= 8.2
  • Composer
  • Laravel/Lumen project setup

Installation steps:

  1. Install the MCP server package via Composer: composer require opgginc/laravel-mcp-server

  2. Publish/configure MCP routes (examples provided in the README):

    • For Laravel, add Route::mcp(...) definitions to your routes file and register the server info, config, protocol version, and tools.
  3. Configure environment for the server (database or other dependencies as needed):

    • Ensure your .env contains proper APP_KEY, database credentials, and any required caches/queues.
  4. Start the Laravel application:

    • php artisan serve --host=0.0.0.0 --port=8000
  5. Verify the MCP route is accessible and tools are registered by listing routes and invoking tool lists (as shown in the README examples).

Additional notes

Tips and common considerations:

  • The server uses route-driven MCP registration; ensure your Laravel routes are properly registered with Route::mcp(...).
  • For production, enable security measures (auth middleware, rate limiting) around the MCP route group as suggested in the Minimal Security section of the README.
  • The MCP configuration shown uses artisan serve for local development. In production, wire the Laravel app behind a web server (Nginx/Apache) or use a process manager to keep the PHP-FPM session running.
  • If you migrate between environments, remember to adjust APP_ENV and database connection settings accordingly.
  • OpenAPI/Swagger generation features rely on the registered Tool classes; ensure tools implement inputSchema() and are properly registered on the endpoint.

Related MCP Servers

Sponsor this space

Reach thousands of developers