From 2c3d0992f0ccbfaa14036dba32d2943a6421ab79 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 10 Apr 2026 00:19:14 +0200 Subject: [PATCH] fix(mcp): send empty object instead of nil arguments in CallTool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- pkg/mcp/manager.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/mcp/manager.go b/pkg/mcp/manager.go index f589f82a9..92b843032 100644 --- a/pkg/mcp/manager.go +++ b/pkg/mcp/manager.go @@ -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,