fix: handle boolean MCP schema leaves#2460
Open
pragnyanramtha wants to merge 3 commits into
Open
Conversation
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.
Root cause
MCP tool schemas can contain JSON Schema boolean leaves, such as
additionalProperties: false. The MCP schema filter recursively processedadditionalPropertiesas though every supported schema value were a mapping, so boolean leaves raisedAttributeError: 'bool' object has no attribute 'items'before conversion.Change
Return non-dict schema leaves unchanged before iterating schema fields. This preserves valid JSON Schema boolean leaves through filtering so the downstream Schema conversion can handle or ignore them according to its supported surface.
Added a focused regression test covering top-level and nested
additionalProperties: falsein an MCP tool input schema.Validation
.venv/bin/python -m pytest google/genai/tests/mcp/test_mcp_to_gemini_tools.py -q-> 11 passedNote: a full
requirements.txtinstall was not run to completion in this Python 3.14 environment because Pillow 11.0.0 attempted a source build and failed due missing JPEG headers. The relevant MCP test file was run with a minimal editable install pluspytest,pytest-asyncio, andmcp.