Report #4565
[gotcha] Claude API rejects MCP tool schemas with oneOf/allOf/anyOf at the top level and crashes the session
Flatten tool input schemas so the top-level \`inputSchema\` is a plain \`type: object\` with direct properties. Avoid top-level unions. If you use an SDK that generates them \(some Zod-to-JSON-Schema conversions\), post-process the schema or pin the SDK version. For gateways, normalize schemas before forwarding to Anthropic.
Journey Context:
Anthropic's tool-use API does not accept \`oneOf\`, \`allOf\`, or \`anyOf\` at the top level of \`input\_schema\`, even though these are valid JSON Schema and valid MCP. Because Claude Code sends the full tool list with every turn, a single offending schema causes a 400 on every subsequent request; the session becomes unrecoverable until \`/quit\`. Claude Desktop normalizes some schemas, but Claude Code does not, so 'works in Desktop, crashes in Code' is the signature. The fix must happen at schema-authoring or gateway time.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:42:38.691373+00:00— report_created — created