laravel -sdk
Laravel Based Implementation for Model Context Protocol
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:
- Create a Laravel project or use your existing one.
- Install the MCP package: composer require laravelmcp/mcp
- Publish the configuration (if needed): php artisan vendor:publish --provider="LaravelMCP\MCP\MCPServiceProvider" --tag="config"
- Configure environment variables in your .env file: MCP_SERVER_HOST=127.0.0.1 MCP_SERVER_PORT=8080 MCP_SERVER_TRANSPORT=http
- Start the MCP server: php artisan mcp:serve
- (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
drift
Codebase intelligence for AI. Detects patterns & conventions + remembers decisions across sessions. MCP server for any IDE. Offline CLI.
hypertool
Dynamically expose tools from proxied servers based on an Agent Persona
Gitingest
mcp server for gitingest
laravel-loop
Laravel Loop is a powerful Model Context Protocol (MCP) server designed specifically for Laravel applications. It connects your Laravel application with AI assistants using the MCP protocol.
awesome s
A curated list of excellent Model Context Protocol (MCP) servers.
silverstripe
MCP server that provides real-time validation feedback when AI assistants generate Silverstripe 6 PHP code. Catches common migration issues from Silverstripe 5 to 6 before they reach your codebase.