Skip to content

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

@aturkenov

Description

@aturkenov

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.

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.
  • Connect a FastMCP 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.

def _filter_to_supported_schema(schema):
    if not isinstance(schema, dict):
        return schema
    
    # ... rest of the logic

Metadata

Metadata

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions