Skip to content

fix(mcp): support mcp/sdk 0.6 ResourceDefinition in Loader#8302

Merged
soyuka merged 2 commits into
api-platform:4.3from
soyuka:fix/mcp-sdk-0.6-compat
Jun 15, 2026
Merged

fix(mcp): support mcp/sdk 0.6 ResourceDefinition in Loader#8302
soyuka merged 2 commits into
api-platform:4.3from
soyuka:fix/mcp-sdk-0.6-compat

Conversation

@soyuka

@soyuka soyuka commented Jun 15, 2026

Copy link
Copy Markdown
Member

Summary

mcp/sdk 0.6 renamed Mcp\Schema\Resource to Mcp\Schema\ResourceDefinition. The MCP Loader instantiated Mcp\Schema\Resource directly, so it fatals on 0.6 (class not found).

This resolves the class at runtime via class_exists, so the Loader works 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 because symfony/mcp-bundle still pins mcp/sdk: ^0.5, which forces 0.5 to be installed in the current stack.

Details

src/Mcp/Capability/Registry/Loader.php is the only file in api-platform/mcp touching renamed 0.6 API. Everything else (Handler, StructuredContentProcessorJsonRpc\*, CallToolResult, ReadResourceResult, TextContent, Tool, Annotations) is unchanged between 0.5 and 0.6.

The trailing $isManual argument on registerResource/registerTool is 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.

Tool and ResourceDefinition constructors take the same named arguments as their 0.5 counterparts, so no other change is needed.

Tests

Existing LoaderTest passes (asserts resource properties, not the class type, so it is robust to either class). The 0.6 branch can't be exercised in CI until symfony/mcp-bundle drops its ^0.5 pin — verified against the 0.6 source by inspection.

soyuka added 2 commits June 15, 2026 14:31
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.
@soyuka soyuka merged commit 8e5a9da into api-platform:4.3 Jun 15, 2026
112 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant