Repository navigation
fix(mcp): a string anyOf/oneOf keeps every branch's enum values - #116
Merged
Merged
Conversation
_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>
This was referenced Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
statusonlistAdCampaigns/getAdTreeisanyOf: [$ref AdStatus, {type: string, enum: [not_deleted]}]. The MCP generator kept only the first branch, so the generatedLiterallackednot_deleted, while the tools' docstrings tell agents to passstatus=not_deleted. FastMCP rejected it before any HTTP call (literal_error), visible in Axiomzernio-mcpaserror_type=ValidationErrorwith nostatus_code(~250+ per tool over Nov 17-19, ~100 users each).Fix
In
_resolve_schema, when every non-null branch istype: 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 twostatusLiterals. The SDK resources already type these params asAny, so no change there.Validation
pytest tests: 3306 passed, 14 skipped; 2 new generator tests (merged enum -> 8 values; open branch ->str).status=not_deletednow reaches the API (401 with dummy key; real data with a real key) on both tools;status=bogusstill rejected.anyOf/oneOfparams: old generator lostnot_deletedon exactly these 2 params; new one loses nothing.🤖 Generated with Claude Code