#419·OfficeCLI

[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.ARRAY

Root Cause Analysis

In officecli mcp, the tools/list RPC endpoint outputs the following inputSchema for the command parameter:

json
{
  "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"
  ]
}
  1. Gemini OpenAPI / Protobuf Schema Constraints:
    • Google Gemini's Function Calling specification strictly requires type to 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 items field is ONLY valid when $type == Type.ARRAY.
  2. When proxies or bridge adapters normalize ["string", "array"] to STRING, the dangling items field causes Gemini to immediately reject the entire payload with HTTP 400 INVALID_ARGUMENT.

Steps to Reproduce

  1. Register officecli as an MCP server in an agent client (e.g. Codex or Claude-Code).
  2. Configure upstream model to Google Gemini (e.g. gemini-2.5-pro or gemini-3.8-flash).
  3. Send any prompt that loads active tools.
  4. 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:

json
"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/officecli version: 1.0.151
  • Platform: Windows x64 (affects all platforms)
  • Upstream Model: Google Gemini (gemini-3.8-flash-high)