-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Description
Description
When using MCP servers (e.g., Notion MCP) with Gemini models, the API returns a 400 error because some tool schemas have properties or required fields on non-object types.
Error Message
Bad Request: {
"error": {
"code": 400,
"message": "* GenerateContentRequest.tools[0].function_declarations[80].parameters.properties[data].properties: only allowed for OBJECT type
* GenerateContentRequest.tools[0].function_declarations[80].parameters.properties[data].required: only allowed for OBJECT type",
"status": "INVALID_ARGUMENT"
}
}
Steps to Reproduce
- Enable Notion MCP (or other MCP servers with similar schema patterns)
- Use a Gemini model (e.g., gemini-3-flash-preview)
- Send any message
- Error occurs on requests with larger tool sets
Expected Behavior
Tool schemas should be sanitized to remove properties and required from non-object types before sending to Gemini API.
Current Behavior
The sanitizeGemini function in transform.ts handles enum conversion and required field filtering, but doesn't strip properties/required from non-object types.
Proposed Solution
Add to sanitizeGemini:
if (result.type && result.type !== "object") {
delete result.properties
delete result.required
}Related Issues
- Similar to AI_APICallError: GenerateContentRequest.tools[0].function_declarations[32].parameters. required[0]: property is not defined with Gemini API #3140, Schema validation error with Google/Gemini models #8036
Environment
- opencode version: latest
- MCP: Notion MCP
- Model: gemini-3-flash-preview
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels