PHPackages                             elliottlawson/mcp-laravel-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. elliottlawson/mcp-laravel-sdk

ActiveLibrary[Framework](/categories/framework)

elliottlawson/mcp-laravel-sdk
=============================

Laravel-native implementation of the Model Context Protocol (MCP)

v0.4.0(1y ago)433MITPHPPHP ^8.2CI passing

Since Mar 22Pushed 1y ago2 watchersCompare

[ Source](https://github.com/elliottlawson/mcp-laravel-sdk)[ Packagist](https://packagist.org/packages/elliottlawson/mcp-laravel-sdk)[ RSS](/packages/elliottlawson-mcp-laravel-sdk/feed)WikiDiscussions main Synced today

READMEChangelog (7)Dependencies (8)Versions (14)Used By (0)

Laravel MCP Server
==================

[](#laravel-mcp-server)

A Laravel-native implementation of the Model Context Protocol (MCP) Server, allowing seamless integration of MCP capabilities into Laravel applications. Compatible with Laravel 10.x, 11.x, and 12.x, with optimizations for the latest Laravel versions.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require elliottlawson/mcp-laravel-sdk
```

The service provider will be automatically registered through Laravel's package discovery.

Configuration
-------------

[](#configuration)

### Laravel 10 and 11

[](#laravel-10-and-11)

For Laravel 10 and 11, publish the configuration file using:

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

This will create a `config/mcp.php` file that you can customize.

### Laravel 12

[](#laravel-12)

For Laravel 12, the configuration should be placed in the `bootstrap/mcp.php` file, following Laravel 12's new configuration approach. Create this file manually or publish it using:

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

Features
--------

[](#features)

- Full Laravel-native implementation with no external JSON-RPC dependencies
- Proper SSE implementation that works with Laravel's response lifecycle
- Direct integration with Laravel's Eloquent models
- Simple registration API for resources, tools, and prompts
- JSON-RPC 2.0 compliant API
- Support for batch requests
- Comprehensive error handling

Basic Usage
-----------

[](#basic-usage)

### Registering Resources, Tools, and Prompts

[](#registering-resources-tools-and-prompts)

You can register resources, tools, and prompts in your service provider or directly in your application code:

```
use ElliottLawson\LaravelMcp\Facades\Mcp;
use App\Models\User;
use ElliottLawson\LaravelMcp\Tools\CommandTool;
use ElliottLawson\LaravelMcp\Prompts\FilePrompt;

// Register a resource from an Eloquent model
Mcp::resource('users', User::class);

// Register a tool with a schema and handler
Mcp::tool('echo', [
    'type' => 'object',
    'properties' => [
        'message' => [
            'type' => 'string',
            'description' => 'The message to echo'
        ]
    ]
], new CommandTool('echo', [
    'command' => 'echo',
    'args' => ['message']
]));

// Register a prompt
Mcp::prompt('system', 'You are a helpful assistant integrated with Laravel.');
// Or from a file
Mcp::prompt('system', new FilePrompt('system', storage_path('prompts/system.txt')));
```

### Configuration File

[](#configuration-file)

Here's an example configuration file:

```
