Skip to content

[Mcp] Properly handle oneOf and anyOf in generated mcp schema so that JSONLD output is actually valid#7962

Merged
soyuka merged 2 commits intoapi-platform:4.3from
jbtronics:fix-invalid-schema
May 11, 2026
Merged

[Mcp] Properly handle oneOf and anyOf in generated mcp schema so that JSONLD output is actually valid#7962
soyuka merged 2 commits intoapi-platform:4.3from
jbtronics:fix-invalid-schema

Conversation

@jbtronics
Copy link
Copy Markdown

Q A
Branch? 4.3 (bugfix)
Tickets None
License MIT
Doc PR Bugfix

So far, the generated output schemas for Mcp does not handle oneOf and anyOf correctly. The JSONLD @context property which can either bei "string" or "object" gets flattended to "object" only, and the schema validation will fail on outputs where the @context is a string (which seems to be the default). Breaking tool use on validating software like Claude Desktop.

This PR fixed this issue.

@soyuka soyuka force-pushed the fix-invalid-schema branch from 9ffc5c0 to 953c992 Compare May 11, 2026 05:56
| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Tickets       | ∅
| License       | MIT
| Doc PR        | ∅

Regression coverage for SchemaFactory: oneOf/anyOf nodes must not get a
`type: object` fallback injected, otherwise Hydra's @context union is
broken in the generated MCP schema.
@soyuka soyuka merged commit 1721a73 into api-platform:4.3 May 11, 2026
114 of 118 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.

2 participants