You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[bug] Gemini rejects MCP tool with nullable array schema (type: "array","null"): languages.items predicate failed + any_of0.items` missing field #48073
Description
Any request to a Gemini model fails with 400 INVALID_ARGUMENT when the @sylphx/pdf-reader-mcp MCP server is enabled — even a plain hello with no PDF involved. Gemini validates all function declarations up front, so one incompatible tool schema breaks every request. The same setup works fine on DeepSeek / OpenAI-compatible providers.
Error
GenerateContentRequest.tools[0].function_declarations[9].parameters.properties[languages].items: field predicate failed: $type == Type.ARRAY
GenerateContentRequest.tools[0].function_declarations[9].parameters.properties[languages].any_of[0].items: missing field.
Root cause
The MCP server's raw tools/list schema (queried directly, v4.1.3 = latest) declares:
"languages": { "items": { "type": "string" }, "type": ["array", "null"] }
This is valid JSON Schema, but after opencode/AI-SDK converts it to Gemini's function-calling schema, the multi-type array is split into anyOf, producing two invalid halves:
top-level items left behind while type is no longer ARRAY → predicate failed: $type == Type.ARRAY
a bare { "type": "array" } branch inside anyOf with no items → any_of[0].items: missing field (Gemini requires items on every array)
The tool has ~15 similar union-typed fields (["string","null"], ["integer","null"], plus a nested sources.regions: ["array","null"]), so patching a single field is not enough — the converter/sanitizer needs to handle the pattern.
Repro
Description
Description
Any request to a Gemini model fails with 400 INVALID_ARGUMENT when the @sylphx/pdf-reader-mcp MCP server is enabled — even a plain hello with no PDF involved. Gemini validates all function declarations up front, so one incompatible tool schema breaks every request. The same setup works fine on DeepSeek / OpenAI-compatible providers.
Error
Root cause
The MCP server's raw tools/list schema (queried directly, v4.1.3 = latest) declares:
"languages": { "items": { "type": "string" }, "type": ["array", "null"] }
This is valid JSON Schema, but after opencode/AI-SDK converts it to Gemini's function-calling schema, the multi-type array is split into anyOf, producing two invalid halves:
The tool has ~15 similar union-typed fields (["string","null"], ["integer","null"], plus a nested sources.regions: ["array","null"]), so patching a single field is not enough — the converter/sanitizer needs to handle the pattern.
Repro
Expected / proposed fix
Extend sanitizeGemini in transform.ts (cf. [bug] Gemini API rejects MCP tool schemas with properties/required on non-object types #11889) to normalize multi-entry type arrays on the Gemini path, e.g. collapse type: ["array","null"] → type: "array", nullable: true keeping items on the array branch (same class of fix as LibreChat [FEATURE]: Multi-project core and API #13623 sanitizeGeminiSchema, and related to AI_APICallError: GenerateContentRequest.tools[0].function_declarations[32].parameters. required[0]: property is not defined with Gemini API #3140 / Gemini: all requests fail due to anyOf schema in github_create_pull_request_review tool #14509). Gemini-side nullable is the documented way to express optionality — no anyOf needed.
Environment
Related
Plugins
pdf-reader
OpenCode version
v1.18.27
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
Ubuntu 22.04
Terminal
Ptyxis