Error with Gemini models when MCP enabled #3685

Closed
opened 2026-02-16 17:41:06 -05:00 by yindo · 8 comments
Owner

Originally created by @shettydev on GitHub (Dec 20, 2025).

Originally assigned to: @rekram1-node on GitHub.

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

Originally created by @shettydev on GitHub (Dec 20, 2025). Originally assigned to: @rekram1-node on GitHub. ### 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 <img width="1429" height="799" alt="Image" src="https://github.com/user-attachments/assets/ead882d5-901c-4fb7-bb36-87734f2d4133" /> 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
yindo added the bug label 2026-02-16 17:41:06 -05:00
yindo closed this issue 2026-02-16 17:41:06 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 20, 2025):

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

  • #4665: OpenCode plus Zen Gemini 3 Pro model causes errors (similar GenerateContentRequest validation errors with Gemini)
  • #3140: AI_APICallError with function declarations parameters on Gemini API (exact same schema validation error pattern)
  • #4832: Gemini 3 Pro function calling fails - missing thoughtSignature support (related to Gemini function calling issues)
  • #365: [bug] google provider not running due to tool call schema mismatches (broader Gemini schema mismatch issue)

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

@github-actions[bot] commented on GitHub (Dec 20, 2025): This issue might be a duplicate of existing issues. Please check: - #4665: OpenCode plus Zen Gemini 3 Pro model causes errors (similar GenerateContentRequest validation errors with Gemini) - #3140: AI_APICallError with function declarations parameters on Gemini API (exact same schema validation error pattern) - #4832: Gemini 3 Pro function calling fails - missing `thoughtSignature` support (related to Gemini function calling issues) - #365: [bug] google provider not running due to tool call schema mismatches (broader Gemini schema mismatch issue) Feel free to ignore if none of these address your specific case.
Author
Owner

@shettydev commented on GitHub (Dec 20, 2025):

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?

@shettydev commented on GitHub (Dec 20, 2025): 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?
Author
Owner

@rekram1-node commented on GitHub (Dec 20, 2025):

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?

@rekram1-node commented on GitHub (Dec 20, 2025): 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?
Author
Owner

@shettydev commented on GitHub (Dec 21, 2025):

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
    }
  }
}
@shettydev commented on GitHub (Dec 21, 2025): I found the MCP, which is causing this issue: ```json { "$schema": "https://opencode.ai/config.json", ... "mcp": { ... "basic-memory": { "type": "local", "command": ["basic-memory", "mcp"], "enabled": true } } } ```
Author
Owner

@rekram1-node commented on GitHub (Dec 21, 2025):

okay ill try to make transform more robust for that case

@rekram1-node commented on GitHub (Dec 21, 2025): okay ill try to make transform more robust for that case
Author
Owner

@Molder72 commented on GitHub (Jan 24, 2026):

same problem Gemini models with MCP jetbrains rider server not working

@Molder72 commented on GitHub (Jan 24, 2026): same problem Gemini models with MCP jetbrains rider server not working
Author
Owner

@mugnimaestra commented on GitHub (Feb 3, 2026):

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.

@mugnimaestra commented on GitHub (Feb 3, 2026): 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.
Author
Owner

@mugnimaestra commented on GitHub (Feb 3, 2026):

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.

@mugnimaestra commented on GitHub (Feb 3, 2026): ## 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 in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3685