Back to Catalog
mcp-server4

Laravel MCP

Official Laravel package for rapidly building Model Context Protocol (MCP) servers, enabling seamless AI client interactions with Laravel applications through tools, resources, and prompts.

Overview

Laravel MCP is the official package developed by the Laravel team to enable developers to build Model Context Protocol (MCP) servers directly within Laravel applications. Launched in 2025 as part of Laravel's AI tooling suite, it provides a fluent, Laravel-native interface for defining servers, tools, resources, and prompts that allow any MCP-compatible AI client (Claude, ChatGPT, Cursor, GitHub Copilot, etc.) to interact securely and efficiently with your Laravel app.

By integrating Laravel MCP, applications gain the ability to expose structured capabilities to AI agents without custom APIs, following the open MCP standard originally introduced by Anthropic and now governed under the Linux Foundation.

Key Features

  • Expressive Server Definition: Use attributes and fluent APIs to configure server metadata (name, version, instructions).
  • Tools, Resources & Prompts: Register custom classes for executable tools, readable resources, and reusable prompt templates.
  • Artisan Scaffolding: Generate full MCP server skeletons with php artisan make:mcp-server.
  • Laravel-Native Integration: Leverages Eloquent, caching, queues, Sanctum authentication, and the service container.
  • Streamable HTTP & SSE Support: Built on modern MCP transports for real-time, scalable interactions.
  • Security & Authentication: Easy integration with Laravel Sanctum or Passport for token-based auth.
  • Testing Support: Works seamlessly with Pest/PHPUnit for testing tools and server behavior.

Installation & Quick Start

Install via Composer:

composer require laravel/mcp

Publish routes and configuration (optional):

php artisan vendor:publish --tag=mcp-config
php artisan vendor:publish --tag=mcp-routes

Create your first server:

php artisan make:mcp-server WeatherServer

Example server class:

<?php

namespace App\Mcp\Servers;

use Laravel\Mcp\Server;
use Laravel\Mcp\Server\Attributes\Name;
use Laravel\Mcp\Server\Attributes\Version;
use Laravel\Mcp\Server\Attributes\Instructions;

#[Name('Weather Server')]
#[Version('1.0.0')]
#[Instructions('Provides current weather and forecasts for locations worldwide.')]
class WeatherServer extends Server
{
    protected array $tools = [
        \App\Mcp\Tools\GetCurrentWeather::class,
    ];

    protected array $resources = [
        \App\Mcp\Resources\WeatherGuidelines::class,
    ];
}

Use Cases

  • AI-Powered Development Tools: Expose Laravel-specific context (routes, models, migrations) to coding agents like Claude Code or Cursor.
  • Business Application Integration: Allow AI assistants to query CRM data, manage tasks, or interact with e-commerce features.
  • Local & Remote Servers: Run MCP servers locally for development or deploy remotely for production AI integrations.
  • Multi-Client Compatibility: One server works across all major AI platforms supporting MCP (Anthropic, OpenAI, Google, Microsoft).

Community benchmarks show that Laravel MCP reduces integration time for AI features by 5–8× compared to custom endpoints, with zero vendor lock-in thanks to the open protocol.

Advanced Tips & Common Pitfalls

  • Use Sanctum middleware for production servers to secure tool execution.
  • Implement rate limiting on tool calls to prevent abuse.
  • Leverage resource templates for dynamic data exposure (e.g., Eloquent query results).
  • Pitfall: Forgetting to register routes — always run php artisan route:cache after changes.
  • Advanced: Combine with Laravel Boost (another first-party MCP server) for enhanced local dev experience.

Conclusion & Resources

Laravel MCP represents Laravel's official commitment to the emerging AI agent ecosystem. As MCP adoption grows in 2026, having an MCP server in your Laravel app positions it as AI-native infrastructure.

Start building today:

  • Official Docs: https://laravel.com/docs/12.x/mcp
  • GitHub: https://github.com/laravel/mcp
  • Explore demo app Locket: https://github.com/laravel/locket

Contribute to the package or build your first MCP server — the future of AI-assisted Laravel development is here.

Tags

laravelmcpaiphpservermodel-context-protocoltoolsresourcesprompts