MCP.so
Sign In
Servers

MCP SDK for Laravel

@ronydebnath

WIP - Model Context Protocol (MCP) SDK for Laravel. A robust, extensible Laravel package that implements the Model Context Protocol (MCP) for building AI-driven conversational applications.

Overview

What is MCP SDK for Laravel?

MCP SDK for Laravel is a PHP package that provides both a client for interacting with Model Context Protocol (MCP) servers and tools for implementing MCP servers within a Laravel application. It is designed for Laravel developers who need to integrate or serve MCP-based conversational AI.

How to use MCP SDK for Laravel?

Install via Composer (composer require ronydebnath/mcp-sdk) and publish the config with php artisan vendor:publish. Configure environment variables like MCP_HOST, MCP_PORT, and MCP_TOKEN_EXPIRY, then use the MCPClient or StreamingMCPClient via dependency injection or the MCP facade to send messages. Set up an MCP server by adding a POST /mcp route and registering message handlers on MCPServer.

Key features of MCP SDK for Laravel

  • Client for sending messages with streaming support
  • Server implementation with custom message handlers
  • Built-in authentication using bearer tokens or query parameters
  • Memory and context management for conversation state
  • Progress tracking for long-running operations
  • Configurable via environment variables and publishable config file

Use cases of MCP SDK for Laravel

  • Build a Laravel-powered MCP client to communicate with remote MCP servers
  • Expose a Laravel application as an MCP server with custom logic
  • Manage multi-turn conversations with memory persistence
  • Stream responses from MCP servers to clients in real time
  • Authenticate and authorize MCP requests using token-based middleware

FAQ from MCP SDK for Laravel

What does this package do?

It provides a Laravel SDK for both consuming and serving MCP (Model Context Protocol) endpoints, including client messaging, server handling, authentication, memory, and progress tracking.

How does authentication work?

The server supports token-based authentication. Clients can send a bearer token in the Authorization header or include it as a token query parameter. Tokens are generated via AuthProvider::generateToken() and validated by the AuthMiddleware.

Where is conversation memory stored?

Memory is kept in-memory by default. If MCP_MEMORY_PERSIST is set to true, data is persisted to the filesystem at the path specified by MCP_MEMORY_STORAGE_PATH (default storage_path('app/mcp/memory')).

What transport does the package use?

Connections are HTTP-based. The client sends messages to a configured host/port. The server listens on a POST /mcp route. Streaming is supported when the client sends an Accept: text/event-stream header.

What are the runtime requirements?

The package requires a Laravel application running on PHP 8.0+ with the Composer dependency manager. It uses standard Laravel features like service providers, facades, and dependency injection.

Tags

More from Developer Tools