fix(mcp): send empty object instead of nil arguments in CallTool

MCP servers built on the Zod-based TypeScript SDK (notably
@playwright/mcp) reject `arguments: null` with
"expected record, received null" when a tool has no required parameters.
The Go SDK happily forwards a nil map as JSON null, which breaks every
parameter-less browser_* tool from Playwright MCP.

Always normalize a nil arguments map to an empty map before building
CallToolParams. Verified end-to-end against @playwright/mcp@latest
running headless Chromium inside the launcher Docker image —
browser_navigate + browser_snapshot now succeed instead of erroring out.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alex 2026-04-10 00:19:14 +02:00
parent 20d3522069
commit 2c3d0992f0

View file

@ -473,6 +473,12 @@ func (m *Manager) CallTool(
}
defer m.wg.Done()
// Some MCP servers (notably @playwright/mcp) reject `arguments: null` with
// a Zod validation error ("expected record, received null") when a tool
// has no required parameters. Always send an empty object instead of nil.
if arguments == nil {
arguments = map[string]any{}
}
params := &mcp.CallToolParams{
Name: toolName,
Arguments: arguments,