Laravel MCP
About
Laravel Based Implementation for Model Context Protocol
Details
- Author
- mohamedahmed01
- GitHub stars
- 29
- Downloads
- 440
- Categories
- Developer Tools
Jump to
- Multiple transport options: HTTP, WebSocket, and Stdio
- Tool registration, execution, and error handling
- Resource management with URI-based access and templates
- Prompt system with templates, arguments, and context management
- Real-time progress tracking and client notification
- Structured logging with multiple log levels
- Model preferences configuration (cost, intelligence, speed priorities)
Install via Composer (composer require laravelmcp/mcp), publish the config (php artisan vendor:publish --provider="..." --tag="config"), and set environment variables (e.g., MCP_SERVER_TRANSPORT). Start the server with php artisan mcp:serve [--transport] [--host] [--port]. Register tools, resources, and prompts using FastMCP or the MCP facade.
Laravel MCP
A Laravel package for implementing the Model Context Protocol (MCP) in Laravel applications. This protocol facilitates communication between AI models and Laravel applications through standardized interfaces.
:star: We are now Featured on mcphub
Requirements
System Requirements
- PHP 8.1 or higher - Laravel 10.x - Composer 2.x - OpenSSL PHP Extension - PDO PHP Extension - Mbstring PHP Extension - XML PHP Extension - Ctype PHP Extension - JSON PHP Extension - ReactPHP (for HTTP/WebSocket transport) - ext-json (for JSON handling)Optional Requirements
- Redis (for WebSocket scaling) - Supervisor (for process management) - ext-pcntl (for signal handling) - ext-posix (for process management)Features
- Multiple Transport Options
- HTTP Transport (RESTful API)
- WebSocket Transport (Real-time)
- Stdio Transport (Command-line)
- Configurable host and port settings
- Server Capabilities
- Tool registration and execution
- Resource management
- Prompt handling
- Progress tracking
- Logging system
- Model preferences configuration
- Tool System
- Register custom tools with parameters
- Handle tool calls with arguments
- Return structured responses
- Error handling and validation
- Resource Management
- URI-based resource access
- Resource templates
- Dynamic resource handling
- Content type support
- Prompt System
- Template-based prompts
- Dynamic argument handling
- Context management
- Message history support
- Progress Tracking
- Real-time progress updates
- Token-based tracking
- Total progress support
- Client notification system
- Logging System
- Multiple log levels
- Logger identification
- Structured logging
- Transport-agnostic logging
Documentation
The project includes comprehensive PHPDoc documentation for all classes and methods. The documentation is available directly in the source code and covers:
Core Components
- Server Capabilities (src/Capabilities/ServerCapabilities.php)
- Server feature management
- Experimental features configuration
- Logging configuration
- Component capabilities (prompts, resources, tools)
- Client Capabilities (src/Capabilities/ClientCapabilities.php)
- Feature flag management
- Root directory configuration
- State serialization/deserialization
Component Capabilities
- Tools Capability (src/Capabilities/ToolsCapability.php)
- Tool list change tracking
- State management
- Change notification support
- Resources Capability (src/Capabilities/ResourcesCapability.php)
- Resource subscription management
- Change tracking
- State serialization
- Prompts Capability (src/Capabilities/PromptsCapability.php)
- Prompt list change tracking
- State management
- Change notifications
- Roots Capability (src/Capabilities/RootsCapability.php)
- Root directory management
- Directory configuration
- Access control settings
Server Management
- MCP Server Command (src/Commands/MCPServerCommand.php)
- Server startup configuration
- Transport selection
- Signal handling
- Graceful shutdown
Each component includes:
- Detailed class descriptions
- Feature lists and capabilities
- Configuration examples
- Usage examples
- Method documentation
- Parameter descriptions
- Return value documentation
To explore the documentation:
1. Browse the source files in the src/ directory
2. Use your IDE's PHPDoc integration
3. Generate HTML documentation using phpDocumentor (optional)
To generate HTML documentation:
composer require --dev phpdocumentor/phpdocumentor
vendor/bin/phpdoc -d src/ -t docs/
Installation
Install via Composer:
composer require laravelmcp/mcp
The package will automatically register its service provider and facade.
Configuration
1. Publish the configuration:
php artisan vendor:publish --provider="LaravelMCP\MCP\MCPServiceProvider" --tag="config"
2. Configure environment variables:
MCP_SERVER_HOST=127.0.0.1
MCP_SERVER_PORT=8080
MCP_SERVER_TRANSPORT=http
Basic Usage
Starting the Server
```bash
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





