PHPackages                             scriptoshi/laravel-mcp-client - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. scriptoshi/laravel-mcp-client

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

scriptoshi/laravel-mcp-client
=============================

Laravel MCP Client for managing tool servers and Claude integration

1.0.0(1y ago)32196[1 issues](https://github.com/scriptoshi/laravel-mcp-client/issues)MITPHPPHP ^8.3

Since Jan 6Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (8)Versions (2)Used By (0)

Laravel MCP Client
==================

[](#laravel-mcp-client)

Disclosure: This package was designed and written Entirely by claude ai. I may have guided and nuggged it in a few places, but the code was written by claude ai.

Laravel MCP (Message Context Protocol) Client is a package that integrates Anthropic's Claude AI model with custom tool servers, allowing you to extend Claude's capabilities with your own tools and services.

Features
--------

[](#features)

- Seamless integration with Anthropic's Claude API
- Tool server management and execution
- Built-in queuing support for long-running tools
- Event-driven architecture
- Automatic chat title generation
- Complete chat history management
- Database persistence for conversations and tool executions
- Soft deletes support
- Comprehensive logging system

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- Laravel 11.0 or higher
- Anthropic API key

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

[](#installation)

You can install the package via composer:

```
composer require scriptoshi/laravel-mcp-client
```

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

[](#configuration)

1. Publish the configuration file:

```
php artisan vendor:publish --provider="Scriptoshi\McpClient\McpClientServiceProvider"
```

2. Add your Anthropic API key to your .env file:

```
ANTHROPIC_API_KEY=your-api-key-here
ANTHROPIC_MODEL=claude-3-sonnet-20240229
ANTHROPIC_MAX_TOKENS=1024
```

3. Run the migrations:

```
php artisan migrate
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use Scriptoshi\McpClient\Facades\McpClient;

// Start a new chat
McpClient::processRequest("What's the weather like?", $chatUuid);
```

### Implementing a Custom Tool Server

[](#implementing-a-custom-tool-server)

Create a new server class that implements `McpServerInterface`:

```
use Scriptoshi\McpClient\Contracts\McpServerInterface;

class WeatherServer implements McpServerInterface
{
    public function initialize(): array
    {
        return [
            'serverInfo' => [
                'name' => 'WeatherServer',
                'version' => '1.0.0'
            ],
            'capabilities' => [
                'tools' => true
            ]
        ];
    }

    public function listTools(): array
    {
        return [
            'tools' => [
                [
                    'name' => 'get_weather',
                    'description' => 'Get current weather for a location',
                    'inputSchema' => [
                        'type' => 'object',
                        'properties' => [
                            'location' => [
                                'type' => 'string',
                                'description' => 'City name or coordinates'
                            ]
                        ],
                        'required' => ['location']
                    ]
                ]
            ]
        ];
    }

    public function toolShouldQueue(string $toolname): bool
    {
        return false;
    }

    public function executeTool(string $name, array $arguments, LoggerInterface $logger): array
    {
        // Implement your tool logic here
    }
}
```

### Registering a Tool Server

[](#registering-a-tool-server)

You can register tool servers in your `AppServiceProvider` or create a dedicated service provider:

```
use Scriptoshi\McpClient\Facades\McpClient;

public function boot()
{
    McpClient::registerServer('weather', new WeatherServer());
}
```

### Using the Queue

[](#using-the-queue)

For long-running tools, implement queueing:

```
public function toolShouldQueue(string $toolname): bool
{
    return match($toolname) {
        'long_running_process' => true,
        default => false
    };
}
```

### Working with Chat History

[](#working-with-chat-history)

```
use Scriptoshi\McpClient\Models\Chat;

// Find a chat by UUID
$chat = Chat::findByUuid($uuid);

// Get chat messages
$messages = $chat->messages;

// Get message responses
$responses = $message->responses;

// Get tool executions
$runners = $response->runners;
```

### Error Handling

[](#error-handling)

The package includes comprehensive error handling and logging:

```
$runner->error('Something went wrong', [
    'context' => 'Additional error details'
]);

// Different log levels
$runner->info('Processing started');
$runner->warning('Resource usage high');
$runner->success('Operation completed');
```

Events
------

[](#events)

The package dispatches several events you can listen for:

- `MessageCreatedEvent`
- `MessageProcessedEvent`
- `MessageErrorEvent`

Testing
-------

[](#testing)

```
composer test
```

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Scriptoshi](https://github.com/scriptoshi)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance40

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

498d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b11cbb2bd5d92b45e8e0c9ac7c644e33d72b02a792ffb399283d4566678c72eb?d=identicon)[scriptoshi](/maintainers/scriptoshi)

---

Top Contributors

[![ofumbi](https://avatars.githubusercontent.com/u/4081256?v=4)](https://github.com/ofumbi "ofumbi (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/scriptoshi-laravel-mcp-client/health.svg)

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

20917.2M158](/packages/orchestra-canvas)[kirschbaum-development/commentions

A package to allow you to create comments, tag users and more

12369.2k](/packages/kirschbaum-development-commentions)[shyim/danger-php

Port of danger to PHP

8544.9k](/packages/shyim-danger-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[glhd/special

1929.4k](/packages/glhd-special)

PHPackages © 2026

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