Skip to content

fix: handle boolean MCP schema leaves#2460

Open
pragnyanramtha wants to merge 3 commits into
googleapis:mainfrom
pragnyanramtha:fix/mcp-boolean-additional-properties
Open

fix: handle boolean MCP schema leaves#2460
pragnyanramtha wants to merge 3 commits into
googleapis:mainfrom
pragnyanramtha:fix/mcp-boolean-additional-properties

Conversation

@pragnyanramtha
Copy link
Copy Markdown

Root cause

MCP tool schemas can contain JSON Schema boolean leaves, such as additionalProperties: false. The MCP schema filter recursively processed additionalProperties as though every supported schema value were a mapping, so boolean leaves raised AttributeError: '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: false in an MCP tool input schema.

Validation

  • .venv/bin/python -m pytest google/genai/tests/mcp/test_mcp_to_gemini_tools.py -q -> 11 passed

Note: a full requirements.txt install 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 plus pytest, pytest-asyncio, and mcp.

@pragnyanramtha pragnyanramtha marked this pull request as ready for review May 17, 2026 01:08
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