From 6f876173b1f7b1092a53e442150f568d84e25c03 Mon Sep 17 00:00:00 2001 From: Mahesh Sadupalli Date: Sat, 16 May 2026 21:33:25 +0200 Subject: [PATCH] fix: handle boolean additionalProperties in _filter_to_supported_schema Add type check to return non-dict values (like booleans) as-is. Fixes AttributeError when MCP tools have 'additionalProperties: false' in their schema, common in Pydantic-generated schemas used by FastMCP. Fixes #2393 --- google/genai/_mcp_utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/google/genai/_mcp_utils.py b/google/genai/_mcp_utils.py index 3d4ae2a17..58d8b3645 100644 --- a/google/genai/_mcp_utils.py +++ b/google/genai/_mcp_utils.py @@ -127,6 +127,9 @@ def _filter_to_supported_schema( schema: _common.StringDict, ) -> _common.StringDict: """Filters the schema to only include fields that are supported by JSONSchema.""" + if not isinstance(schema, dict): + return schema + supported_fields: set[str] = set(types.JSONSchema.model_fields.keys()) supported_fields.update([