Skip to content

Error with Gemini models when MCP enabled #5832

Closed

Description

@shettydev

Description

Unable to use opencode with any gemin models. Tried updating the API key multiple times, but that doesn't seem to be the root cause. Since the same API keys are woring in other apps. Not sure what the issue is?

OpenCode version

1.0.174

Steps to reproduce

  1. Enable MCP
  2. Select any Gemini model before starting the conversation

Screenshot and/or share link

Image

This is the error block:

* GenerateContentRequest.tools[0].function_declarations[21].parameters.properties[nodes].items: missing field.
* GenerateContentRequest.tools[0].function_declarations[21].parameters.properties[edges].items: missing field.

Operating System

macOS 26.1

Terminal

Ghostty, Tmux

Activity

  1. github-actions commented on Dec 20, 2025

    @github-actions
    Contributor

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

    Feel free to ignore if none of these address your specific case.

  2. shettydev commented on Dec 20, 2025

    @shettydev
    Author

    Looks like the issue was specific to the MCP configuration. I disabled all my MCPs (which were only 3) from ~/.config/opencode/opencode.json and tried using the Gemini model,s and it worked fine.

    Although I am curious whether there is any fix for this?

  3. changed the title [-]Not working with Gemini models[/-] [+]Error with Gemini models when MCP enabled[/+] on Dec 20, 2025
  4. rekram1-node commented on Dec 20, 2025

    @rekram1-node
    Contributor

    ur mcp server isnt compatible w gemini api, now we do some transforms to make the tools compliant but there is a case we arent handling, what mcp causes this?

  5. shettydev commented on Dec 21, 2025

    @shettydev
    Author

    I found the MCP, which is causing this issue:

    {
      "$schema": "https://opencode.ai/config.json",
      ...
      "mcp": {
        ...
        "basic-memory": { 
          "type": "local",
          "command": ["basic-memory", "mcp"],
          "enabled": true
        }
      }
    }
  6. rekram1-node commented on Dec 21, 2025

    @rekram1-node
    Contributor

    okay ill try to make transform more robust for that case

  7. Molder72 commented on Jan 24, 2026

    @Molder72

    same problem Gemini models with MCP jetbrains rider server not working

  8. added a commit that references this issue on Feb 3, 2026
    e99ca94
  9. mugnimaestra commented on Feb 3, 2026

    @mugnimaestra
    Contributor

    I've opened a PR to address the remaining edge cases for this issue: #11952

    The fix extends #5846 to handle:

    • 2D arrays (array of arrays) where inner array is missing items
    • Arrays with empty items: {} objects that lack a type

    This should resolve the items.items: missing field errors when using Gemini with MCP tools like basic-memory and JetBrains Rider MCP server.

  10. mugnimaestra commented on Feb 3, 2026

    @mugnimaestra
    Contributor

    Follow-up: Additional Fix Required

    Hey everyone, I want to apologize - my initial testing for #11952 wasn't thorough enough and missed an important case.

    What Happened

    The fix in #11952 added nested array handling to sanitizeGemini, but MCP tools were bypassing the schema transformation pipeline entirely. This means MCP tools with 2D arrays (like google-docs-mcp spreadsheet tools, basic-memory, etc.) still failed with Gemini even after #11952 was merged.

    Evidence

    Testing with google-docs-mcp enabled:

    With only #11952 (version 202602031444):

    Error: * GenerateContentRequest.tools[0].function_declarations[49].parameters.properties[values].items.items: missing field.
    

    With the follow-up fix (version 202602031607):

    > build · gemini-3-flash
    
    Hello! How can I help you today?
    

    The Fix

    I've opened #11968 to address this. The fix ensures MCP tools go through ProviderTransform.schema() before registration, so the sanitizeGemini transformation is properly applied.

    Affected MCP Tools

    Any MCP tool with nested array schemas, including:

    • google-docs-mcp: writeSpreadsheet, appendSpreadsheetRows, createSpreadsheet
    • basic-memory (as originally reported)
    • JetBrains Rider MCP server

    Again, sorry for the incomplete fix. #11968 should fully resolve this issue for all MCP tools.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions