Skip to content

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

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

mfazekas wants to merge 3 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 the 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, and below-minimum values. The unknown organize target test also checks that no command was dispatched.

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

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant MCPClient
  participant withInvalidArgumentsAsToolErrors
  participant ToolkitHandler
  participant MCPRequestContext
  MCPClient->>withInvalidArgumentsAsToolErrors: call tool
  withInvalidArgumentsAsToolErrors->>ToolkitHandler: invoke handler
  ToolkitHandler-->>withInvalidArgumentsAsToolErrors: InvalidParams
  withInvalidArgumentsAsToolErrors->>MCPRequestContext: check requestState and inputResponses
  alt neither is present
    withInvalidArgumentsAsToolErrors-->>MCPClient: error CallToolResult with message
  else either is present
    withInvalidArgumentsAsToolErrors-->>MCPClient: propagate InvalidParams
  end
Loading

Possibly related issues

Possibly related PRs

  • pingdotgg/t3code#35729: This PR makes the same middleware change and updates tests to expect error tool results.

Suggested labels: bugfix

Suggested reviewers: minilaolao, juliusmarminge, macroscopeapp

Merge Risk: Minimal · up to 287c3

Invalid tool arguments will now reach claude.ai as tool errors that name the bad argument. The change is small and covered by updated tests, and no merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: toolkit tool-argument validation failures now reach claude.ai as tool errors that name the invalid argument. The raw summary shows the wrapper withInvalidArgumentsAsTo…
Description check Passed The description follows the template sections: Problem, Change, Scope, and Verification. It states the bug, the fix, why no issue link is needed for a small obvious bug, and the tests run with their r…
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 tool-argument validation failures now reach claude.ai as tool errors that name the invalid argument. The raw summary shows the wrapper withInvalidArgumentsAsToolErrors and the test updates that match this claim. The title is 78 characters, slightly long, but it is specific and conventional.

Full details: Description check

Explanation

The description follows the template sections: Problem, Change, Scope, and Verification. It states the bug, the fix, why no issue link is needed for a small obvious bug, and the tests run with their results. It also notes the uncovered continuation-call path and names the model and harness. It does not link an issue or CONTRIBUTING.md, and it does not mention a reproduction environment beyond claude.ai under MCP 2025-06-18. These gaps are minor.

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 7f15ce2 and 287c391.

Files selected for processing: 1

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

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 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

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

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