PHPackages                             bramato/laravel-mcp-server - 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. [API Development](/categories/api)
4. /
5. bramato/laravel-mcp-server

ActiveLibrary[API Development](/categories/api)

bramato/laravel-mcp-server
==========================

A base Laravel package for building Model Context Protocol (MCP) servers.

0.2.1(1y ago)023MITPHPPHP ^8.1

Since Apr 13Pushed 1y ago1 watchersCompare

[ Source](https://github.com/bramato/laravel-mcp-server)[ Packagist](https://packagist.org/packages/bramato/laravel-mcp-server)[ RSS](/packages/bramato-laravel-mcp-server/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (4)Used By (0)

 [![Laravel MCP Server Logo](https://camo.githubusercontent.com/28a3648c820bf929a9723ec279f5da4bf5f9e49b175a0003c350e03d72ab93f3/68747470733a2f2f66726565696d6167652e686f73742f692f33637030304f62)](https://camo.githubusercontent.com/28a3648c820bf929a9723ec279f5da4bf5f9e49b175a0003c350e03d72ab93f3/68747470733a2f2f66726565696d6167652e686f73742f692f33637030304f62)

Laravel MCP Server (bramato/laravel-mcp-server)
===============================================

[](#laravel-mcp-server-bramatolaravel-mcp-server)

A base Laravel package for building [Model Context Protocol (MCP)](https://gomcp.org/) servers.

[![Latest Version on Packagist](https://camo.githubusercontent.com/0a29c1c4347b18603e3c492770102a9a6e7b129833ab4408148cbb224008155d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6272616d61746f2f6c61726176656c2d6d63702d7365727665722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bramato/laravel-mcp-server)[![Total Downloads](https://camo.githubusercontent.com/aaaea023ce402a3850989a04647aa26e99e4f3d676f5b236b04e6d7c2fcbd1e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6272616d61746f2f6c61726176656c2d6d63702d7365727665722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bramato/laravel-mcp-server)

This package provides the basic infrastructure to handle MCP requests over different transports (Stdio, HTTP, WebSocket via Reverb). It uses the excellent [sajya/server](https://github.com/sajya/server) library internally for robust JSON-RPC 2.0 request parsing and response formatting.

You need to implement your own `ResourceInterface` and `ToolInterface` classes (using the `Bramato\\LaravelMcpServer\\Mcp\\Interfaces` namespace) and register them in the configuration file to expose your application's data and functionalities according to the MCP specification.

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

[](#installation)

You can install the package via composer:

```
composer require bramato/laravel-mcp-server
```

Next, you should publish the configuration file using the `vendor:publish` Artisan command:

```
php artisan vendor:publish --provider="Bramato\LaravelMcpServer\Providers\McpServiceProvider" --tag="config"
```

This will create a `config/mcp.php` file in your application's config directory, where you can customize the server's behavior.

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

[](#configuration)

The `config/mcp.php` file allows you to configure:

- `enabled_transports`: Choose which transports (`stdio`, `http`, `websocket`) are active.
- `transports`: Configure details for each transport (e.g., the HTTP path in `transports.http.path`).
- `authentication`: Basic authentication setup (supports `none` or `token` via `authentication.driver`). For token authentication, specify the header name in `authentication.options.header`.
- `resources`: **Register your MCP Resources.** Provide an array of fully qualified class names that implement `Bramato\\LaravelMcpServer\\Mcp\\Interfaces\\ResourceInterface`.
- `tools`: **Register your MCP Tools.** Provide an array of fully qualified class names that implement `Bramato\\LaravelMcpServer\\Mcp\\Interfaces\\ToolInterface`. This acts as a whitelist for executable tools.
- `logging`: Configure the logging channel and level for package-specific logs.

Creating Resources and Tools
----------------------------

[](#creating-resources-and-tools)

This package provides the interfaces, but you need to implement the actual logic.

**Example: Creating a Resource**

1. Create your Resource class (e.g., in `app/Mcp/Resources/UserProfileResource.php`):

    ```
    namespace App\Mcp\Resources;

    use Bramato\LaravelMcpServer\Mcp\Interfaces\ResourceInterface;
    use Illuminate\Support\Facades\Auth;

    class UserProfileResource implements ResourceInterface
    {
        public function getUri(): string { return 'user://profile'; } // Unique URI for this resource
        public function getName(): string { return 'User Profile'; }
        public function getDescription(): string { return 'Provides information about the authenticated user.'; }
        public function getMimeType(): string { return 'application/json'; }

        public function getContents(): mixed
        {
            $user = Auth::user(); // Example: Get authenticated user
            if (!$user) {
                return null; // Or throw an exception mapped to an error
            }
            return [
                'id' => $user->id,
                'name' => $user->name,
                'email' => $user->email,
            ];
        }
    }
    ```
2. Register it in `config/mcp.php`:

    ```
    // config/mcp.php
    return [
        // ... other config
        'resources' => [
            \App\Mcp\Resources\UserProfileResource::class,
        ],
        // ...
    ];
    ```

**Example: Creating a Tool**

1. Create your Tool class (e.g., in `app/Mcp/Tools/SendNotificationTool.php`):

    ```
    namespace App\Mcp\Tools;

    use Bramato\LaravelMcpServer\Mcp\Interfaces\ToolInterface;
    // use App\Jobs\ProcessNotificationJob; // Example Job
    use Illuminate\Support\Facades\Log;

    class SendNotificationTool implements ToolInterface
    {
        public function getName(): string { return 'sendNotification'; }
        public function getDescription(): string { return 'Sends a notification to a user.'; }

        public function getInputSchema(): array
        {
            // Define expected parameters using JSON Schema format
            return [
                'type' => 'object',
                'properties' => [
                    'user_id' => ['type' => 'integer', 'description' => 'ID of the target user'],
                    'message' => ['type' => 'string', 'description' => 'The notification message content'],
                ],
                'required' => ['user_id', 'message'],
            ];
        }

        public function execute(array $arguments): mixed
        {
            Log::info('Executing sendNotification tool', $arguments);
            // ** Add your logic here **
            // Example: Validate input, find user, dispatch a Job
            // ProcessNotificationJob::dispatch($arguments['user_id'], $arguments['message']);
            return ['status' => 'queued', 'user_id' => $arguments['user_id']];
        }
    }
    ```
2. Register it in `config/mcp.php`:

    ```
    // config/mcp.php
    return [
        // ... other config
        'tools' => [
            \App\Mcp\Tools\SendNotificationTool::class,
        ],
    ];
    ```

Usage
-----

[](#usage)

How to run the server depends on the enabled transport:

- **Stdio**: Run the Artisan command: `php artisan mcp:server --transport=stdio`.
- **HTTP**: Ensure your web server (e.g., `php artisan serve` or Nginx/Apache) is running. Send JSON-RPC POST requests to the path configured in `mcp.transports.http.path` (default: `/mcp-rpc`).
- **WebSocket (Reverb)**:
    1. Install and configure Laravel Reverb in your main application: `php artisan reverb:install`.
    2. Ensure the `websocket` transport is listed in `enabled_transports` in `config/mcp.php`.
    3. Start the Reverb server: `php artisan reverb:start`.
    4. Connect your MCP WebSocket client to the Reverb server endpoint (check your Reverb configuration).

Testing
-------

[](#testing)

The package includes a basic test suite using PHPUnit and Orchestra Testbench.

```
# From the package directory (packages/bramato/laravel-mcp-server)
../../vendor/bin/phpunit

# Or from the project root
./vendor/bin/phpunit packages/bramato/laravel-mcp-server/tests
```

Security Considerations
-----------------------

[](#security-considerations)

The MCP specification does not define authentication or authorization mechanisms between client and server. This package provides:

- **Tool Whitelisting**: Only tools explicitly listed in the `tools` array in `config/mcp.php` can be executed.
- **Basic Token Authentication**: You can enable token-based authentication via the `authentication` config section.

**Important**: It is **your responsibility** to implement fine-grained authorization logic within your `ToolInterface::execute` and `ResourceInterface::getContents` methods. Use Laravel's Gates and Policies or other authorization mechanisms to ensure that the requesting client has the necessary permissions to access specific resources or execute specific tools.

Contributing
------------

[](#contributing)

Please see `CONTRIBUTING.md` for details (if available).

License
-------

[](#license)

The MIT License (MIT). Please see the [LICENSE.md](LICENSE.md) file for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance47

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

3

Last Release

392d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/38055d590f08941b20679ac613e29db531f612149db31f8f4d3dc8b996bc7982?d=identicon)[bramato](/maintainers/bramato)

---

Top Contributors

[![bramato](https://avatars.githubusercontent.com/u/4388004?v=4)](https://github.com/bramato "bramato (21 commits)")

---

Tags

laravelmcpaijson-rpcllmModel Context Protocolreverb

### Embed Badge

![Health badge](/badges/bramato-laravel-mcp-server/health.svg)

```
[![Health](https://phpackages.com/badges/bramato-laravel-mcp-server/health.svg)](https://phpackages.com/packages/bramato-laravel-mcp-server)
```

###  Alternatives

[neuron-core/neuron-laravel

Official Neuron AI Laravel SDK.

10710.0k](/packages/neuron-core-neuron-laravel)[php-mcp/laravel

Laravel SDK for building Model Context Protocol (MCP) servers - Seamlessly integrate MCP tools, resources, and prompts into Laravel applications

47283.1k1](/packages/php-mcp-laravel)[vizra/vizra-adk

Vizra Agent Development Kit - A comprehensive Laravel package for building intelligent AI agents.

29026.1k](/packages/vizra-vizra-adk)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[mischasigtermans/laravel-toon

Token-Optimized Object Notation encoder/decoder for Laravel with intelligent nested object handling

13113.1k](/packages/mischasigtermans-laravel-toon)[claude-php/claude-php-sdk-laravel

Laravel integration for the Claude PHP SDK - Anthropic Claude API

5010.8k](/packages/claude-php-claude-php-sdk-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
