Claude models fail on MCP tools with no required parameters (undefined vs {}) #6559

Closed
opened 2026-02-16 18:04:35 -05:00 by yindo · 3 comments
Owner

Originally created by @belovedEmperor on GitHub (Jan 16, 2026).

Originally assigned to: @thdxr on GitHub.

Description

Claude models send undefined for MCP tool arguments when a tool has no required parameters. OpenCode passes this through unchanged, causing Zod validation to fail on the MCP server side.

Gemini models send {} for the same tools and work fine.

Steps to reproduce

  1. Configure @modelcontextprotocol/server-memory MCP server
  2. Use a Claude model (e.g., claude-sonnet-4-20250514)
  3. Trigger memory_read_graph tool (no required params)
  4. Tool execution aborted with invalid_union error

Error output

[
  {
    "code": "invalid_union",
    "errors": [
      [
        {
          "expected": "record",
          "code": "invalid_type",
          "path": [
            "state",
            "input"
          ],
          "message": "Invalid input: expected record, received undefined"
        }
      ],
      [
        {
          "expected": "object",
          "code": "invalid_type",
          "path": [
            "part"
          ],
          "message": "Invalid input: expected object, received undefined"
        },
        {
          "expected": "string",
          "code": "invalid_type",
          "path": [
            "delta"
          ],
          "message": "Invalid input: expected string, received undefined"
        }
      ],
      [
        {
          "expected": "object",
          "code": "invalid_type",
          "path": [
            "part"
          ],
          "message": "Invalid input: expected object, received undefined"
        },
        {
          "expected": "string",
          "code": "invalid_type",
          "path": [
            "delta"
          ],
          "message": "Invalid input: expected string, received undefined"
        }
      ]
    ],
    "path": [],
    "message": "Invalid input"
  }
]

Root cause

In packages/opencode/src/mcp/index.ts, convertMcpTool's execute function passes args directly:

arguments: args as Record<string, unknown>

When Claude sends undefined, this becomes arguments: undefined to the MCP server.

Suggested fix

arguments: args ?? {}

Environment

  • OS: NixOS
  • Models affected: Claude (all versions tested)
  • Models working: Gemini
Originally created by @belovedEmperor on GitHub (Jan 16, 2026). Originally assigned to: @thdxr on GitHub. ## Description Claude models send `undefined` for MCP tool arguments when a tool has no required parameters. OpenCode passes this through unchanged, causing Zod validation to fail on the MCP server side. Gemini models send `{}` for the same tools and work fine. ## Steps to reproduce 1. Configure `@modelcontextprotocol/server-memory` MCP server 2. Use a Claude model (e.g., `claude-sonnet-4-20250514`) 3. Trigger `memory_read_graph` tool (no required params) 4. Tool execution aborted with `invalid_union` error ## Error output ```json [ { "code": "invalid_union", "errors": [ [ { "expected": "record", "code": "invalid_type", "path": [ "state", "input" ], "message": "Invalid input: expected record, received undefined" } ], [ { "expected": "object", "code": "invalid_type", "path": [ "part" ], "message": "Invalid input: expected object, received undefined" }, { "expected": "string", "code": "invalid_type", "path": [ "delta" ], "message": "Invalid input: expected string, received undefined" } ], [ { "expected": "object", "code": "invalid_type", "path": [ "part" ], "message": "Invalid input: expected object, received undefined" }, { "expected": "string", "code": "invalid_type", "path": [ "delta" ], "message": "Invalid input: expected string, received undefined" } ] ], "path": [], "message": "Invalid input" } ] ``` ## Root cause In `packages/opencode/src/mcp/index.ts`, `convertMcpTool`'s execute function passes args directly: ```typescript arguments: args as Record<string, unknown> ``` When Claude sends `undefined`, this becomes `arguments: undefined` to the MCP server. ## Suggested fix ```typescript arguments: args ?? {} ``` ## Environment - OS: NixOS - Models affected: Claude (all versions tested) - Models working: Gemini
yindo added the nix label 2026-02-16 18:04:35 -05:00
yindo closed this issue 2026-02-16 18:04:35 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 16, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #8184: Strict JSON Schema validation fail on backends like SGLang (Missing required field in empty tool parameters)

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 16, 2026): This issue might be a duplicate of existing issues. Please check: - #8184: Strict JSON Schema validation fail on backends like SGLang (Missing required field in empty tool parameters) Feel free to ignore if none of these address your specific case.
Author
Owner

@belovedEmperor commented on GitHub (Jan 16, 2026):

Also confirmed this affects the Playwright MCP server - not specific to server-memory. Any MCP tool with no required parameters will fail when called by Claude.

@belovedEmperor commented on GitHub (Jan 16, 2026): Also confirmed this affects the Playwright MCP server - not specific to server-memory. Any MCP tool with no required parameters will fail when called by Claude.
Author
Owner

@BingLi37 commented on GitHub (Jan 20, 2026):

me too

@BingLi37 commented on GitHub (Jan 20, 2026): me too
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6559