[Bug] MCP tools/list inputSchema causes HTTP 400 with Google Gemini API: `$type == Type.ARRAY` assertion failure
Author: vjiaozivCreated Sep 21, 2026Updated Sep 22, 2026
Description
When using officecli mcp with LLM clients connecting to the Google Gemini API (such as Codex, Claude Code, or Antigravity proxying to Gemini 2.0/3.0/3.8), requests fail with HTTP 400 Bad Request:
GenerateContentRequest.tools[0].function_declarations[...].parameters.properties[command].items: field predicate failed: $type == Type.ARRAYRoot Cause Analysis
In officecli mcp, the tools/list RPC endpoint outputs the following inputSchema for the command parameter:
{
"type": "object",
"properties": {
"command": {
"type": [
"string",
"array"
],
"items": {
"type": "string"
},
"description": "The officecli command line — either a single string (e.g. \"add deck.pptx /slide[1] --type shape --prop text=Hi\") or a pre-split argv array of strings..."
}
},
"required": [
"command"
]
}- Gemini OpenAPI / Protobuf Schema Constraints:
- Google Gemini's Function Calling specification strictly requires
typeto be a single enum value (STRING,ARRAY,OBJECT, etc.), not a JSON Schema union array["string", "array"]. - Google Gemini API enforces a strict server-side assertion: the
itemsfield is ONLY valid when$type == Type.ARRAY.
- Google Gemini's Function Calling specification strictly requires
- When proxies or bridge adapters normalize
["string", "array"]toSTRING, the danglingitemsfield causes Gemini to immediately reject the entire payload with HTTP 400INVALID_ARGUMENT.
Steps to Reproduce
- Register
officeclias an MCP server in an agent client (e.g. Codex or Claude-Code). - Configure upstream model to Google Gemini (e.g.
gemini-2.5-proorgemini-3.8-flash). - Send any prompt that loads active tools.
- Upstream Gemini API responds with
400 INVALID_ARGUMENT:* GenerateContentRequest.tools[0].function_declarations[...].parameters.properties[command].items: field predicate failed: $type == Type.ARRAY
Suggested Fix
In the native binary's MCP tool definition (or officecli.js launcher wrapper), consider either:
Option A (Best compatibility across all LLMs):
Use anyOf / oneOf to separate the string and array definitions instead of a hybrid multitype with items:
"command": {
"description": "The officecli command line...",
"anyOf": [
{ "type": "string" },
{ "type": "array", "items": { "type": "string" } }
]
}Option B:
Define command simply as "type": "string", since in practice LLM tool callers almost always provide the full CLI string (e.g., "view deck.pptx text").
Environment
@officecli/officecliversion:1.0.151- Platform: Windows x64 (affects all platforms)
- Upstream Model: Google Gemini (
gemini-3.8-flash-high)
Source: iOfficeAI/OfficeCLI