Releases: php-mcp/laravel
v3.1.0
What's Changed
- Add PHPUnit 12 support and fix test compatibility issues by @tkaratug in #26
- feat: Add Closure Handler Support and Custom Input Schema for Tools by @CodeWithKyrian in #27
- Fix: correct argument order in response()->stream for legacy SSE mode by @sergioalborada in #31
- Fix ServeCommand output interfering with stdio JSON-RPC communication by @CodeWithKyrian in #34
New Contributors
- @tkaratug made their first contribution in #26
- @sergioalborada made their first contribution in #31
Full Changelog: 3.0.0...3.1.0
v3.0.0
Major Changes
- Upgraded to php-mcp/server ^3.0 with latest MCP protocol support(
2025-03-26) - Laravel-native session management with multiple storage backends (file, database, cache, redis)
- Streamable HTTP transport with resumability and better connection handling
- Simplified configuration structure for capabilities and session management
Improvements
- Enhanced transport layer with better error handling
- Automatic session garbage collection
- Updated documentation with migration guide
Fixes
- Fixed SSE stream handling for expired sessions
- Improved transport initialization
- Better memory management for long-running servers
Breaking Changes
- Requires
php-mcp/server ^3.0 - Updated configuration structure (see migration guide in
README) - Transport class names changed for consistency
Installation
composer require php-mcp/laravel:^3.0
php artisan vendor:publish --provider="PhpMcp\Laravel\McpServiceProvider"Full Changelog: 2.1.1...3.0.0
v2.1.1
What's Changed
- Fix STDIO transport stream errors on client disconnect by @CodeWithKyrian in #23
Full Changelog: 2.1.0...2.1.1
v2.1.0
What's Changed
- Update README.md by @taylorotwell in #5
- [docs] Fix publish config command for 2.x by @barryvdh in #7
- [docs] Remove config call from app/bootstrap.php by @barryvdh in #8
- Do not defer ServiceProvider to boot routes by @barryvdh in #9
- Fix: Correct Client State Management in LaravelHttpTransport by @CodeWithKyrian in #17
- chore: Update dependencies and improve MCP notification handling by @CodeWithKyrian in #18
- docs: transport should be explicitly set to stdio for the tool to start by @xel1045 in #15
New Contributors
- @taylorotwell made their first contribution in #5
- @barryvdh made their first contribution in #7
- @xel1045 made their first contribution in #15
Full Changelog: 2.0.0...2.1.0
v2.0.0
This release marks a major overhaul, bringing it into full alignment with php-mcp/server v2.1.0+ and introducing a significantly improved, more "Laravely" developer experience.
Added
- Fluent Manual Registration API:
- Introduced the
McpFacade (PhpMcp\Laravel\Facades\Mcp). - Define Tools, Resources, Prompts, and Resource Templates fluently (e.g.,
Mcp::tool(...)->description(...)). - Definitions are typically placed in
routes/mcp.php(configurable). - Handlers are resolved via Laravel's service container, allowing dependency injection.
- Introduced the
- Dedicated HTTP Server Transport via
mcp:serve:- The
php artisan mcp:serve --transport=httpcommand now launches a standalone, high-performance ReactPHP-based HTTP server using\PhpMcp\Server\Transports\HttpServerTransport. - Configuration for this dedicated server is in
config/mcp.phpundertransports.http_dedicated. - CLI options (
--host,--port,--path-prefix) can override config defaults.
- The
LaravelHttpTransportfor Integrated HTTP:- New
PhpMcp\Laravel\Transports\LaravelHttpTransportclass implementsServerTransportInterfaceto bridge Laravel's HTTP request lifecycle with the core MCPProtocolhandler.
- New
- Configurable Auto-Discovery:
config('mcp.discovery.auto_discover')(default:true) now controls whether discovery runs automatically or not. You can set it to false in production..
- Interactive Prompt for
mcp:serve: If--transportis not specified, the command now interactively prompts the user to choose betweenstdioandhttp.
Changed
- Core Server Integration: Now uses
\PhpMcp\Server\Server::make()(ServerBuilder) for all server instantiation, fully leveragingphp-mcp/serverv2.x architecture. - Namespace: Base package namespace changed from
PhpMcp\Laravel\ServertoPhpMcp\Laravel. - Configuration (
config/mcp.php):- Significantly restructured and updated to align with
ServerBuilderoptions. - Clearer separation of settings for
http_dedicatedvs.http_integratedtransports. - Simplified cache TTL (
cache.ttl) and discovery (discovery.save_to_cache_on_discover) keys. - Added
server.instructionsfor theinitializeMCP response. - Added
discovery.exclude_dirsanddiscovery.definitions_file.
- Significantly restructured and updated to align with
McpServiceProvider:- Completely rewritten to correctly build and configure the
\PhpMcp\Server\Serverinstance using Laravel's services for logging, caching (with fallback to coreFileCache), container, and event loop. - Loads manual definitions from the configured
definitions_fileviaMcpRegistrar. - Sets up core
Registrynotifiers to dispatch Laravel events for list changes.
- Completely rewritten to correctly build and configure the
McpController(Integrated HTTP): More robustly handles the integrated server behavior, working with a customLaravelHttpTransport.- Artisan Commands:
mcp:discover: Now directly callsServer::discover()with configured/CLI parameters.forceoption behavior clarified.mcp:list: Fetches elements from the live, fully configuredRegistryfrom the resolvedServerinstance.mcp:serve: Refactored to use coreStdioServerTransportorHttpServerTransportdirectly.
- Dependency: Updated
php-mcp/serverto^2.2.0
Fixed
- More robust error handling and logging in Artisan commands and
McpController. - Improved clarity and consistency in how core server components are resolved and used within the Laravel context.
Removed
PhpMcp\Laravel\Server\Adapters\ConfigAdapter: No longer needed due to changes inphp-mcp/serverv2.x.
BREAKING CHANGES
- Namespace Change: The primary package namespace has changed from
PhpMcp\Laravel\ServertoPhpMcp\Laravel. Update allusestatements and FQCN references in your application. You may have to uninstall and reinstall the package to avoid conflicts. - Configuration File: The
config/mcp.phpfile has been significantly restructured. You must republish and merge your customizations:php artisan vendor:publish --provider="PhpMcp\Laravel\McpServiceProvider" --tag="mcp-config" --force
mcp:servefor HTTP: The--transport=httpoption formcp:servenow launches a dedicated ReactPHP-based server process. For serving MCP via your main Laravel application routes, ensure thehttp_integratedtransport is enabled inconfig/mcp.phpand your web server is configured appropriately.- Event Handling: If you were directly listening to internal events from the previous version, these may have changed. Rely on the documented Laravel events (
ToolsListChanged, etc.). - Removed Classes:
PhpMcp\Laravel\Server\Adapters\ConfigAdapteris removed.
Full Changelog: 1.1.1...2.0.0
v1.1.1
v1.1.0
This release updates the package for compatibility with php-mcp/server v1.1.0.
What Changed
- Updated dependency requirement to
php-mcp/server: ^1.1.0. - Modified
McpServiceProviderto correctly provideConfigurationRepositoryInterface,LoggerInterface, andCacheInterfacebindings to the underlyingServerinstance when resolved from the Laravel container. - Updated
ServeCommandandMcpControllerto inject theServerinstance and instantiateTransportHandlerclasses according tophp-mcp/serverv1.1.0 constructor changes.
Fixed
- Ensures compatibility with the refactored dependency injection and transport handler instantiation logic in
php-mcp/serverv1.1.0.
Full Changelog: 1.0.0...1.1.0
v1.0.0
Welcome to the first release of php-mcp/laravel! This package provides seamless integration of the core php-mcp/server package with your Laravel application, allowing you to expose application functionality as Model Context Protocol (MCP) tools, resources, and prompts using simple PHP attributes.
Key Features
- Effortless Integration: Automatically wires up Laravel's Cache, Logger, and Service Container for use by the MCP server.
- Attribute-Based Definition: Define MCP tools, resources, and prompts using PHP attributes (
#[McpTool],#[McpResource], etc.) within your Laravel application structure. Leverage Laravel's Dependency Injection within your MCP element classes. - Configuration: Provides a publishable configuration file (
config/mcp.php) for fine-grained control over discovery, transports, caching, and capabilities. - Artisan Commands: Includes commands for element discovery (
mcp:discover), listing discovered elements (mcp:list), and running the server via stdio (mcp:serve). - HTTP+SSE Transport: Sets up routes (
/mcp/message,/mcp/sseby default) and a controller for handling MCP communication over HTTP, enabling browser-based clients and other HTTP consumers. - Automatic Discovery (Dev): Automatically discovers MCP elements in development environments on first use, improving developer experience (no need to manually run
mcp:discoverafter changes). - Manual Discovery (Prod): Requires manual discovery (
mcp:discover) for production environments, ensuring optimal performance via caching (integrates well with deployment workflows). - Event Integration: Dispatches Laravel events (
ToolsListChanged,ResourcesListChanged,PromptsListChanged) when element lists change, allowing for custom integrations or notifications.
Installation
Installation is straightforward using Composer. See the README Installation Guide for full details.
# 1. Require the package
composer require php-mcp/laravel
# 2. Publish the configuration file (optional but recommended)
php artisan vendor:publish --provider="PhpMcp\Laravel\Server\McpServiceProvider" --tag="mcp-config"Getting Started
- Define Elements: Create PHP classes with methods annotated with
#[McpTool],#[McpResource], etc., within directories specified inconfig/mcp.php(e.g.,app/Mcp). Inject dependencies as needed. See Defining MCP Elements. - Discovery:
- In development, discovery runs automatically when needed.
- In production, run
php artisan mcp:discoverduring your deployment process. See Automatic Discovery vs. Manual Discovery.
- Run the Server:
- For Stdio Transport: Use
php artisan mcp:serveand configure your client to execute this command (using the full path toartisan). - For HTTP+SSE Transport: Ensure
transports.http.enabledis true, run your Laravel app on a suitable web server (Nginx+FPM, Octane, etc. - notphp artisan serve), exclude the MCP route from CSRF protection, and configure your client with the SSE URL (e.g.,http://your-app.test/mcp/sse). See Running the Server for critical details.
- For Stdio Transport: Use
Important Notes
- HTTP Transport Server Requirement: The standard
php artisan servedevelopment server is not suitable for the HTTP+SSE transport due to its single-process nature. Use a proper web server setup like Nginx/Apache + PHP-FPM or Laravel Octane. - CSRF Exclusion: If using the default
webmiddleware group for the HTTP transport, you must exclude the MCP message route (default:mcpormcp/*) from CSRF protection in your application to avoid419errors. - Dependencies: Requires PHP >= 8.1 and Laravel >= 10.0.
Links
- GitHub Repository: https://github.com/php-mcp/laravel
- Packagist: https://packagist.org/packages/php-mcp/laravel
Please report any issues or provide feedback on the GitHub repository.