claude-code - 💡(How to fix) Fix [BUG] MCP tools with oneOf/allOf/anyOf in schema cause unrecoverable session crash [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45106Fetched 2026-04-09 08:13:08
View on GitHub
Comments
2
Participants
2
Timeline
7
Reactions
0
Timeline (top)
labeled ×4commented ×2unlabeled ×1

Error Message

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"tools.11.custom.input_schema: input_schema does not support oneOf, allOf, or anyOf at the top level"},"request_id":"req_011CZr1kf8NdxBHLJYyB5cTT"}

This error repeats on every subsequent API call (tool use, agent spawn, even plain messages) until the session is quit.

Root Cause

When a third-party MCP server exposes a tool whose inputSchema contains oneOf, allOf, or anyOf at the top level, the Claude API rejects the request. Because Claude Code sends the full tool list with every API call, the error repeats on every subsequent request, making the session completely unrecoverable. Only /quit works.

Fix Action

Fix / Workaround

Related to #43916 (built-in tool schemas), but this is the MCP-specific variant: Claude Code passes MCP tool schemas through to the API unmodified, with no validation or normalization. Unlike built-in tool issues, this can't be fixed by updating Claude Code's tool bundle.

Workaround: A stdio proxy script between Claude Code and the MCP binary that intercepts tools/list responses and strips anyOf/oneOf/allOf, replacing with a flattened equivalent (e.g., "required": ["id"]).

Code Example

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"tools.11.custom.input_schema: input_schema does not support oneOf, allOf, or anyOf at the top level"},"request_id":"req_011CZr1kf8NdxBHLJYyB5cTT"}


This error repeats on every subsequent API call (tool use, agent spawn, even plain messages) until the session is quit.

---

"inputSchema": {
     "anyOf": [
       {"required": ["id", "title"]},
       {"required": ["id", "when"]}
     ],
     "properties": {
       "id": {"type": "string"},
       "title": {"type": "string"},
       "when": {"type": "string"}
     },
     "type": "object"
   }
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

When a third-party MCP server exposes a tool whose inputSchema contains oneOf, allOf, or anyOf at the top level, the Claude API rejects the request. Because Claude Code sends the full tool list with every API call, the error repeats on every subsequent request, making the session completely unrecoverable. Only /quit works.

Related to #43916 (built-in tool schemas), but this is the MCP-specific variant: Claude Code passes MCP tool schemas through to the API unmodified, with no validation or normalization. Unlike built-in tool issues, this can't be fixed by updating Claude Code's tool bundle.

Claude Desktop handles the same MCP server without issue, suggesting it normalizes schemas before sending them to the API.

What Should Happen?

Claude Code should either:

  • Normalize incompatible JSON Schema keywords (oneOf/allOf/anyOf) in MCP tool schemas before sending them to the API (as Claude Desktop appears to do)
  • Or catch the API validation error per-tool, disable the offending tool, and warn the user

The session should never become unrecoverable due to a single tool's schema.

Error Messages/Logs

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"tools.11.custom.input_schema: input_schema does not support oneOf, allOf, or anyOf at the top level"},"request_id":"req_011CZr1kf8NdxBHLJYyB5cTT"}


This error repeats on every subsequent API call (tool use, agent spawn, even plain messages) until the session is quit.

Steps to Reproduce

  1. Install an MCP server whose tool schema uses anyOf at the top level. The Fantastical MCP connector (v1.1.0) is one example. Its modifyCalendarItem tool has:
    "inputSchema": {
      "anyOf": [
        {"required": ["id", "title"]},
        {"required": ["id", "when"]}
      ],
      "properties": {
        "id": {"type": "string"},
        "title": {"type": "string"},
        "when": {"type": "string"}
      },
      "type": "object"
    }
  2. Start a Claude Code session
  3. Trigger loading of the MCP tool (e.g., via ToolSearch or by asking Claude to use it)
  4. Every API call from that point forward fails with the 400 error above
  5. No recovery is possible without /quit

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.96 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

Workaround: A stdio proxy script between Claude Code and the MCP binary that intercepts tools/list responses and strips anyOf/oneOf/allOf, replacing with a flattened equivalent (e.g., "required": ["id"]).

Why this is distinct from #43916: That issue covers Claude Code's own built-in tools shipping invalid schemas. This issue is about Claude Code lacking resilience to third-party MCP servers that use valid JSON Schema features the Claude API doesn't support. The fix path is different: schema normalization or graceful degradation for MCP-sourced tools, not just fixing one built-in tool definition.

extent analysis

TL;DR

Normalize incompatible JSON Schema keywords in MCP tool schemas before sending them to the API to prevent session crashes.

Guidance

  • Identify the MCP server's tool schema that contains oneOf, allOf, or anyOf at the top level and modify it to be compatible with the Claude API.
  • Consider implementing a schema normalization step in Claude Code to handle third-party MCP servers that use valid JSON Schema features the Claude API doesn't support.
  • Use a stdio proxy script as a temporary workaround to intercept tools/list responses and strip anyOf/oneOf/allOf, replacing with a flattened equivalent.
  • Catch the API validation error per-tool and disable the offending tool to prevent session crashes.
  • Warn the user when a tool is disabled due to an incompatible schema.

Example

// Before normalization
"inputSchema": {
  "anyOf": [
    {"required": ["id", "title"]},
    {"required": ["id", "when"]}
  ],
  "properties": {
    "id": {"type": "string"},
    "title": {"type": "string"},
    "when": {"type": "string"}
  },
  "type": "object"
}

// After normalization (flattened equivalent)
"inputSchema": {
  "required": ["id"],
  "properties": {
    "id": {"type": "string"},
    "title": {"type": "string"},
    "when": {"type": "string"}
  },
  "type": "object"
}

Notes

The provided workaround using a stdio proxy script may not be suitable for all users, and a more robust solution would be to implement schema normalization in Claude Code.

Recommendation

Apply the workaround using a stdio proxy script until a more permanent solution can be implemented in Claude Code to normalize incompatible JSON Schema keywords.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING