fix(mcp): omit unused optional tool args#3304
Conversation
Pruned empty optional MCP argument placeholders before tools/call while preserving required fields and meaningful falsy values. Added regression coverage for active and deferred MCP tools. Fixes #3302
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60348404a0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| ### Fixed | ||
|
|
||
| - Fixed MCP tool calls forwarding empty optional placeholder arguments (`""` and `{}`) to `tools/call`; optional placeholders are now omitted while required fields and meaningful falsy values are preserved. ([#3302](https://github.com/can1357/oh-my-pi/issues/3302)) |
There was a problem hiding this comment.
Move changelog entry back to Unreleased
The root AGENTS.md changelog rule says new entries must go under ## [Unreleased] and already-released sections are immutable. This entry was added under ## [16.1.16] - 2026-06-23 instead, so it mutates a released changelog section and will not be picked up as an unreleased fix for the next release; move it to the Unreleased ### Fixed section.
Useful? React with 👍 / 👎.
|
Moved the MCP fix changelog entry from the released |
Repro
Constructed an
MCPToolwith requiredsymboland optionallanguage/options, executed it with{ symbol: "Foo", language: "", options: {} }, and observed the pre-fixtools/callpayload forwarding{"symbol":"Foo","language":"","options":{}}(exit 42 from the repro guard).Cause
packages/coding-agent/src/mcp/tool-bridge.tsnormalized model-emitted MCP tool params withnormalizeToolArgs()and passed them directly tocallTool()in bothMCPTool.execute()andDeferredMCPTool.execute(). That preserved empty optional placeholders even when the MCP input schema declared the fields as optional.Fix
tool-bridge.tsthat omits optional"",{}, andundefinedplaceholders beforetools/call.0andfalse.packages/coding-agent/test/mcp-tool-args.test.ts.Verification
bun test packages/coding-agent/test/mcp-tool-args.test.tspassed (2 tests).bun --cwd=packages/coding-agent run checkpassed. The original repro command now forwards{"symbol":"Foo"}and exits 0. Fixes #3302