-
Notifications
You must be signed in to change notification settings - Fork 17
Description
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
- Create a Google App Script using
ToolsForMCPServerversion 39 andMCPApp- i used the instructions here - Deploy the script as a Web App.
- Configure the Gemini CLI
settings.jsonto use this Web App as an MCP server (also as per the above page). - Start the Gemini CLI (
gemini). - 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
/mcpcommand works correctly and lists all 149 tools from the server. - The issue is present in version 39 of the
ToolsForMCPServerlibrary. - The symptoms strongly suggest that the Gemini API is rejecting the entire
/generateContentrequest because of an invalid tool definition, as described in the relatedgemini-cliissue #5030.