freshcrate
Skin:/
Home > MCP Servers > mcp-client-laravel

mcp-client-laravel

Laravel-native client for Model Context Protocol (MCP) servers. Built by Redberry (Diamond-tier Laravel partner). Used by LarAgent and other frameworks to enable AI agent functionality.

Why this rank:Release freshnessStrong adoptionHealthy release cadence

Description

Laravel-native client for Model Context Protocol (MCP) servers. Built by Redberry (Diamond-tier Laravel partner). Used by LarAgent and other frameworks to enable AI agent functionality.

README

MCP Client for Laravel

Latest Version on PackagistGitHub Tests Action StatusGitHub Code Style Action StatusTotal Downloads Laravel-native client for Model Context Protocol (MCP) servers
Built and maintained by Redberry, a Diamond-tier official Laravel partner.

AI PoC Sprint


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 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

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

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

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

  • 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

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

use Redberry\MCPClient\MCPClient;

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

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

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

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

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

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

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Release History

VersionChangesUrgencyDate
v1.1.1Backport release. Public API unchanged. Brings v1.x in line with the dependency widening from `main`. ## Added - **Laravel 13 and PHP 8.5 support.** `composer.json` now allows: - `php: ^8.3||^8.4||^8.5` - `illuminate/contracts: ^10.0||^11.0||^12.0||^13.0` - `orchestra/testbench: ^8.22||^9.0||^10.0||^11.0` - CI matrix now runs PHP 8.3/8.4/8.5 × Laravel 11/12/13 (each with its matching Testbench major), `prefer-lowest` and `prefer-stable`. Larastan pinned to `^3.0`; Pest widened to `^2.0||High5/8/2026
v1.1.0## What's Changed * Headers, new configs and fixes by @MaestroError in https://github.com/RedberryProducts/mcp-client-laravel/pull/26 * Build(deps): Bump actions/checkout from 4 to 5 by @dependabot[bot] in https://github.com/RedberryProducts/mcp-client-laravel/pull/17 * Build(deps): Bump stefanzweifel/git-auto-commit-action from 6 to 7 by @dependabot[bot] in https://github.com/RedberryProducts/mcp-client-laravel/pull/21 **Full Changelog**: https://github.com/RedberryProducts/mcp-client-lLow11/7/2025
v1.0.0## What's Changed * Build(deps): Bump stefanzweifel/git-auto-commit-action from 5 to 6 by @dependabot[bot] in https://github.com/RedberryProducts/mcp-client-laravel/pull/1 * Feat/transporter by @nikajorjika in https://github.com/RedberryProducts/mcp-client-laravel/pull/2 * MCP client implementation by @nikajorjika in https://github.com/RedberryProducts/mcp-client-laravel/pull/3 * Create feature.yml by @nikajorjika in https://github.com/RedberryProducts/mcp-client-laravel/pull/4 * Add stdio Low9/29/2025

Dependencies & License Audit

Loading dependencies...

Similar Packages

mayrosProduction-ready AI agent framework — semantic memory, multi-agent mesh, MCP server, intelligent routing, governance, and 67+ platform integrations.v0.3.2
DeepMCPAgentModel-agnostic plug-n-play LangChain/LangGraph agents powered entirely by MCP tools over HTTP/SSE.v1.1.0
chatbotTorvian Chatbot is a self-hosted chatbot platform with a Ktor backend and Compose Multiplatform clients, supporting OpenAI-compatible APIs, Ollama local models, and MCP tool calling with per-call userv0.8.0
c4-genai-suitec4 GenAI Suitev10.0.0
galdrAI-powered development framework with task management, 41 agents, 83 skills, and MCP tools for Cursor, Claude Code, Gemini, Codex & OpenCode. File-based memory that survives across sessions.v3.0.0

More in MCP Servers

supersetCode Editor for the AI Agents Era - Run an army of Claude Code, Codex, etc. on your machine
kreuzbergA polyglot document intelligence framework with a Rust core. Extract text, metadata, images, and structured information from PDFs, Office documents, images, and 91+ formats. Available for Rust, Python
ai-engineering-from-scratchLearn it. Build it. Ship it for others.
CodeGraphContextAn MCP server plus a CLI tool that indexes local code into a graph database to provide context to AI assistants.