Skip to content

[Bug]: MCP tool call with an optional argument set to null fails via OpenClaw but succeeds via other MCP clients #96716

Closed

Description

@yybht155

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

An MCP tool call where an optional string argument is set to JSON null fails with a
server-side error via OpenClaw, while the identical call (same arguments, same server URL
and token) sent from another MCP client (Cursor) succeeds — indicating OpenClaw transmits
the optional null argument differently.

Steps to reproduce

  1. Configure an MCP server over streamable-http that exposes a tool with an OPTIONAL string
    argument whose JSON Schema is anyOf [string, null] with default null
    (concrete case: awslabs eks-mcp-server get_eks_insights, arg insight_id).
  2. Have the agent call the tool in "list" mode, i.e. with insight_id = null.
  3. Observe the tool result is the server's "describe one item" error path, and the
    OpenClaw trajectory records the arguments with insight_id: null.
  4. Send the identical arguments from another MCP client (Cursor) to the same server URL +
    bearer token -> it returns the list successfully.

Expected behavior

Calling the tool with the optional argument = null (or absent) should behave as "not
provided". Grounded reference: the identical arguments sent from another MCP client (Cursor)
to the same server return the list successfully, and the tool's JSON Schema defines null as
the default ("no id" => list mode).

Actual behavior

The call fails. OpenClaw trajectory recorded the tool arguments as:
{"category":null,"cluster_name":"testenv-cluster","insight_id":null}
and the tool returned:
Error retrieving insight details: An error occurred (AccessDeniedException) when calling
the DescribeInsight operation: Unable to determine service/operation name to be authorized

Against that same server, this error is reproducible ONLY when insight_id is sent as an
empty string "" — sending null, absent, or the string "null" all return the list. So the
server distinguishes "" from null, and OpenClaw's null call behaves like "".

OpenClaw version

2026.6.10 (aa69b12)

Operating system

Ubuntu Linux (kernel 7.0.0-1006-aws), x86_64 EC2

Install method

npm global (~/.npm-global)

Model

gpt-5.5

Provider / routing chain

openclaw -> gateway -> gpt-5.5

Additional provider/model setup details

MCP path relevant to this bug: openclaw -> mcphub (streamable-http) -> awslabs eks-mcp-server.

Logs, screenshots, and evidence

# OpenClaw trajectory: tool call arguments (insight_id is null) and the error result
get_eks_insights","arguments":{"category":null,"cluster_name":"testenv-cluster","insight_id":null}
get_eks_insights","content":[{"type":"text","text":"Error retrieving insight details: An error occurred (AccessDeniedException) when calling the DescribeInsight operation: Unable to determine service/operation name to be authorized"}],"details":{"mcpServer":"mcphub","mcpTool":"eks-apn1-get_eks_insights","status":"error"}

# Same server, same token, sent from another MCP client (Cursor):
#   {cluster_name}                      -> list OK
#   {cluster_name, insight_id: null}    -> list OK
#   {cluster_name, insight_id: "null"}  -> list OK
#   {cluster_name, insight_id: ""}      -> SAME DescribeInsight error as above

Impact and severity

Affected: any MCP server that distinguishes null/absent from "" for an optional argument.
Severity: High for affected tools (the "list" form of get_eks_insights is impossible from
OpenClaw; it always errors).
Frequency: Always (reproduced repeatedly, including a forced single-call test).
Consequence: A logically valid tool call is unusable via OpenClaw while working from other
MCP clients.

Additional information

Hypothesis (NOT yet confirmed by a captured wire payload): OpenClaw may serialize optional
arguments set to JSON null as empty strings "" when calling MCP tools over streamable-http.
We could not capture the raw wire request: openclaw proxy run blocked the model provider
endpoint via SSRF protection, so the run could not reach the MCP call under capture.
Downstream defensive fix filed at awslabs/mcp#4036 (server side treating "" as list mode),
but the originating behavior appears to be on the OpenClaw client side.

Activity

  1. clawsweeper commented on Jun 25, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 25, 2026, 5:08 AM ET / 09:08 UTC.

    Summary
    Keep open: current main and the latest release still forward MCP tool input records without dropping null values, and the unmerged linked PR is the active candidate fix rather than an implemented solution.

    Reproducibility: yes. with medium confidence from source and reporter evidence: the reported release and current main both forward null-containing input records through the bundle-MCP call path. I did not run the awslabs EKS MCP server or capture a live wire payload.

    Root-cause cluster
    Relationship: canonical
    Canonical: #96716
    Summary: This issue is the canonical report for the optional-null MCP argument behavior, with one open candidate fix PR.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Next step
    An open linked PR already owns the implementation path, so this issue should not queue a separate repair job unless that PR is closed or rejected.

    Review details

    Best possible solution:

    Keep this issue open while maintainers review the linked candidate fix; the final fix should normalize optional-null MCP arguments at the bundle-MCP boundary with focused regression coverage and avoid changing meaningful required-null parameters.

    Do we have a high-confidence way to reproduce the issue?

    Yes, with medium confidence from source and reporter evidence: the reported release and current main both forward null-containing input records through the bundle-MCP call path. I did not run the awslabs EKS MCP server or capture a live wire payload.

    Is this the best way to solve the issue?

    Unclear until the linked PR is reviewed: stripping optional nulls before MCP dispatch is a plausible narrow fix, but a schema-aware version may be safer than dropping every top-level null value.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The raw wire payload was not captured, so the exact null-to-empty-string conversion point remains unproven by local reproduction.
    • The open candidate PR strips all top-level null values; PR review should confirm this is safe for nullable-but-required MCP parameters or narrow it to optional-null schema fields.

    Codex review notes: model internal, reasoning high; reviewed against c8c4490b1729.

    Label changes

    Label changes:

    • add P2: This is a normal-priority MCP runtime bug with a clear affected tool-call path and limited blast radius.
    • add impact:other: The issue affects external MCP tool invocation semantics, which is maintainer-visible but outside the more specific impact label taxonomy.
    • add issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.
    • add clawsweeper:needs-live-repro: Current issue advisory state selects this label.
    • add clawsweeper:linked-pr-open: Current issue advisory state selects this label.
    • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.

    Label justifications:

    • P2: This is a normal-priority MCP runtime bug with a clear affected tool-call path and limited blast radius.
    • impact:other: The issue affects external MCP tool invocation semantics, which is maintainer-visible but outside the more specific impact label taxonomy.
    Evidence reviewed

    What I checked:

    • Current main MCP tool dispatch: The materialized bundle-MCP tool execute path passes the raw model input object into runtime.callTool(...); there is no current-main null stripping at this boundary. (src/agents/agent-bundle-mcp-materialize.ts:406, c8c4490b1729)
    • Current main MCP runtime forwarding: The session MCP runtime forwards record inputs as arguments to the MCP SDK call, so a record containing null values remains in the tool-call argument object at this layer. (src/agents/agent-bundle-mcp-runtime.ts:902, c8c4490b1729)
    • Latest release still has same behavior: The latest release tag v2026.6.10 shows the same dispatch line passing input directly to runtime.callTool(...), matching the version reported by the issue. (src/agents/agent-bundle-mcp-materialize.ts:406, aa69b12d0086)
    • Open candidate fix: The linked pull request is open, mergeable, and uses closing syntax for this issue while changing only the MCP materialization file; it has not merged, so this issue should remain open for PR review. (8904f234944a)
    • Feature history: Blame points the current bundle-MCP materialization and runtime code to commit 070996e5c3, which introduced the relevant current-main forwarding behavior. (src/agents/agent-bundle-mcp-materialize.ts:406, 070996e5c334)
    • MCP SDK contract check: The pinned MCP TypeScript SDK v1.29.0 accepts arguments as a record of unknown values and Client.callTool sends the supplied params through tools/call; this supports reviewing null handling at the OpenClaw boundary rather than assuming the SDK contract rejects null values. (package.json:1965)

    Likely related people:

    • Josh Lehman: git blame and git show --stat tie the current materialization and runtime files to commit 070996e5c3, which introduced the direct input to callTool path. (role: introduced current bundle-MCP forwarding path; confidence: medium; commits: 070996e5c334; files: src/agents/agent-bundle-mcp-materialize.ts, src/agents/agent-bundle-mcp-runtime.ts)
    • zw-xysk: The open linked PR changes the MCP dispatch boundary for this issue and is the current implementation candidate. (role: candidate fix author; confidence: medium; commits: 8904f234944a; files: src/agents/agent-bundle-mcp-materialize.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P2Normal backlog priority with limited blast radius.
    impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    on Jun 25, 2026
  3. added 2 commits that reference this issue on Jun 26, 2026
    49fe87d
    c3b2539
  4. added a commit that references this issue on Jun 27, 2026
    361869e
  5. added a commit that references this issue on Jun 28, 2026
    b024c96
  6. added 2 commits that reference this issue on Jul 1, 2026
    0a165ee
  7. locked as resolved and limited conversation to collaborators on Jul 16, 2026
  8. VACInc commented on Sep 6, 2026

    @VACInc
    Member

    Related shared-validator follow-up: #140310 merged as b494b1f.

    The new regression coverage preserves genuine null values while preventing rejected non-null inputs from being converted into null as a validation fallback. It covers tagged TypeBox and plain nullable unions while retaining supported record, numeric-enum, and integer conversion behavior.

    This is related validation hardening, not a claim that #140310 originally fixed this issue or that its EKS MCP scenario was rerun. This report concerns genuine null becoming an empty string; the newly guarded case concerns invalid non-null input becoming null.

    The issue's existing closed state is unchanged.

    Exact TypeBox 1.3.18 source inspection and executed probe: #140310 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingbug:behaviorIncorrect behavior without a crashclawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions