Skip to content

Bug: MCP tools with all-optional parameters fail when called without arguments — harness requires content.0.tool_use.input to be present #20637

@D26FORWARD

Description

@D26FORWARD

Description

When calling an MCP tool that has all optional parameters (e.g., Playwright's browser_snapshot), and the LLM correctly decides to call it with no arguments (since none are required), OpenCode's harness rejects the call because it requires content.0.tool_use.input to be a non-empty object.

Expected behavior: The tool should be called successfully with an empty input {}, since the MCP tool schema declares all parameters as optional.

Actual behavior: The call fails because the harness enforces the presence of content[0].tool_use.input, which is absent or empty when no arguments are passed.

Example MCP tool affected:

{
  "name": "playwright_browser_snapshot",
  "parameters": {
    "properties": {
      "depth": { "type": "number", "description": "Limit the depth of the snapshot tree" },
      "filename": { "type": "string", "description": "Save snapshot to markdown file..." }
    },
    "type": "object"
  }
}

Note: no "required" array — both parameters are optional. Calling browser_snapshot() with no arguments is a perfectly valid invocation.

Workaround: The LLM must always pass at least one dummy parameter (e.g., depth=5) even when no arguments are needed, which is wasteful and fragile.

Root cause hypothesis: The harness validation likely checks for the existence/non-emptiness of tool_use.input without accounting for the case where all tool parameters are optional and the LLM correctly omits them.

Plugins

oh-my-opencode, Playwright MCP

OpenCode version

1.3.13

Steps to reproduce

  1. Configure an MCP server that exposes a tool with all-optional parameters (e.g., Playwright MCP's browser_snapshot)
  2. Ask the LLM to take a page snapshot without specifying any parameters
  3. The LLM generates a tool call with no input field (or empty input: {})
  4. OpenCode harness rejects the call

Screenshot and/or share link

{
"error": {
"code": 400,
"message": "{"type":"error","error":{"type":"invalid_request_error","message":"..content.0.tool_use.input: Field required"},"request_id":"req_vrtx_011CZefzKau4PEToWRYs5nXc"}",
"status": "INVALID_ARGUMENT"
}
}
(traceid: 5a8af7d0b37ea218fe88123c0d307dde)

Image

Operating System

Linux

Terminal

OpenCode TUI

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions