fix(mcp): strip null optional arguments before MCP tool calls#96718
fix(mcp): strip null optional arguments before MCP tool calls#96718zw-xysk wants to merge 4 commits into
Conversation
MCP tool calls with optional arguments set to JSON null are transmitted differently than absent/undefined arguments by some MCP runtimes, causing servers to reject the call. Strip null values before passing input to callTool so null optional args behave the same as omitted ones. Fixes openclaw#96716 Co-Authored-By: Claude (via Anthropic API) <[email protected]>
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Codex review: needs real behavior proof before merge. Reviewed June 26, 2026, 9:59 AM ET / 13:59 UTC. Summary PR surface: Source +69, Tests +78. Total +147 across 3 files. Reproducibility: no. high-confidence live reproduction was run in this review. Source inspection shows current validation can convert Review metrics: 2 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land one canonical fix that preserves schema-declared nullable nulls, performs any null-as-absent cleanup before validation with normalized schemas, and includes redacted configured OpenClaw MCP proof. Do we have a high-confidence way to reproduce the issue? No high-confidence live reproduction was run in this review. Source inspection shows current validation can convert Is this the best way to solve the issue? No. The branch is a plausible partial fix, but it filters after validation and uses raw schema data; the safer fix is pre-validation or validation-layer normalization with normalized-schema nullability and real MCP proof. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1cd6f81a46ae. Label changesLabel justifications:
Evidence reviewedPR surface: Source +69, Tests +78. Total +147 across 3 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Improve the MCP null-argument fix to be schema-aware: - Only strip null values for fields NOT declared as nullable in the tool's input schema (handles type:null, type:[...,null], anyOf/oneOf with null variant, nullable:true) - Preserves null for schema-meaningful nulls (anyOf [string, null]) This approach is based on competitor PR openclaw#96729 (maweibin) which correctly handles the distinction between nullable and non-nullable fields at the MCP boundary. Fixes openclaw#96716 Signed-off-by: 赵旺0668001248 <[email protected]>
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Fixes #96716
What Problem This Solves
MCP tool calls with optional arguments set to JSON null fail via OpenClaw but succeed via other MCP clients. The MCP server distinguishes null from absent/undefined, so sending
{"insight_id": null}triggers a different code path than omittinginsight_identirely.Evidence
Fix
src/agents/agent-bundle-mcp-materialize.ts: strip null values from tool call input before passing tocallTool().Terminal output
What was not tested
End-to-end with a real MCP server. The fix is a targeted null-strip at the boundary between OpenClaw's tool call dispatch and the MCP runtime.
Changes
1 file, +9/-1. Lockfile unchanged.