Skip to content

AI_APICallError: GenerateContentRequest.tools[0].function_declarations[32].parameters. required[0]: property is not defined with Gemini API #3140

Closed

Description

@soyruiz

Related to: #2275, #2241, #3077

Bug Description

Getting AI_APICallError when using Gemini API in Opencode with
function declarations validation error.

Error Details

AI_APICallError:
GenerateContentRequest.tools[0].function_declarations[32].parameters.
required[0]:
property is not defined

Additional Context

This appears to be related to previous Gemini API issues:

The error suggests a schema validation issue where a function
declaration has a required parameter but the property name is not
properly defined in the parameters.required array.

Thanks :)

Activity

  1. github-actions commented on Oct 13, 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. rekram1-node commented on Oct 13, 2025

    @rekram1-node
    Contributor

    Yeah this is due to mcp server tools, we can sanitize them but they aren't compatible with gemini api out of the box

  3. self-assigned this
    on Oct 13, 2025
  4. rekram1-node commented on Dec 1, 2025

    @rekram1-node
    Contributor

    This should fix it: 0331931

    in next release

  5. jeffscottward commented on Dec 18, 2025

    @jeffscottward

    I am still getting this error.
    I am trying to use Docker MCP toolkit as an aggregation for all my MCPs to stop it from eating the context window.
    My current open code version is 1.0.167
    @rekram1-node should this be reopened?

    Specifically, my error says exactly this:

    * GenerateContentRequest.tools[0].function_declarations[21].parameters.required[1]: property is not defined* 

    Since I think I'm already at the latest version, and that this shouldn't be an issue, I asked AI, and it said this.


    If you're already on a version that includes commit 0331931, then the issue is likely one of these scenarios:

    Possible Explanations

    1. The Fix Doesn't Cover All MCP Servers
      The commit may have fixed specific servers mentioned in issue AI_APICallError: GenerateContentRequest.tools[0].function_declarations[32].parameters. required[0]: property is not defined with Gemini API #3140, but the Docker MCP Gateway itself might be generating malformed schemas for other MCP servers (like the ones you're using). The fix in 0331931 may have been targeted at OpenCode's built-in tool declarations, not the MCP Gateway's schema translation layer.

    2. Docker MCP Gateway Issue (Not OpenCode)
      The problem might actually be in Docker Desktop's MCP Gateway itself, not OpenCode. The Gateway is responsible for translating MCP server schemas into a format that AI models can consume. If Docker's Gateway has bugs in how it generates Gemini-compatible schemas, OpenCode can't fix that—Docker would need to release an update to their MCP Toolkit.​

    3. Specific MCP Servers Have Invalid Schemas
      The MCP servers you enabled (GitHub, Neon, Next.js, etc.) might have invalid tool declarations in their own source code. When the Gateway passes these through to OpenCode and then to Gemini, the validation fails. This would require fixes from the individual MCP server maintainers.

    What You Can Check
    To determine where the issue actually is:

    1. Check Your OpenCode Version
      Run this command to see exactly which version you're on:

    bash
    opencode --version
    The fix from commit 0331931 should be in version 1.0.137 or later (based on the Chocolatey package dated December 17, 2025).​

    1. Check Docker MCP Toolkit Version
      The issue might be in Docker's MCP Gateway, not OpenCode. Check your Docker Desktop version:

    Open Docker Desktop

    Go to Settings → General

    Look for "MCP Toolkit" or check the Docker version

    1. Test Without Docker MCP Gateway
      Temporarily remove the MCP_DOCKER configuration from your OpenCode config to see if errors persist with other tools. If errors disappear, it confirms the Gateway is the problem.

    2. Check Which Specific Tools Are Failing
      The error indices (13, 63, 103, 114) point to specific tools. You can inspect the actual schema being sent to Gemini by enabling debug logging in OpenCode or checking the Gateway's output directly.

    Most Likely Scenario
    Given that you're on the latest OpenCode version and the issue persists, this is almost certainly a Docker MCP Gateway bug, not an OpenCode bug. The Gateway is translating MCP server schemas incorrectly for Gemini's strict validation requirements.

    Your current workaround (disabling problematic MCP servers) is the right approach until Docker releases an updated MCP Toolkit that properly formats function declarations for Gemini's API. Other AI models like Claude are more lenient with schema validation, which is why this specifically affects Gemini users.​

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