Skip to content

fix(mcp): an invalid tool argument reaches claude.ai as a tool error naming it - #41377

Open
mfazekas wants to merge 4 commits into
pingdotgg:mainfrom
mfazekas:fix/mcp-argument-errors-as-tool-errors
Open

mfazekas wants to merge 4 commits into
pingdotgg:mainfrom
mfazekas:fix/mcp-argument-errors-as-tool-errors

Conversation

@mfazekas

Copy link
Copy Markdown
Contributor

Problem

Under MCP 2025-06-18, which the server still offers first, an invalid tool argument (an unknown name, a value below its minimum, a malformed target) becomes a JSON-RPC -32602 error. claude.ai shows that only as "the tool failed (unavailable)", so the model never learns which argument was wrong.

Change

Toolkit tool calls now return an InvalidParams failure as an isError tool result carrying its message, on every protocol. Continuation calls (with requestState or inputResponses) keep the protocol error. The wrapper sits outside the span and analytics wrappers, so both still record the original failure.

Scope

A small fix for an obvious bug: claude.ai users see a dead-end "unavailable" instead of the validation message.

Verification

Updated McpHttpServer.test.ts and toolkits/core.test.ts to expect an isError result naming the bad argument (including t3_thread_read with an unknown position). The 6 affected tests fail without the change and pass with it. src/mcp passes, and typecheck is clean. Not covered by a test: continuation calls, since the harness can't set requestState.

Model: Claude Opus 5.5 (claude-opus-5-5). Harness: Claude Code, run from T3 Code.

…naming it

Under MCP 2025-06-18 an invalid tool argument becomes a JSON-RPC -32602
error, which claude.ai shows only as "the tool failed (unavailable)". Tool
calls now return it as an isError result naming the bad argument on every
protocol. Continuation calls keep the protocol error, and spans and
analytics still record the original failure.
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The MCP server now returns selected argument validation failures as error tool results when the request context has neither requestState nor inputResponses. Tests check returned error results and messages.

Changes: MCP argument error handling

Layer / File(s) Summary
Convert invalid arguments to tool results
apps/server/src/mcp/McpHttpServer.ts
A new wrapper converts InvalidParams into an error tool result when the request context has neither requestState nor inputResponses. Toolkit registration applies the wrapper around the existing middleware.
Validate invalid-argument tool results
apps/server/src/mcp/McpHttpServer.test.ts, apps/server/src/mcp/toolkits/core.test.ts
Tests check error tool results and their text for invalid delegate targets, undeclared arguments, below-minimum values, an empty send_to_user message, and an unknown organize target.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Possibly related issues

  • Issue 35713: The change returns selected argument validation failures as error tool results. Calls with requestState or inputResponses still propagate protocol errors, so the issue is not fully resolved.

Suggested reviewers: sheetsync, juliusmarminge

Merge Risk: Minimal · up to ac2aa

Invalid tool arguments are now returned as error tool results that name the problem. Calls that continue a request with requestState or inputResponses keep the protocol error. No concrete merge-blocking risk was found, though continuation behavior and claude.ai presentation were not exercised.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: toolkit InvalidParams failures now return as isError tool results that name the invalid argument, so claude.ai shows the validation message. It follows the conventiona…
Description check Passed The description follows the template. It gives the problem (MCP -32602 errors shown as an unavailable tool on claude.ai), the change (isError tool results on every protocol, with continuation calls ke…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: toolkit InvalidParams failures now return as isError tool results that name the invalid argument, so claude.ai shows the validation message. It follows the conventional commit format and is specific to the changeset.

Full details: Description check

Explanation

The description follows the template. It gives the problem (MCP -32602 errors shown as an unavailable tool on claude.ai), the change (isError tool results on every protocol, with continuation calls keeping the protocol error), the scope (a small bug fix), and verification (updated tests, the 6 affected tests failing before and passing after, and what was not covered). It also names the model and harness as the template asks. The reproduction steps are brief, and the description does not link an issue. The scope section says a small fix needs no issue, which the template accepts. The Verification section does not cover continuation calls. The PR objectives also report an automated pipeline comment that the behavior could not be verified on claude.ai, and the description does not mention that gap.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 287c391 and ac2aacb.

Files selected for processing: 2

  • apps/server/src/mcp/McpHttpServer.ts
  • apps/server/src/mcp/toolkits/core.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 23, 2026
juliusmarminge and others added 2 commits November 23, 2026 10:47
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

The automated pipeline stopped on this pull request and will not merge it:

the fix is written and reviewed, but proving it needs something no worker has:

  • Permanent blocker: a signed-in claude.ai account with MCP connector access is required; first-party Claude OAuth is unavailable on workers. Replay scenarios cannot establish claude.ai's provider-specific error presentation.
  • The initial-call error text, prevention of tool execution, and protocol-error handling for requestState or inputResponses were not observed on either revision.

It stays open for a person to finish or close.

@juliusmarminge juliusmarminge added takeover:blocked Takeover blocked; reason in the PR body and removed takeover:in-progress A takeover lead is working on this PR labels Nov 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR conflicts with main. Rebase it or merge main into it. If it still conflicts after 7 days with no activity, it will be closed automatically.

See the conflict window.

@github-actions github-actions Bot added the needs-rebase Conflicts with its base branch. Closes after 7 days with no activity. label Nov 24, 2026
…rs-as-tool-errors

# Conflicts:
#	apps/server/src/mcp/McpHttpServer.ts

This branch has not been deployed

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

Labels

needs-rebase Conflicts with its base branch. Closes after 7 days with no activity. size:M 30-99 changed lines (additions + deletions). takeover:blocked Takeover blocked; reason in the PR body vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants