Refactor: Align with php-mcp/server v2.x and Enhance Laravel DX #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a comprehensive overhaul to achieve full compatibility with
php-mcp/serverv2.x.x+ and significantly enhance the developer experience for Laravel users.Key Goals Achieved:
php-mcp/serverv2.xServerBuilder, explicit discovery mechanisms, clear transport separation, and the newConfigurationvalue object.McpFacade and a dedicated definitions file (e.g.,routes/mcp.php), similar to defining Laravel routes.config/mcp.php.mcp:serveArtisan command now clearly supportsstdioand a dedicatedhttp(ReactPHP-based) transport, with CLI options for configuration.McpController) has been re-architected to correctly use a customLaravelHttpTransportthat bridges with the core MCPProtocolhandler.mcp:discovercommand provides explicit control over discovery and caching. Manual registrations always take precedence.PhpMcp\Laravelfor better clarity and convention.Major Changes Include:
McpServiceProvider: Rebuilt to useServerBuilderfor\PhpMcp\Server\Serverinstantiation, correctly wiring all Laravel dependencies and applying configurations. Implements configurable auto-discovery.McpRegistrar&BluePrintObjects: Power the new fluent facade API for manual registrations.config/mcp.php: New structure, new keys for dedicated HTTP transport, simplified cache and discovery settings.mcp:discover,mcp:list,mcp:serve): Refactored to interact with the newServerinstance and core transport implementations.mcp:servenow offers an interactive prompt for transport selection.LaravelHttpTransport&McpController: Reworked for correct interaction with the coreProtocolwhen serving MCP via integrated Laravel routes. The controller now drives events on the custom transport.McpNotificationListenerto queue MCP notifications.This refactor addresses previous architectural limitations and aims to make
php-mcp/laravelthe definitive way to build MCP-enabled Laravel applications.BREAKING CHANGES: (To be detailed in Release Notes)
PhpMcp\Laravel\ServertoPhpMcp\Laravel.config/mcp.phpstructure and keys.ConfigAdapteris removed.Serveris built and configured have changed; direct manipulation of old internal classes will break.mcp:servecommand's behavior for HTTP transport now launches a dedicated server by default (use integrated routes for embedded functionality).