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

Sdk Laravel Package

mcp/sdk

The official PHP SDK for the Model Context Protocol: a framework-agnostic API for building MCP servers and clients in PHP, with tools, resources, prompts, STDIO and HTTP transports, sessions, authorization, and support for both protocol eras.

View on GitHub
Deep Wiki
Context7

The official PHP SDK for the Model Context Protocol (MCP), developed collaboratively by the PHP Foundation and the Symfony project. It offers a framework-agnostic API for building MCP servers and clients, covering tools, resources, prompts, transports, sessions, and authorization—supporting both protocol eras (the initialize handshake and the stateless 2026-07-28 revision). Currently experimental.

  • Tools, resources & prompts with a clean, framework-agnostic API
  • STDIO and HTTP transports plus session management
  • Authorization support built in
  • Dual protocol eras: initialize handshake and stateless 2026-07-28
  • Conformance-tested servers and clients, following Symfony standards and BC promise
Frequently asked questions about Sdk
How do I install mcp/sdk in a Laravel application?
Install it with Composer using composer require mcp/sdk. The SDK is framework-agnostic and ships no Laravel service provider, so you register your server or client in your own provider, such as McpServerServiceProvider, and bind it in the container. From there you define tools, resources and prompts using PHP attributes or manual registration and attach either the STDIO or Streamable HTTP transport. Pin the version in composer.json, because the package is still pre-1.0.
Does mcp/sdk work with Laravel?
Yes. The SDK is framework-agnostic and built on PSR standards, so it runs alongside Laravel without tight coupling. You can wrap it in a service provider for dependency injection, route StreamableHttpTransport through Laravel middleware for CORS and authentication, and map MCP lifecycle events onto Laravel's event system. Expect to write a thin integration layer yourself, since there is no official Laravel wrapper package.
Should I use the STDIO or HTTP transport with mcp/sdk?
Use STDIO for CLI tools and local agent processes where blocking I/O is acceptable. Use StreamableHttpTransport for web APIs and remote AI clients, since it fits Laravel's HTTP layer and middleware pipeline, including authentication and CORS. Avoid STDIO for high-throughput APIs and keep HTTP middleware lean to limit added latency. Hybrid setups are possible but can complicate routing.
Is mcp/sdk production-ready at version 0.8.1?
The SDK is officially maintained in collaboration with the PHP Foundation and Symfony, but it is explicitly experimental until 1.0, so breaking changes are possible. v0.8.1 is a patch release with no breaking changes, deprecations or new public APIs: it fixes variadic tool parameter casting, stops announcing externally loaded registries as changed, and bumps a CI dependency. Pin the version, review the changelog and roadmap before each minor bump, and re-test your tool contracts on upgrades given the pace from 0.6 to 0.8.1.
How do I expose Laravel Eloquent models as MCP tools or resources?
Register tools and resources that wrap your Eloquent queries and return plain arrays or scalars that satisfy the MCP JSON Schema you declare. Use attributes for simple registration and manual registration when you compose registries from multiple service providers. Explicitly type array and list-shaped parameters in the schema rather than relying on implicit coercion, even though v0.8.1 now casts variadic parameters element by element. Enforce authorization inside the handler, since MCP clients can call tools directly.
How does authentication work with mcp/sdk?
The HTTP transport supports OAuth, which you can bridge to Laravel Sanctum or Passport so your existing tokens and guards apply to MCP requests. Sessions are stored through PSR-16, so you can back them with Laravel's cache store, including Redis, and share state across queue workers. STDIO transport instead runs with local process privileges and relies on the host environment rather than HTTP authentication.
Can I build an MCP client with mcp/sdk, not just a server?
Yes. The SDK provides both client and server implementations, and the README tracks client conformance alongside server conformance for both protocol eras. That makes it viable for Laravel apps that need to call external MCP servers as well as expose their own tools. Client sessions and transports follow the same framework-agnostic patterns as the server side.
Which Laravel and PHP versions does mcp/sdk support?
The SDK is framework-agnostic plain PHP, so it does not impose a Laravel version constraint; any Laravel release that satisfies its PHP requirement should work. Check the PHP version badge on Packagist or the require section of composer.json for the exact constraint before installing. Because the package is pre-1.0, confirm the constraint again on each upgrade rather than assuming it is unchanged.
How should I handle MCP sessions and caching in Laravel with mcp/sdk?
Session storage uses PSR-16, so you can point it at Laravel's cache repository and use Redis or another shared store in production. Align session lifetime and eviction with your queue workers and horizontal scaling so tool calls do not lose state mid-conversation. For STDIO-based CLI usage, an in-memory or file store is usually sufficient. Avoid request-local stores when running behind a load balancer.
How do I test MCP tools and servers built with mcp/sdk?
Unit test your tool and resource handler classes directly by resolving them from Laravel's container, then add integration tests that exercise the real transport. The project publishes weekly client and server conformance results for both protocol eras, which is a useful signal of protocol compliance. Test list-shaped and variadic tool arguments explicitly, since argument coercion was a known source of bugs before the v0.8.1 fix. Re-run contract tests whenever you bump the minor version.
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.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator