Skip to content

Commit 409ad38

Browse files
committed
fix: Fix issue with MCP tools throwing an error.
The error "parameters.properties[segmentation_classes].items: missing field" indicates _to_gemini_schema isn't correctly handling array types.
1 parent 33b2d49 commit 409ad38

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/google/adk/tools/_gemini_schema_util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,16 @@ def _sanitize_schema_type(schema: dict[str, Any]) -> dict[str, Any]:
8989
non_null_type = t
9090
if not non_null_type:
9191
non_null_type = "object"
92+
if non_null_type == "array" and "items" not in schema:
93+
schema["items"] = {"type": "string"}
9294
if nullable:
9395
schema["type"] = [non_null_type, "null"]
9496
else:
9597
schema["type"] = non_null_type
9698
elif schema.get("type") == "null":
9799
schema["type"] = ["object", "null"]
100+
elif schema.get("type") == "array" and "items" not in schema:
101+
schema["items"] = {"type": "string"}
98102

99103
return schema
100104

0 commit comments

Comments
 (0)