fix(mcp): fold non-string enums into descriptions for tools/list - #39
Merged
KristofersOzolinsMagebit merged 1 commit intoAug 19, 2026
Merged
Conversation
KristofersOzolinsMagebit
deleted the
fix/gemini-non-string-enum-schemas
branch
August 31, 2026 16:01
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
Gemini errors out on every message when this MCP server is connected. Google validates every advertised tool schema on each request and rejected two of ours:
Nothing is actually missing from our schemas. Google's function-declaration schema only accepts
enumwhen the values are strings, and we emit integer ones (status,visibility,backorders, source-itemstatus). When Google meets a numeric enum it discards the whole surroundingpropertiesmap, andrequiredis then left naming properties it can no longer see — hence the misleading error.Our schemas are correct: the MCP spec defines
inputSchemaas plain JSON Schema with no keyword subset, and draft-07 says enum elements "might be of any value". This is a Gemini limitation, but we're the ones getting the ticket, so the accommodation goes here. Claude and OpenAI ignore it, which is why it only ever showed up on Gemini.Change
Split the two uses of
SchemaSanitizer, because they are not the same job:sanitize()— unchanged. Used byToolsCallHandlerto validate incoming arguments, so it keeps the integer enums and validation stays strict.sanitizeForClient()— new. Used only byToolsListHandlerfor what we advertise. Drops anyenumholding non-string values and folds the allowed values into the property description.The split matters:
ToolsCallHandlervalidates against the sanitized schema, so folding the enum in one shared method would have silently dropped server-side enum validation as a side effect. The advertised schema is now looser than the validation schema, which is the safe direction.The fold only fires on a JSON list, so a tool with a property literally named
enumis not mangled. There is a test pinning that.Verification
tools/list: 146 tools, 0 non-string enums, 0 orphanrequired.catalog_product_stock_setwithbackorders: 9returns-32014 "The data should match one item from enum", whilebackorders: 1passes schema and fails on the SKU. Used a non-existent SKU so nothing could be written.Also fixes two latent cases in
McpInventoryTools(inventory_source_item_set,inventory_stock_item_configuration_set) that would have failed the same way once that module met a Gemini client.Pairs with magebitcom/magento2-mcp-catalog-tools — that side adds the value meanings to
status/visibility, which had no description to fall back on once the enum was dropped.🤖 Generated with Claude Code