Skip to content

Bug: "Request contains an invalid argument" when using with Gemini CLI #13

@aleks-mariusz

Description

@aleks-mariusz

Describe the bug
When using ToolsForMCPServer (v39) as an MCP Server for the Gemini CLI, every prompt sent to the Gemini API fails with a 400 - Request contains an invalid argument error. This happens for any prompt, even simple ones like "hi", effectively breaking the CLI's core functionality.

This may be the exact same issue as a previously reported bug in the gemini-cli repository: Issue #5030: API Error: Request contains an invalid argument.

The root cause in that issue was identified as recursive or overly deep schema definitions in the toolset sent to the Gemini API.

After analyzing the full schema of all 149 tools provided by the MCP server, the possible cause of these errors may be the following:

The tool classroom_courses_courseWork_rubrics_create provides a malformed JSON schema for its parameters.

The items object within the criteria property is defined as "type": "object" but is missing the required properties field.

Here is a snippet from this tool's schema:

"items": {
  "title": "Level",
  "description": "A level of performance within a criterion...",
  "type": "object"
}

This invalid schema is causing the Gemini API to reject the entire list of tools, which explains why every prompt fails.

To Reproduce

  1. Create a Google App Script using ToolsForMCPServer version 39 and MCPApp - i used the instructions here
  2. Deploy the script as a Web App.
  3. Configure the Gemini CLI settings.json to use this Web App as an MCP server (also as per the above page).
  4. Start the Gemini CLI (gemini).
  5. Type any prompt, such as hi.

Expected behavior
A chat response should be returned from the model.

Actual behavior
An API error is returned immediately:

[API Error: [{
    "error": {
      "code": 400,
      "message": "Request contains an invalid argument.",
      "status": "INVALID_ARGUMENT"
    }
  }
]]

Additional context

  • The /mcp command works correctly and lists all 149 tools from the server.
  • The issue is present in version 39 of the ToolsForMCPServer library.
  • The symptoms strongly suggest that the Gemini API is rejecting the entire /generateContent request because of an invalid tool definition, as described in the related gemini-cli issue #5030.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions