Skip to content

fix: handle boolean MCP schema leaves#2563

Open
he-yufeng wants to merge 1 commit into
googleapis:mainfrom
he-yufeng:fix/mcp-boolean-additional-properties
Open

fix: handle boolean MCP schema leaves#2563
he-yufeng wants to merge 1 commit into
googleapis:mainfrom
he-yufeng:fix/mcp-boolean-additional-properties

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Fixes #2393.

_filter_to_supported_schema() recursively filters MCP JSON Schema input before converting it to a Gemini tool declaration. JSON Schema allows boolean values for additionalProperties, and FastMCP/Pydantic schemas commonly emit additionalProperties: false. The current recursion assumes every nested schema value is a dict and calls .items(), so those valid schemas crash with AttributeError: 'bool' object has no attribute 'items'.

This keeps scalar schema leaves as-is before recursing into dictionaries, then adds MCP conversion coverage for a nested object with additionalProperties: false.

To verify

  • UNITTEST_ON_FORGE=1 python -m pytest google/genai/tests/mcp/test_mcp_to_gemini_tools.py -q
  • python -m py_compile google/genai/_mcp_utils.py google/genai/tests/mcp/test_mcp_to_gemini_tools.py

@Venkaiahbabuneelam Venkaiahbabuneelam self-assigned this Jun 8, 2026
@Venkaiahbabuneelam Venkaiahbabuneelam added the size:M Code changes between 10-40 lines label Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M Code changes between 10-40 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'bool' object has no attribute 'items' in _mcp_utils.py when using FastMCP tools

2 participants