Skip to content

fix(jsonschema): don't require @id in single-item MCP output schema#8343

Merged
soyuka merged 2 commits into
api-platform:4.3from
alexisLefebvre:fix-mcp-single-item-outputschema-id
Jun 22, 2026
Merged

fix(jsonschema): don't require @id in single-item MCP output schema#8343
soyuka merged 2 commits into
api-platform:4.3from
alexisLefebvre:fix-mcp-single-item-outputschema-id

Conversation

@alexisLefebvre

Copy link
Copy Markdown
Contributor
Q A
Branch? 4.3
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT
Doc PR -

What

For a single-item McpTool/McpResource with structuredContent enabled, the advertised JSON-LD outputSchema no longer marks @id as required. @type stays required; McpToolCollection members keep requiring @id.

Why

A single-item MCP operation has no routed item URI, so Mcp\Routing\IriConverter::getIriFromResource() returns null and the serializer omits @id from the structuredContent. The schema still required @id, so a strict MCP client (validating the payload against the outputSchema from tools/list) rejected the response with /<root>: The required properties (@id) are missing.

The fix mirrors the IriConverter null-@id behaviour on the schema side: Hydra\JsonSchema\SchemaFactory now selects the existing HydraItemBaseSchemaWithoutId base (already used when gen_id is false) for non-collection MCP output schemas. A McpToolCollection is excluded — its members get an IRI because member normalization sets item_uri_template — so the collection case is unaffected.

alexisLefebvre and others added 2 commits June 22, 2026 12:57
IriConverter returns a null IRI for a non-collection McpTool/McpResource,
so the serializer omits @id but the schema still required it — strict MCP
clients rejected the structuredContent. Kept required for
McpToolCollection members, which do get an IRI.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@soyuka soyuka force-pushed the fix-mcp-single-item-outputschema-id branch from f55bb82 to bb1e16b Compare June 22, 2026 13:28
@soyuka soyuka merged commit a5761cc into api-platform:4.3 Jun 22, 2026
108 of 112 checks passed
@alexisLefebvre alexisLefebvre deleted the fix-mcp-single-item-outputschema-id branch June 22, 2026 21:59
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.

2 participants