googleapis / googleapis/python-genai

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

Open
#2,393 1 comment 0 reactions 1 assignee Claimed by @Venkaiahbabuneelam View on GitHub
priority: p2 type: bug
Dominant language
Python
Stars
4k
Forks
1k
Avg merge
2d 11h
Merged PRs (30d)
40

Description

### Describe the bug
When using an MCP server (specifically via FastMCP) as a tool with the google-genai SDK, the internal utility function _filter_to_supported_schema fails with an AttributeError.

The issue occurs because the function assumes that additionalProperties (or additional_properties) is always a dictionary, whereas the JSON Schema specification allows these fields to be a boolean (e.g., "additionalProperties": false).

### Root Cause
In `google/genai/_mcp_utils.py`, the `_filter_to_supported_schema` function recursively iterates over schema fields. When it encounters `additionalProperties: False`, it passes the boolean value False back into itself.
```python
def _filter_to_supported_schema(schema):
# some code
for field_name, field_value in schema.items(): # Throws AttributeError if schema is a bool
if field_name in schema_field_names:
filtered_schema[field_name] = _filter_to_supported_schema(field_value)
```

Environment details
- Package version: 1.74.0, 1.75.0
- Python version: 3.14
- OS: macOS / Ubuntu 24.04

### Steps to reproduce
- Use the [Gemini Live GenAI Python SDK example](https://github.com/google-gemini/gemini-live-api-examples/blob/main/gemini-live-genai-python-sdk/gemini_live.py).
- Connect a [FastMCP](https://gofastmcp.com/integrations/gemini#call-the-server) server as a tool.
- If the tool's output schema or input parameters include "additionalProperties": false (common in Pydantic-generated schemas used by FastMCP), the SDK crashes.

### Suggested Fix
The function should check if the schema is a dictionary before attempting to call .items(). If it's a boolean, it should be returned as-is or handled appropriately.
```python
def _filter_to_supported_schema(schema):
if not isinstance(schema, dict):
return schema

# ... rest of the logic
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.