Weave Code
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 Laravel Package

redberry/mcp-client-laravel

Laravel client for the Model Context Protocol (MCP). Supports JSON-RPC 2.0 over Streamable HTTP (including SSE) and STDIO. Configure multiple servers and use a single facade to list/call tools and read resources, with per-request content negotiation.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Modular & Extensible: The package follows a clean architecture with clear separation between core logic (MCPClient), transports (HTTP, STDIO), and contracts (MCPClient interface). This aligns well with Laravel’s dependency injection and service container patterns.
  • Protocol-Agnostic: Supports Model Context Protocol (MCP) via JSON-RPC 2.0, with built-in support for Streamable HTTP (SSE) and STDIO transports. This makes it versatile for both remote (API-based) and local (subprocess) AI/agent integrations.
  • Facade & DI-Friendly: The facade (MCPClient) and contract (Contracts\MCPClient) enable seamless integration into Laravel’s service container, reducing boilerplate for dependency injection.
  • Streaming Support: Native SSE handling for long-running operations (e.g., AI tool calls) is a key differentiator for agentic workflows, aligning with Laravel’s event-driven capabilities.

Integration Feasibility

  • Laravel Native: Built for Laravel (uses illuminate/contracts, orchestra/testbench), with zero framework conflicts (MIT license).
  • Config-Driven: Server configurations (HTTP/STDIO) are publishable via php artisan vendor:publish, reducing manual setup.
  • Tool/Resource Abstraction: Exposes tools() and resources() as Laravel Collections, enabling fluent chaining (e.g., ->only(['search'])).
  • Event Streaming: Callback support for callTool()/readResource() allows real-time processing of intermediate results (e.g., logging, progress tracking).

Technical Risk

Risk Area Mitigation Strategy
Transport Failures HTTP: Automatic session recovery on 404 (configurable retries). STDIO: Lazy subprocess initialization.
Version Compatibility Supports Laravel 10–13 and PHP 8.3–8.5. Backward compatibility noted in UPGRADE.md.
Performance STDIO subprocesses persist across calls (efficient for repeated use). HTTP uses Guzzle under the hood.
Security Token-based auth (Bearer) for HTTP; subprocess isolation for STDIO. No exposed sensitive data in defaults.
Testing CI includes PHP 8.3/8.4/8.5, Laravel 11/12/13, and Pest/Testbench. Local testing via composer test.

Key Questions

  1. Use Case Alignment:
    • Is this for remote AI APIs (HTTP) or local agent processes (STDIO)?
    • Will tools/resources require streaming (e.g., progress updates)?
  2. Scaling Needs:
    • How many simultaneous MCP connections are needed? (STDIO subprocesses may require tuning for high concurrency.)
    • Will session management (e.g., token rotation) be required?
  3. Customization:
    • Are custom transports needed (e.g., WebSockets, gRPC)?
    • Will tool/resource filtering (e.g., dynamic whitelisting) be required?
  4. Observability:
    • How should streaming events (e.g., logs, progress) be surfaced (e.g., Laravel Events, logging)?
  5. Deployment:
    • For STDIO: Will the app run under Octane/queue workers (required for subprocess persistence)?

Integration Approach

Stack Fit

  • Laravel Core: Leverages facades, service container, and config publishing natively.
  • HTTP Clients: Uses Guzzle (injected via HttpTransporter), compatible with Laravel’s HTTP stack.
  • Event System: Streaming callbacks integrate with Laravel’s event listeners or logging.
  • Testing: Works with Pest/Testbench (CI-validated).

Migration Path

  1. Installation:
    composer require redberry/mcp-client-laravel
    php artisan vendor:publish --tag="mcp-client-config"
    
  2. Configure Servers:
    • Define HTTP (remote) or STDIO (local) servers in config/mcp-client.php.
    • Example:
      'servers' => [
          'github' => [
              'type' => Transporters::HTTP,
              'base_url' => 'https://api.githubcopilot.com/mcp',
              'token' => env('GITHUB_TOKEN'),
          ],
          'local_agent' => [
              'type' => Transporters::STDIO,
              'command' => ['npx', '@modelcontextprotocol/server-memory'],
          ],
      ],
      
  3. Dependency Injection:
    • Inject Redberry\MCPClient\Contracts\MCPClient into services:
      public function __construct(private MCPClient $client) {}
      
  4. Usage:
    • List tools/resources:
      $tools = $client->connect('github')->tools()->only(['search']);
      
    • Call a tool:
      $result = $client->connect('github')->callTool('create_issue', ['title' => 'Fix bug']);
      
    • Stream events:
      $client->connect('github')->callTool('long_task', [], function (array $event) {
          Log::info('MCP Event', $event);
      });
      

Compatibility

Component Compatibility Notes
Laravel Tested on 10–13; uses illuminate/contracts.
PHP 8.3–8.5 (PHP 8.2 may need adjustments for typed properties).
Transports HTTP: Guzzle-compatible. STDIO: Requires non-PHP CLI (e.g., Octane, queues).
Streaming SSE-only for HTTP; STDIO uses newline-delimited JSON-RPC.
Error Handling JSON-RPC errors mapped to Laravel exceptions (e.g., RuntimeException).

Sequencing

  1. Phase 1: Core Integration
    • Publish config, configure servers, inject MCPClient.
    • Test basic tool/resource calls.
  2. Phase 2: Streaming
    • Implement event callbacks for long-running operations.
    • Integrate with Laravel logging/events.
  3. Phase 3: Scaling
    • Tune STDIO subprocess timeouts (process_timeout).
    • Add session management (e.g., token rotation).
  4. Phase 4: Customization
    • Extend transports (e.g., WebSockets) if needed.
    • Add middleware for tool/resource filtering.

Operational Impact

Maintenance

  • Dependencies:
    • Guzzle (HTTP), Symfony Process (STDIO) are battle-tested.
    • No external state: Config is self-contained; no shared DB/Redis.
  • Updates:
    • Follow semver (v2.x breaking changes documented in UPGRADE.md).
    • Monitor Packagist for new releases (last: 2026-05-08).
  • Debugging:
    • HTTP: Guzzle middleware for request/response inspection.
    • STDIO: Log subprocess output via Process::getOutput().

Support

  • Documentation:
    • README covers installation/configuration.
    • ARCHITECTURE.md details internals (e.g., transports).
    • MCP Spec Rules clarify protocol constraints.
  • Community:
    • 13 stars, 0 dependents (early-stage; Redberry-backed).
    • GitHub issues for bugs; Redberry support for enterprise.
  • Error Handling:
    • HTTP 404: Auto-retry session recovery.
    • JSON-RPC Errors: Wrapped in RuntimeException with context.

Scaling

Scenario Considerations
High Concurrency STDIO: Subprocesses are reused but may hit OS limits. Use process_timeout.
Long-Running Calls HTTP: SSE read_timeout (default: 60s) prevents wedged streams.
Multiple Servers Cached transporters per server; no cross-server leakage.
Queue Workers STDIO works if processes persist (e.g., Laravel Horizon with process_timeout).

Failure Modes

Failure Type Impact Mitigation
HTTP 404 (Session) Lost session; auto-retry (configurable). Monitor max_session_retries.
STDIO Process Crash Subprocess dies; lazy restart on next call. Set process_timeout to kill hung processes.
Network Timeout
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.
codraw/entity-migrator
codraw/doctrine-extra
codraw/aws-tool-kit
codraw/validator
codraw/workflow
codraw/open-api
codraw/cron-job
codraw/process
codraw/log
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony