Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Mcp Client Laravel

Mcp Client Laravel Laravel Package

redberry/mcp-client-laravel

Laravel client for the Model Context Protocol, speaking JSON-RPC 2.0 over Streamable HTTP and STDIO. One facade lists and calls tools and reads resources, with per-request content negotiation for JSON or SSE replies.

View on GitHub
Deep Wiki
Context7

MCP Client for Laravel is a client for the Model Context Protocol, speaking JSON-RPC 2.0 over both Streamable HTTP (2025-03-26) and STDIO. It exposes a single facade for listing and calling tools and reading resources, letting your Laravel app connect to remote servers or local subprocesses through a simple config array.

The HTTP transport content-negotiates on every request, so you get the final result whether the server replies with one JSON object or a stream of server-sent events.

  • Dual transports: HTTP for remote servers, STDIO for local subprocesses
  • Content negotiation handles JSON or SSE replies transparently
  • Single facade for tools and resources
  • Simple config with per-server timeout and token settings
Frequently asked questions about Mcp Client Laravel
How do I install and configure redberry/mcp-client-laravel in a Laravel app?
Install it with composer require redberry/mcp-client-laravel, then publish the config using php artisan vendor:publish --tag="mcp-client-config". That creates config/mcp-client.php, where you define servers under the servers array. Each server entry specifies either the HTTP or STDIO transport plus connection details such as base_url and token, or command and cwd.
Which Laravel and PHP versions does this MCP client support?
Laravel 11 through 13 and PHP 8.3 through 8.5 are the supported, CI-covered versions. Laravel 10 will install but is outside CI, so treat it as unsupported. PHP 8.2 is blocked. Resolve any version constraints before adopting the package.
How do I connect to a remote MCP server over Streamable HTTP with a bearer token?
Add an HTTP server entry with type Transporters::HTTP, a base_url, and a token pulled from an environment variable. Bearer-token auth is built in. OAuth flows are not handled, so you must acquire and inject the token yourself. Then use the facade to connect and list or call tools.
Can I use STDIO transport with npx MCP servers, and why does php artisan serve fail?
Yes, define a STDIO server with a command array and cwd. STDIO starts a lazy subprocess and reuses it per worker, so it needs a long-lived PHP runtime such as Octane, a queue worker, Sail, or Valet. It is explicitly broken under php artisan serve. Also review inherit_env because the child process sees the full parent environment by default.
How do I list tools and call an MCP tool using the MCPClient facade?
Use the MCPClient facade to connect to a configured server, then call tools() to list available tools and callTool($name, $arguments) to invoke one. Results are decoded JSON-RPC arrays, so validate and map them in your application. You can pass an optional onEvent callback to receive SSE progress events.
How do I read resources from an MCP server with this package?
After connecting, call resources() to list available resources and readResource($uri) to fetch one. Requests are sent as JSON-RPC over the configured HTTP or STDIO transport. The client returns decoded arrays, so wrap responses in your own DTO or validation layer before exposing them to controllers or jobs.
How do I test code that uses the MCP client facade without hitting a real server?
The package exposes a single facade and a Contracts\MCPClient seam you can mock. Swap the container binding or use Facade::shouldReceive in your tests. Because returns are plain arrays, assert against expected JSON-RPC result structures. Keep a thin adapter in your app so tests do not depend directly on raw package arrays.
Why does callTool return an array, and should I add DTOs on top?
The client returns decoded JSON-RPC results as arrays, leaving schema validation and typing to your application. That keeps the package a thin protocol adapter but is risky if raw arrays reach controllers or jobs. Add a DTO or mapper layer and validate both tool arguments and results. There is no built-in JSON Schema validation for tool arguments.
What breaking changes landed in v2.0.0 and how do I upgrade from 1.x?
v2.0.0 shipped four breaking changes at once: connect() returns an immutable clone, the client became a container singleton, Contracts\MCPClient is aliased to the concrete class, and return types are tightened. Prototypes built on 1.x will break. Pin the major version and plan every major upgrade as scheduled work.
Does it handle HTTP session loss or rate limits automatically?
HTTP session loss, such as a 404, triggers one automatic re-handshake and retry controlled by max_session_retries, which defaults to 1. There is no backoff, circuit breaker, or rate-limit handling beyond that. Flapping upstream servers can become your outages. Add your own resilience layer and monitor errors around the facade.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections