anomalyco / anomalyco/opencode

Anthropic MCP tools fail when input schema uses root-level anyOf/oneOf/allOf

Open
#47,543 1 comment 0 reactions 1 assignee View on GitHub

@nexxeln is already working on this.

Since Sep 5, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Bug description

Anthropic rejects a tool input_schema that uses anyOf/oneOf/allOf at the root level — these combinators are only accepted nested inside properties. MCP servers commonly emit "exactly one of these fields" patterns (e.g. anyOf: [{required:["route"]}, {required:["file"]}]) as root-level combinators, which then fail Anthropic validation and take the whole tool down with a 400.

OpenCode has an existing OpenAI sanitizer (#32489) but nothing equivalent for the Anthropic family.

Steps to reproduce
  1. Expose an MCP tool whose input_schema contains a root-level anyOf/oneOf/allOf (e.g. the schema in #35516 used anyOf: [{required:["route"]},{required:["file"]}]).
  2. Use it with an Anthropic model (or Copilot proxying Claude, or Vertex Anthropic).
Expected behavior

Tool continues to work; the schema is folded into the root object so Anthropic accepts it.

Actual behavior

The request fails with an Anthropic validation error and the tool is unusable.

Fix

fix(opencode): sanitize MCP tool schemas for Anthropic root combinators (#47542) adds a targeted sanitizer that folds root-level combinators into the root object schema while preserving nested content verbatim.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.