Skip to content

fix(provider): drop top-level schema composition for Anthropic MCP tools - #39826

Open
vrutkovs wants to merge 1 commit into
anomalyco:devfrom
vrutkovs:anthropic-mcp-schema-sanitize
Open

fix(provider): drop top-level schema composition for Anthropic MCP tools#39826
vrutkovs wants to merge 1 commit into
anomalyco:devfrom
vrutkovs:anthropic-mcp-schema-sanitize

Conversation

@vrutkovs

Copy link
Copy Markdown

Issue for this PR

Closes #37916

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Applies the same approach as in #32489 to Anthropic models.

How did you verify your code works?

  • bun test test/provider/transform.test.ts --timeout 30000
  • bun run typecheck
  • Push hook also ran bun turbo typecheck successfully
  • Manual verification via nix install

Screenshots / recordings

Non-UI change

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@TomasEkeli

TomasEkeli commented Aug 5, 2026

Copy link
Copy Markdown

Dropping the keywords fixes the API error but leaves some tools undocumented to the model. The real-world case that led me here is the hosted Notion MCP, whose notion-create-attachment tool has a pure top-level anyOf: three branches and no top-level properties at all (makenotion/notion-mcp-server#340). After the drop the model sees {"type": "object"} and has to guess every argument.

Suggestion: merge the branches instead of dropping them.

  • properties: union across branches (first definition wins on collision)
  • required: intersection for anyOf/oneOf, union for allOf
  • append the valid combinations to the description, e.g. Exactly one of these parameter combinations must be provided: filename + content; or filename + source_url; or source_file_id.

I run this as a local sanitizing proxy today and the merged schema works well with Anthropic models; the description line is enough for the model to pick a valid branch. I can send the merge logic as a follow-up if this PR wants to stay minimal.

@vrutkovs

vrutkovs commented Aug 5, 2026

Copy link
Copy Markdown
Author

merge the branches instead of dropping them

Iiuc this needs to be applied to every provider as well? That would be a change of scope in this PR, so I'd prefer this to be implemented in a separate PR

@TomasEkeli

Copy link
Copy Markdown

Totally valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Anthropic models error Input_schema does not support oneOf, allOf, or anyOf at the top level

2 participants