claude-code - 💡(How to fix) Fix [BUG] Cowork/Desktop: MCP tool inputSchema with property-level anyOf [X, null] (Optional[X]) is silently stripped before reaching the model [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#56263Fetched 2026-05-06 06:32:49
View on GitHub
Comments
2
Participants
2
Timeline
9
Reactions
0
Author
Timeline (top)
labeled ×5commented ×2mentioned ×1subscribed ×1

Error Message

Error Messages/Logs

Code Example



---

"keywords": {
  "anyOf": [
    {"items": {"type": "string"}, "type": "array"},
    {"type": "null"}
  ],
  "default": null,
  "description": "Seed keywords..."
}

---

{
  "default": null,
  "description": "Seed keywords..."
}

---

Invalid arguments for tool 'generate_keyword_ideas':
  keywords: Input should be a valid list
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 an MCP tool's inputSchema contains a parameter with anyOf [X, null] shape — the standard output for Python Optional[X] generated by FastMCP — Claude desktop strips the anyOf block, leaving only default and description. The LLM sees no type info and serializes arguments inconsistently. In particular, Optional[list[str]] parameters end up serialized as stringified JSON ('["a","b"]'), which servers then reject with "expected list, got str".

Affected: Claude desktop, both Code tab and Cowork tab (verified 2026-05-05). Not affected: Claude Code CLI (preserves full schema).

What Should Happen?

Claude desktop should pass the full inputSchema to the LLM, including any anyOf blocks. The current stripping breaks any MCP tool that uses Optional[X] Python parameters — i.e. virtually every FastMCP-generated tool with optional list/dict/object inputs.

Error Messages/Logs

Steps to Reproduce

MCP server: FastMCP 3.2.4 + Pydantic 2.x, streamable-HTTP transport. Server-side raw tools/list response (verified via curl):

"keywords": {
  "anyOf": [
    {"items": {"type": "string"}, "type": "array"},
    {"type": "null"}
  ],
  "default": null,
  "description": "Seed keywords..."
}

In Claude desktop Code tab and Cowork tab, asking Claude to dump the raw schema for the same parameter returns:

{
  "default": null,
  "description": "Seed keywords..."
}

anyOf, type, items are gone. The same prompt in Claude Code CLI returns the full anyOf block intact.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.128 (Claude Code) / Claude 1.5354.0 (9a9e3d)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Symptom in Cowork tab Calling the tool with keywords=["judo gi", "bjj gi", "karate gi"] causes the LLM to serialize the parameter as one stringified JSON value ('["judo gi", "bjj gi", "karate gi"]'), and the server-side pydantic validator rejects with:

Invalid arguments for tool 'generate_keyword_ideas':
  keywords: Input should be a valid list

The same call in Claude Code CLI works (LLM sees type: array, sends array). In Claude desktop Code tab, the LLM happens to infer "array" from the description's example, but that is non-deterministic — different model runs or different examples in description will trip this.

Counter-evidence — narrowing the bug location I ran the same tools/list request through three layers and inspected the schema at each step:

  1. Server (FastMCP): raw tools/list response over HTTP contains the full anyOf (verified via curl).
  2. mcp-remote proxy: the stdio adapter that Claude desktop uses to bridge HTTP MCP servers preserves the full anyOf intact (verified by piping JSON-RPC to npx mcp-remote and inspecting its stdout — schema passes through unchanged).
  3. Claude Code CLI: connects directly to the HTTP server (no proxy). LLM sees the full anyOf; tool calls succeed.
  4. Claude desktop (Code tab and Cowork tab): uses mcp-remote as a stdio bridge. LLM sees only {default, description}. anyOf is gone.

Therefore the stripping happens inside the desktop client, after mcp-remote hands the schema over via stdio and before the schema reaches the model context. mcp-remote and the MCP server are not at fault.

Environment Claude desktop on macOS, build Claude 1.5354.0 (9a9e3d), 2026-04-29T01:14:34.000Z Reproduced: 2026-05-05 MCP transport: streamable-HTTP Server: FastMCP 3.2.4 + Pydantic 2.x Same server tested from Claude Code CLI: full schema preserved (control group)

extent analysis

TL;DR

The issue can be fixed by modifying the Claude desktop client to preserve the anyOf block in the input schema, ensuring that the LLM receives the full schema and serializes arguments correctly.

Guidance

  • Investigate the Claude desktop client's schema processing code to identify where the anyOf block is being stripped.
  • Verify that the mcp-remote proxy is correctly passing the full schema to the Claude desktop client.
  • Consider adding logging or debugging statements to the Claude desktop client to inspect the schema at different points in the processing pipeline.
  • Test potential fixes using the provided reproduction steps and verify that the LLM receives the correct schema and serializes arguments as expected.

Example

No code snippet is provided as the issue does not contain sufficient information about the specific code implementation.

Notes

The issue appears to be specific to the Claude desktop client and does not affect the Claude Code CLI. The mcp-remote proxy and the MCP server have been ruled out as the cause of the issue.

Recommendation

Apply a workaround to modify the Claude desktop client to preserve the anyOf block in the input schema, as the root cause of the issue is likely a bug in the client's schema processing code.

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

claude-code - 💡(How to fix) Fix [BUG] Cowork/Desktop: MCP tool inputSchema with property-level anyOf [X, null] (Optional[X]) is silently stripped before reaching the model [2 comments, 2 participants]