An MCP server in a few lines of PHP.

Register a server, attach your tools, resources, and prompts, and let Laravel MCP handle the protocol plumbing.

  • Callable tools.

    Let AI clients trigger actions, query data, and run domain logic inside your app with typed input schemas.

  • Secure by default.

    Protect MCP endpoints with standard Laravel middleware, OAuth 2.1 via Passport, or Sanctum tokens.

  • Reusable prompts.

    Define parameterized prompt templates so AI clients interact with your app consistently.

  • Structured resources.

    Expose files, database records, and docs as readable resources with clean URIs and MIME types.

  • Dependency injection.

    Type-hint services in your tools and resources and let Laravel's service container resolve them automatically.

  • Inspector and test helpers.

    Debug servers interactively with the MCP Inspector and write fast unit tests for every tool and resource.

  • Real-time streaming.

    Stream progress updates and partial responses to AI clients over Server-Sent Events.

  • Web and local servers.

    Serve remote MCP endpoints over HTTP for web clients, or run local stdio servers for editors like Claude Code and Cursor.

Familiar Laravel, all the way down.

Define MCP servers in routes/ai.php, resolve dependencies from the container, and test everything in Pest or PHPUnit.

1<?php
2
3namespace App\Mcp\Servers;
4
5class Flightio extends Laravel\Mcp\Server
6{
7 public string $serverName = 'Flightio';
8 public string $serverVersion = '0.0.1';
9 public string $instructions = 'Use to help the user search, book, and manage flights.';
10
11 public array $tools = [
12 \App\Mcp\Tools\Search::class,
13 \App\Mcp\Tools\Book::class,
14 \App\Mcp\Tools\Reschedule::class,
15 \App\Mcp\Tools\Cancel::class,
16 ];
17
18 public array $resources = [
19 \App\Mcp\Resources\Itinerary::class,
20 ];
21
22 public array $prompts = [
23 \App\Mcp\Prompts\Inspiration::class,
24 ];
25}

Laravel MCP by the numbers.

1 week ago
v1.3.0
Contributors
69
GitHub Stars
885
Open PRs
10

Laravel MCP FAQ.

The agent stack.

Ship your first MCP server today.

Install the package with Composer and connect your Laravel app to Claude, ChatGPT, and local coding agents.