Skip to content

Gemini schema sanitizer doesn't strip contentEncoding from MCP tool schemas #15408

@RaviTharuma

Description

@RaviTharuma

Bug Description

When using Gemini-based agents (e.g. oh-my-opencode Junior Sisyphus) with MCP servers that define contentEncoding in their tool schemas, the Gemini API rejects the request with a 400 error.

The existing schema sanitizer (introduced in v1.0.137 via #3140) strips properties/required from non-object types, but does not strip contentEncoding or contentMediaType — both valid JSON Schema keywords that Gemini's function calling API doesn't support.

Error

Bad Request: {
  "error": {
    "code": 400,
    "message": "Invalid JSON payload received. Unknown name \"contentEncoding\" at 'request.tools[0].function_declarations[87].parameters.properties[4].value.items.properties[2].value': Cannot find field.\nInvalid JSON payload received. Unknown name \"contentEncoding\" at 'request.tools[0].function_declarations[88].parameters.properties[4].value.items.properties[2].value': Cannot find field.\nInvalid JSON payload received. Unknown name \"contentEncoding\" at 'request.tools[0].function_declarations[89].parameters.properties[4].value.items.properties[2].value': Cannot find field.",
    "status": "INVALID_ARGUMENT"
  }
}

Reproduction

  1. Configure an MCP server that uses contentEncoding in tool schemas (e.g. chrome-devtools-mcp — tools like take_screenshot, take_snapshot, upload_file use contentEncoding: "base64")
  2. Start a session with a Gemini model
  3. The API call fails with the above error

Expected Behavior

The Gemini schema sanitizer should strip unsupported JSON Schema keywords before sending function declarations. At minimum:

  • contentEncoding
  • contentMediaType

Environment

  • opencode v1.2.15
  • MCP server: chrome-devtools-mcp (mcpm)
  • Gemini model via oh-my-opencode Junior Sisyphus agent

Related

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions