openclaw - 💡(How to fix) Fix MCP server anyOf schemas rejected by DeepSeek - should strip at gateway level

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…

MCP servers that expose tool schemas with anyOf/oneOf keywords (e.g. Unusual Whales) cause all LLM requests to fail with 400 Invalid schema when the provider is DeepSeek. The gateway registers tools natively without stripping anyOf, and DeepSeek rejects them.

Error Message

400 Invalid schema for function 'unusual-whales__get_balance_sheet_screener': "date" is not valid under any of the schemas listed in the 'anyOf' keyword

Root Cause

The Unusual Whales MCP server exposes optional fields as anyOf unions (e.g. "date": {"anyOf": [{"type": "string"}, {"type": "integer"}]}). This is valid JSON Schema and accepted by Anthropic/OpenAI, but DeepSeek's API rejects schemas with anyOf/oneOf at the tool schema level.

The userland workaround is a strip_nullable_unions() function that collapses anyOf: [T, "null"] to {type: T, nullable: true}, but this only works if it runs in the agent process before schemas reach the LLM. The gateway registers MCP tools natively and sends raw schemas to the provider.

Fix Action

Fix / Workaround

The userland workaround is a strip_nullable_unions() function that collapses anyOf: [T, "null"] to {type: T, nullable: true}, but this only works if it runs in the agent process before schemas reach the LLM. The gateway registers MCP tools natively and sends raw schemas to the provider.

Code Example

400 Invalid schema for function 'unusual-whales__get_balance_sheet_screener': "date" is not valid under any of the schemas listed in the 'anyOf' keyword

---

{
  "error": "LLM request failed: provider rejected the request schema or tool payload.",
  "failoverReason": "format",
  "model": "deepseek-v4-pro",
  "provider": "deepseek",
  "rawErrorPreview": "400 Invalid schema for function 'unusual-whales__get_balance_sheet_screener': 'date' is not valid under any of the schemas listed in the 'anyOf' keyword",
  "providerRuntimeFailureKind": "schema"
}
RAW_BUFFERClick to expand / collapse

Summary

MCP servers that expose tool schemas with anyOf/oneOf keywords (e.g. Unusual Whales) cause all LLM requests to fail with 400 Invalid schema when the provider is DeepSeek. The gateway registers tools natively without stripping anyOf, and DeepSeek rejects them.

Error

400 Invalid schema for function 'unusual-whales__get_balance_sheet_screener': "date" is not valid under any of the schemas listed in the 'anyOf' keyword

Full gateway log entry

{
  "error": "LLM request failed: provider rejected the request schema or tool payload.",
  "failoverReason": "format",
  "model": "deepseek-v4-pro",
  "provider": "deepseek",
  "rawErrorPreview": "400 Invalid schema for function 'unusual-whales__get_balance_sheet_screener': 'date' is not valid under any of the schemas listed in the 'anyOf' keyword",
  "providerRuntimeFailureKind": "schema"
}

Happens in any session/context that has UW MCP tools registered -- cron jobs, direct chat, sub-agent runs. 48/48 crons affected.

Root Cause

The Unusual Whales MCP server exposes optional fields as anyOf unions (e.g. "date": {"anyOf": [{"type": "string"}, {"type": "integer"}]}). This is valid JSON Schema and accepted by Anthropic/OpenAI, but DeepSeek's API rejects schemas with anyOf/oneOf at the tool schema level.

The userland workaround is a strip_nullable_unions() function that collapses anyOf: [T, "null"] to {type: T, nullable: true}, but this only works if it runs in the agent process before schemas reach the LLM. The gateway registers MCP tools natively and sends raw schemas to the provider.

Proposed Fix

Add a lightweight schema sanitization step when registering MCP tools at the gateway level:

  1. Walk all tool schemas for anyOf/oneOf keywords at registration time
  2. Collapse nullable unions (anyOf: [T, "null"] -> {type: T, nullable: true})
  3. For multi-branch anyOf (e.g. date as string|integer), collapse to first non-null variant
  4. This is safe because MCP tool handlers re-validate arguments server-side

Environment

  • OpenClaw 2026.5.12-beta.6 (c4292e0)
  • DeepSeek v4 Flash + Pro providers
  • Node v22.22.2
  • Linux arm64

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

openclaw - 💡(How to fix) Fix MCP server anyOf schemas rejected by DeepSeek - should strip at gateway level