Skip to content

[bug] Gemini API rejects MCP tool schemas with properties/required on non-object types #11889

Closed

Description

@fwkyle

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

  1. Enable Notion MCP (or other MCP servers with similar schema patterns)
  2. Use a Gemini model (e.g., gemini-3-flash-preview)
  3. Send any message
  4. 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

Environment

  • opencode version: latest
  • MCP: Notion MCP
  • Model: gemini-3-flash-preview

Activity

  1. github-actions commented on Feb 3, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    These issues all relate to the same root cause: Gemini API's strict validation that only allows properties and required fields on OBJECT type parameters.

    Feel free to ignore if your specific case differs from these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions