Get the FREE Ultimate OpenClaw Setup Guide →

laravel -sdk

Laravel Based Implementation for Model Context Protocol

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio mohamedahmed01-laravel-mcp-sdk php artisan mcp:serve \
  --env MCP_SERVER_HOST="127.0.0.1" \
  --env MCP_SERVER_PORT="8080" \
  --env MCP_SERVER_TRANSPORT="http"

How to use

This MCP server is a Laravel package that implements the Model Context Protocol (MCP) for Laravel applications. It provides a flexible server capable of handling Tool registration and execution, Resource management, Prompt handling, Progress tracking, and a robust Logging system, all exposed via HTTP, WebSocket, or Stdio transports depending on how you configure the server. The package exposes a rich PHPDoc-documented API and example usage within the README, guiding you through creating and configuring MCPServer instances, registering tools, managing resources, and selecting transports. To run the server locally, install the package with Composer, publish and tailor configuration, then start the server using Laravel’s artisan command. Tools can be registered to perform operations, resources can be exposed for dynamic access, and the prompt system can be configured to manage context and message history for model interactions.

How to install

Prerequisites:

  • PHP 8.1 or higher
  • Laravel 10.x
  • Composer 2.x
  • OpenSSL, PDO, Mbstring, XML, Ctype, JSON PHP extensions
  • ReactPHP (for HTTP/WebSocket transport)
  • Optional: Redis (WebSocket scaling), Supervisor, ext-pcntl, ext-posix

Step-by-step:

  1. Create a Laravel project or use your existing one.
  2. Install the MCP package: composer require laravelmcp/mcp
  3. Publish the configuration (if needed): php artisan vendor:publish --provider="LaravelMCP\MCP\MCPServiceProvider" --tag="config"
  4. Configure environment variables in your .env file: MCP_SERVER_HOST=127.0.0.1 MCP_SERVER_PORT=8080 MCP_SERVER_TRANSPORT=http
  5. Start the MCP server: php artisan mcp:serve
  6. (Optional) If you want WebSocket or other transports, install and configure the necessary dependencies (Redis for scaling, Supervisor for process management, etc.).

You can now interact with the MCP endpoints, register tools, manage resources, and handle prompts via the configured transports.

Additional notes

Tips and notes:

  • The server supports multiple transports; choose http for REST, websocket for real-time interactions, or stdio for CLI-based tooling.
  • Ensure required PHP extensions are enabled, and that your Laravel app has appropriate permissions for sockets and network binding.
  • For scaling WebSocket transport, consider Redis and Supervisor in your environment.
  • The README emphasizes comprehensive PHPDoc documentation in src/; leverage your IDE’s PHPDoc integration for discovery.
  • If you encounter port conflicts, adjust MCP_SERVER_PORT in your .env and restart the server.
  • When registering tools, validate inputs and implement proper error handling to provide meaningful MCP responses.

Related MCP Servers

Sponsor this space

Reach thousands of developers