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