fix(mcp): support mcp/sdk 0.6 ResourceDefinition in Loader#8302
Merged
Conversation
mcp/sdk 0.6 renamed Mcp\Schema\Resource to Mcp\Schema\ResourceDefinition. Resolve the class at runtime via class_exists so the Loader works on both 0.5 and 0.6, since symfony/mcp-bundle still pins ^0.5 and forces 0.5 to be installed. The composer constraint (>=0.4 <1.0) already permits 0.6. The trailing $isManual argument is kept: 0.6 dropped it from the signature but PHP silently ignores the extra positional argument, while 0.5 still honors it.
…a class PHPStan analyzes against the installed mcp/sdk (0.5), where Mcp\Schema\ResourceDefinition does not exist; under 0.6 it is Mcp\Schema\Resource that is absent. The Loader resolves the correct class at runtime, so scope a class.notFound ignore to that file, matching the project's existing convention for transitional types.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
mcp/sdk0.6 renamedMcp\Schema\ResourcetoMcp\Schema\ResourceDefinition. The MCPLoaderinstantiatedMcp\Schema\Resourcedirectly, so it fatals on 0.6 (class not found).This resolves the class at runtime via
class_exists, so theLoaderworks on both 0.5 and 0.6.The composer constraint (
mcp/sdk: >=0.4 <1.0) already permits 0.6 — no constraint change needed. Dual support is required becausesymfony/mcp-bundlestill pinsmcp/sdk: ^0.5, which forces 0.5 to be installed in the current stack.Details
src/Mcp/Capability/Registry/Loader.phpis the only file inapi-platform/mcptouching renamed 0.6 API. Everything else (Handler,StructuredContentProcessor—JsonRpc\*,CallToolResult,ReadResourceResult,TextContent,Tool,Annotations) is unchanged between 0.5 and 0.6.The trailing
$isManualargument onregisterResource/registerToolis kept: 0.6 dropped it from the signature, but PHP silently ignores the extra positional argument on a userland method, while 0.5 still honors it.ToolandResourceDefinitionconstructors take the same named arguments as their 0.5 counterparts, so no other change is needed.Tests
Existing
LoaderTestpasses (asserts resource properties, not the class type, so it is robust to either class). The 0.6 branch can't be exercised in CI untilsymfony/mcp-bundledrops its^0.5pin — verified against the 0.6 source by inspection.