MCP tool input validation error: Invalid input: Should pass single schema with invalid_union #15115
Unanswered
DudeFactory
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Updated:
While investigating MCP validation issues, we identified limitations in json-schema-to-zod when converting complex JSON Schema structures (notably oneOf with $ref, as used by Payload CMS blocks). The generated Zod unions rely on strict “exactly one schema must match” logic, which becomes problematic when fallback or unconstrained branches are involved, causing valid inputs to fail validation before reaching application logic.
The library appears largely unmaintained relative to modern schema use cases (e.g. CMS block systems, discriminated unions, localized fields). This suggests that either targeted contributions are needed to support these patterns properly, or that a new, CMS-aware JSON Schema → runtime validation approach should be developed.
For now I just patch it for specific collection, specific field (layout):
When using MCP tools (createPages - autogenerated) with Payload CMS, tool execution can fail with the following error:
Request:
Schema for page collection, layout - is broken for MCP:
Observed Behavior
The tool is registered successfully and appears available to the MCP client.
The error occurs only when the tool is invoked.
The validation failure happens before any tool logic runs.
Error messages reference union validation and “single schema” requirements.
With complex inputs (e.g. Payload type 'blocks')
Environment
Payload CMS: 3.70.0
@payloadcms/plugin-mcp: 3.70.0
@modelcontextprotocol/sdk: 1.24.x
Node.js: 22.x
Runtime: Next.js (Node runtime)
Beta Was this translation helpful? Give feedback.
All reactions