PHPackages                             redberry/mcp-client-laravel - 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. redberry/mcp-client-laravel

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

redberry/mcp-client-laravel
===========================

Package that enables you access to any mcp server that you define in the config

v1.1.0(6mo ago)1345.0k↑49.6%2[4 PRs](https://github.com/RedberryProducts/mcp-client-laravel/pulls)1MITPHPPHP ^8.3||^8.4CI passing

Since Jul 6Pushed 4mo agoCompare

[ Source](https://github.com/RedberryProducts/mcp-client-laravel)[ Packagist](https://packagist.org/packages/redberry/mcp-client-laravel)[ Docs](https://github.com/redberryproducts/mcp-client-laravel)[ GitHub Sponsors](https://github.com/Redberry)[ RSS](/packages/redberry-mcp-client-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (13)Versions (11)Used By (1)

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

[](#mcp-client-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e9ab87b8349d2c69d216cfc3e9c2fe5674a1b47f23014747b2e70a9f11d4dff3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72656462657272792f6d63702d636c69656e742d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/redberry/mcp-client-laravel)[![GitHub Tests Action Status](https://camo.githubusercontent.com/c72b862d20e515b61c208454a6803c5ea45735faa50c7d19026ed84eb38af42c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f726564626572727970726f64756374732f6d63702d636c69656e742d6c61726176656c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/redberryproducts/mcp-client-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/3048793253ddc8bfd5c9aeedd2c3577d01ab0aa3c35543702456074ecdd225ff/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f726564626572727970726f64756374732f6d63702d636c69656e742d6c61726176656c2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/redberryproducts/mcp-client-laravel/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/56d2969a1c2f9b51a6f91f9132bc7bd43049806dafbfe963aa4cf40b94936ddf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72656462657272792f6d63702d636c69656e742d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/redberry/mcp-client-laravel)

 **Laravel-native client for Model Context Protocol (MCP) servers**
 Built and maintained by Redberry, a Diamond-tier official Laravel partner.

 AI PoC Sprint

---

🚀 What is This?
---------------

[](#-what-is-this)

This package provides a Laravel-native client for interacting with **Model Context Protocol (MCP)** servers — enabling your Laravel application to communicate with external tools, structured resources, and memory services in a standardized way.

It is **framework-agnostic** and can be used in any Laravel application. Agent frameworks like [LarAgent](https://github.com/MaestroError/LarAgent) use this package internally to enable tool use, memory management, and reasoning across distributed contexts.

Use it to:

- Connect to any MCP-compliant server over HTTP or STDIO
- Discover and call tools defined on MCP servers
- Access structured memory and contextual resources
- Extend your Laravel apps with AI-ready interfaces to external agents or toolchains

> 🚀 Looking to build an AI agent in Laravel? Talk to us about our 5-week PoC sprint — from idea to working prototype.

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

[](#installation)

*Note that while project is running with `php artisan serve` **STDIO** transporter doesn't work*

You can install the package via composer:

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

After installation, publish the configuration file:

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

This will create a `config/mcp-client.php` file in your application.

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

[](#configuration)

The published configuration file contains settings for your MCP servers. Here's an example configuration:

```
return [
    'servers' => [
        'github' => [
            'type' => \Redberry\MCPClient\Enums\Transporters::HTTP,
            'base_url' => 'https://api.githubcopilot.com/mcp',
            'timeout' => 30,
            'token' => env('GITHUB_API_TOKEN', null),
        ],
        'npx_mcp_server' => [
            'type' => \Redberry\MCPClient\Enums\Transporters::STDIO,
            'command' => [
                'npx',
                '-y',
                '@modelcontextprotocol/server-memory',
            ],
            'timeout' => 30,
            'cwd' => base_path(),
        ],
    ],
];
```

### Configuration Options

[](#configuration-options)

#### HTTP Transporter

[](#http-transporter)

- `type`: Set to `Redberry\MCPClient\Enums\Transporters::HTTP` for HTTP connections
- `base_url`: The base URL of the MCP server
- `timeout`: Request timeout in seconds
- `token`: Authentication token (if required)

#### STDIO Transporter

[](#stdio-transporter)

- `type`: Set to `Redberry\MCPClient\Enums\Transporters::STDIO` for STDIO connections
- `command`: Array of command parts to execute the MCP server
- `timeout`: Command timeout in seconds
- `cwd`: Current working directory for the command

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use Redberry\MCPClient\Facades\MCPClient;

// Connect to a specific MCP server defined in your config
$client = MCPClient::connect('github');

// Get available tools from the MCP server
$tools = $client->tools();

// Get available resources from the MCP server
$resources = $client->resources();
```

### Using Dependency Injection

[](#using-dependency-injection)

```
use Redberry\MCPClient\MCPClient;

class MyService
{
    public function __construct(private MCPClient $mcpClient)
    {
    }

    public function getToolsFromGithub()
    {
        return $this->mcpClient->connect('github')->tools();
    }
}
```

### Working with Collections

[](#working-with-collections)

The `tools()` and `resources()` methods return a `Collection` object that provides helpful methods for working with the results:

```
// Get all tools as an array
$allTools = $client->tools()->all();

// Get only specific tools by name
$specificTools = $client->tools()->only('tool1', 'tool2');

// Exclude specific tools
$filteredTools = $client->tools()->except('tool3');

// Map over tools
$mappedTools = $client->tools()->map(function ($tool) {
    return $tool['name'];
});
```

### Call tools

[](#call-tools)

The `callTool` method is used to execute specific tool. Here is the signature:

```
public function callTool(string $toolName, mixed $params = []): mixed;
```

Example:

```
$result = $client->callTool('create_entities', [
    'entities' => [
        [
            'name' => 'John Doe',
            'entityType' => 'PERSON',
            'observations' => ['Test observation 1', 'Test observation 2'],
        ]
    ],
]);
```

### Read Resources

[](#read-resources)

The `readResource` method is used to retrieve the resource by the `uri`.

```
public function readResource(string $uri): mixed;
```

Example:

```
$result = $client->readResource("file:///project/src/main.rs");
```

Advanced Usage
--------------

[](#advanced-usage)

### Creating Custom Transporters

[](#creating-custom-transporters)

If you need to create a custom transporter, you can extend the `Transporter` interface and implement your own transport mechanism. Then register it in the `TransporterFactory`.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Nika Jorjoliani](https://github.com/nikajorjika)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance73

Regular maintenance activity

Popularity39

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 84.1% 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 ~38 days

Total

2

Last Release

193d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d2ceddc163a8c821d012238fe8f5439bd018bcd3036368c373eb397a19acfe7b?d=identicon)[Redberry LTD](/maintainers/Redberry%20LTD)

---

Top Contributors

[![nikajorjika](https://avatars.githubusercontent.com/u/4212052?v=4)](https://github.com/nikajorjika "nikajorjika (90 commits)")[![MaestroError](https://avatars.githubusercontent.com/u/46760939?v=4)](https://github.com/MaestroError "MaestroError (14 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

---

Tags

agent-integrationai-agentsai-frameworkchatbotcontextlaravellaravel-ailaravel-packagellmmcpmcp-clientmemoryopenaiphpprompt-engineeringredberrytoolslaravelredberrymcp-client-laravel

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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