fix(mcp): send empty object instead of nil arguments in CallTool#2460
Open
alexrexby wants to merge 1 commit intosipeed:mainfrom
Open
fix(mcp): send empty object instead of nil arguments in CallTool#2460alexrexby wants to merge 1 commit intosipeed:mainfrom
alexrexby wants to merge 1 commit intosipeed:mainfrom
Conversation
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>
|
Alex seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
afjcjsbx
requested changes
Apr 10, 2026
Collaborator
afjcjsbx
left a comment
There was a problem hiding this comment.
hi, good catch! thanks for the fix, would you add also a unit test? 🙏
stpwin
added a commit
to stpwin/picoclaw
that referenced
this pull request
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
MCP servers built on the official TypeScript SDK validate tool call arguments with Zod. When PicoClaw invokes a tool that has no required parameters, it currently passes a
nilmap[string]anytomcp.CallToolParams.Arguments, which the Go SDK serializes as JSONnull. Zod-based servers reject this with:```
expected record, received null
path: params.arguments
```
The most prominent affected server is @playwright/mcp, which makes every parameter-less browser tool unusable from PicoClaw —
browser_snapshot,browser_take_screenshot,browser_tabs, etc. all fail immediately on first call.Reproduction
```json
"tools": {
"mcp": {
"enabled": true,
"servers": {
"playwright": {
"enabled": true,
"command": "npx",
"args": ["-y", "@playwright/mcp@latest", "--headless"]
}
}
}
}
```
Fix
Normalize a nil arguments map to an empty map before constructing `CallToolParams`. JSON marshalling then produces `{}` instead of `null`, which Zod accepts.
Six lines, no behaviour change for tools that already pass non-nil arguments.
Verified
End-to-end against `@playwright/mcp@latest` running headless Chromium inside the launcher Docker image. `browser_navigate` + `browser_snapshot` now succeed and the agent returns the page title in 6-7 seconds.
Happy to add a unit test in `pkg/mcp/manager_test.go` if maintainers want it — just say the word.