Laravel MCP

v1.0.0Developer Toolsstable

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.

ailaravellaravel-packagellmmcp
Share:
472
Stars
0
Downloads
0
Weekly
0/5

What is Laravel MCP?

Laravel MCP is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to 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...

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.

This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • A Laravel package for implementing secure Model Context Prot

Use Cases

PHP MCP server implementation
Streamable HTTP and SSE transport
Enterprise MCP integration
php-mcp

Maintainer

LicenseMIT
Languagephp
Versionv1.0.0
UpdatedMay 8, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx laravel

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use Laravel MCP

The php-mcp/laravel package lets you build fully featured MCP servers inside a Laravel application, supporting Streamable HTTP, SSE, and STDIO transports. It provides auto-discovery of MCP tools, resources, resource templates, and prompts via PHP attributes, as well as a fluent Facade API for manual registration, making it the natural choice for PHP teams that want to expose Laravel application logic to AI assistants in enterprise environments.

Prerequisites

  • PHP 8.1 or higher with Composer installed
  • Laravel 10 or 11 application
  • A database configured for Laravel migrations (used for optional session storage)
  • An MCP client such as Claude Desktop or VS Code to test the server
1

Install the package via Composer

Add php-mcp/laravel to your application. The -W flag ensures all dependency constraints are resolved.

composer require php-mcp/laravel:^3.0 -W
2

Publish the config and migrations

Publish the mcp.php configuration file and the session management migrations so you can customise transport, session storage, and logging.

php artisan vendor:publish --provider="PhpMcp\Laravel\McpServiceProvider" --tag="mcp-config"
php artisan vendor:publish --provider="PhpMcp\Laravel\McpServiceProvider" --tag="mcp-migrations"
php artisan migrate
3

Exclude MCP routes from CSRF protection

In Laravel 11 or later, add the mcp paths to your CSRF exclusion list inside bootstrap/app.php so HTTP transport requests are not rejected.

->withMiddleware(function (Middleware $middleware) {
    $middleware->validateCsrfTokens(except: [
        'mcp',
        'mcp/*',
    ]);
})
4

Register MCP tools and resources

Annotate your service methods with MCP attributes for auto-discovery, or use the Mcp Facade for manual registration. Auto-discovery is enabled by default via config/mcp.php.

use PhpMcp\Server\Attributes\McpTool;

class UserService
{
    #[McpTool(name: 'create_user')]
    public function createUser(string $email, string $password): array {
        // your implementation
    }
}
5

Start the MCP server

Use the artisan command to start the server on your chosen transport. STDIO is used for most desktop MCP clients; HTTP is useful for remote or containerised deployments.

# STDIO transport (for desktop MCP clients)
php artisan mcp:serve --transport=stdio

# Dedicated HTTP server
php artisan mcp:serve --transport=http --host=0.0.0.0 --port=8090
6

Discover and list registered elements

Run the discovery command to scan for attribute-annotated classes and verify everything is registered correctly before connecting a client.

php artisan mcp:discover
php artisan mcp:list tools

Laravel MCP Examples

Client configuration

Add this entry to claude_desktop_config.json for a Laravel app running the STDIO transport. Adjust the path to your artisan file.

{
  "mcpServers": {
    "laravel-mcp": {
      "command": "php",
      "args": ["/path/to/your/laravel-app/artisan", "mcp:serve", "--transport=stdio"]
    }
  }
}

Prompts to try

After connecting your MCP client to a Laravel app with tools registered, try these prompts.

- "List all available MCP tools registered in this Laravel app."
- "Call the create_user tool to add a new account with email [email protected]."
- "Fetch the config://app/settings resource and summarise the application configuration."
- "Use the welcome_user prompt to generate a greeting for a new subscriber named Alice."

Troubleshooting Laravel MCP

CSRF token mismatch errors when using HTTP transport

Ensure that 'mcp' and 'mcp/*' are added to the CSRF exception list in bootstrap/app.php (Laravel 11+) or in the VerifyCsrfToken middleware's $except array (Laravel 10).

Tools or resources are not discovered automatically

Run 'php artisan mcp:discover' to trigger the discovery scan, then 'php artisan mcp:list tools' to verify. Make sure auto-discovery is enabled in config/mcp.php and that your classes are in a scanned namespace.

Session not persisting between requests on HTTP transport

Check the session driver setting in config/mcp.php. For production, switch to 'redis' or 'database' instead of 'file' and ensure the corresponding service is running.

Frequently Asked Questions about Laravel MCP

What is Laravel MCP?

Laravel MCP is a Model Context Protocol (MCP) server that 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. It connects AI assistants to external tools and data sources through a standardized interface.

How do I install Laravel MCP?

Follow the installation instructions on the Laravel MCP GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with Laravel MCP?

Laravel MCP works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is Laravel MCP free to use?

Yes, Laravel MCP is open source and available under the MIT license. You can use it freely in both personal and commercial projects.

Browse More Developer Tools MCP Servers

Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "laravel": { "command": "npx", "args": ["-y", "laravel"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use Laravel MCP?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides