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
@he-yufeng he-yufeng force-pushed the fix/mcp-boolean-additional-properties branch from da0766d to 08ceb27 Compare June 12, 2026 11:45
@he-yufeng

Copy link
Copy Markdown
Contributor Author

Rebased this branch onto current main and pushed the updated head 08ceb27.

Validation:

  • python -m pytest google\genai\tests\mcp\test_mcp_to_gemini_tools.py -q -k "boolean or additional" -> passed, 1 passed
  • python -m py_compile google\genai\_mcp_utils.py google\genai\tests\mcp\test_mcp_to_gemini_tools.py -> passed
  • git diff --check upstream/main..HEAD -> passed

@he-yufeng he-yufeng force-pushed the fix/mcp-boolean-additional-properties branch from 08ceb27 to 9b83860 Compare June 12, 2026 14:10
@he-yufeng he-yufeng force-pushed the fix/mcp-boolean-additional-properties branch from 9b83860 to 9dd5f50 Compare June 12, 2026 16:23
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