- Home
- MCP servers
- Laravel MCP SDK Server
Laravel MCP SDK Server
- php
28
GitHub Stars
php
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"mohamedahmed01-laravel-mcp-sdk": {
"command": "php",
"args": [
"artisan",
"mcp:serve",
"--transport=stdio"
],
"env": {
"MCP_SERVER_HOST": "127.0.0.1",
"MCP_SERVER_PORT": "8080",
"MCP_SERVER_TRANSPORT": "http"
}
}
}
}You can run a Laravel-based MCP server that lets AI models interact with your Laravel app through standardized tools, resources, prompts, and real-time or HTTP-based transports. This server enables tool execution, resource access, prompt handling, progress tracking, and structured logging, making it easy to integrate AI capabilities into your Laravel applications.
How to use
You run the MCP server locally using PHP, then connect your MCP client to the running server through the chosen transport. Start by launching the server with the default HTTP transport, or opt into WebSocket or stdio transports for real-time or CLI-driven workflows. Use the server to register tools, manage resources, define prompts, monitor progress, and review logs as you build AI-assisted features into your Laravel application.
How to install
Prerequisites: PHP 8.1 or higher, Laravel 10.x, Composer 2.x, and the necessary PHP extensions (OpenSSL, PDO, Mbstring, XML, Ctype, JSON). You should also have Composer available to install the package.
composer require laravelmcp/mcp
Configuration and startup
Publish the MCP configuration and adjust environment variables to fit your environment. The essential environment variables include the host, port, and transport you plan to use.
MCP_SERVER_HOST=127.0.0.1
MCP_SERVER_PORT=8080
MCP_SERVER_TRANSPORT=http
Starting the server with different transports
Start the server with the default HTTP transport, or specify a transport and binding when starting.
php artisan mcp:serve
To run with WebSocket transport, bind to a host and port you choose.
php artisan mcp:serve --transport=websocket --host=0.0.0.0 --port=8081
For CLI applications that prefer stdio transport, run this command.
php artisan mcp:serve --transport=stdio
Available tools
calculate
Register a tool that performs a calculation based on input numbers and an operation. Returns a structured result or an error.
process-data
Process a list of items with optional token tracking, emitting progress updates and logs during processing.
analyze-complexity
Analyze code complexity for a given language and code snippet, returning metrics like cyclomatic and cognitive complexity.
suggest-improvements
Generate improvement suggestions for given code, language, and optional context through a dedicated prompt template.
review-code
Run a full code review workflow, analyze complexity, generate structured improvements, and save a history of results.