Skip to content

fix(mcp): a string anyOf/oneOf keeps every branch's enum values - #116

Merged
Ooscaar merged 1 commit into
developfrom
fix/mcp-anyof-enum-merge
Nov 19, 2026
Merged

Ooscaar merged 1 commit into
developfrom
fix/mcp-anyof-enum-merge

Conversation

@Ooscaar

@Ooscaar Ooscaar commented Nov 19, 2026

Copy link
Copy Markdown
Member

Problem

status on listAdCampaigns / getAdTree is anyOf: [$ref AdStatus, {type: string, enum: [not_deleted]}]. The MCP generator kept only the first branch, so the generated Literal lacked not_deleted, while the tools' docstrings tell agents to pass status=not_deleted. FastMCP rejected it before any HTTP call (literal_error), visible in Axiom zernio-mcp as error_type=ValidationError with no status_code (~250+ per tool over Nov 17-19, ~100 users each).

Fix

In _resolve_schema, when every non-null branch is type: string: merge all branches' enums (deduped, first-seen order); if any branch has no enum, return plain {type: string}. Non-string unions and the [X, null] nullable pattern are unchanged.

Regenerated generated_tools.py: the only diff is "not_deleted" added to those two status Literals. The SDK resources already type these params as Any, so no change there.

Validation

  • pytest tests: 3306 passed, 14 skipped; 2 new generator tests (merged enum -> 8 values; open branch -> str).
  • In-memory FastMCP client: status=not_deleted now reaches the API (401 with dummy key; real data with a real key) on both tools; status=bogus still rejected.
  • Whole-spec scan of string anyOf/oneOf params: old generator lost not_deleted on exactly these 2 params; new one loses nothing.

🤖 Generated with Claude Code

_resolve_schema returned the first string branch of a union, so
`status: anyOf [$ref AdStatus, {enum: [not_deleted]}]` on listAdCampaigns
and getAdTree became a Literal without `not_deleted`. FastMCP rejected the
value the tools' own docs recommend, before any API call (ValidationError
in zernio-mcp logs). String branches now merge their enums; a branch with
no enum makes the param plain str.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant