Skip to content

Return protocol errors for invalid tool arguments#2173

Closed
FU-max-boop wants to merge 1 commit into
modelcontextprotocol:mainfrom
FU-max-boop:fix/tool-argument-protocol-error
Closed

Return protocol errors for invalid tool arguments#2173
FU-max-boop wants to merge 1 commit into
modelcontextprotocol:mainfrom
FU-max-boop:fix/tool-argument-protocol-error

Conversation

@FU-max-boop
Copy link
Copy Markdown

Summary

Fixes #2162.

Invalid tool arguments are request-level validation failures, but McpServer was wrapping input schema validation failures in a CallToolResult with isError: true. This rethrows input validation ProtocolErrorCode.InvalidParams errors so clients receive a protocol error for malformed tool calls, while preserving tool execution errors as CallToolResult failures.

The tests update the existing Zod, union, ArkType, Valibot, and JSON Schema invalid-input cases to assert InvalidParams instead of tool error content.

Tests

  • npx -y pnpm@10.26.1 --filter @modelcontextprotocol/server test -- mcp.test.ts standardSchema.test.ts
  • npx -y pnpm@10.26.1 --filter @modelcontextprotocol/server lint
  • npx -y pnpm@10.26.1 --filter @modelcontextprotocol/server typecheck
  • npx -y pnpm@10.26.1 --filter @modelcontextprotocol/server build
  • git diff --check HEAD~1..HEAD

Note: git push hit repeated network timeouts to github.com:443 from this environment, so I created the fork branch via the GitHub Git Data API after the local checks passed.

@FU-max-boop FU-max-boop requested a review from a team as a code owner May 28, 2026 22:14
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 28, 2026

🦋 Changeset detected

Latest commit: eaf4444

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 28, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@2173

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/codemod@2173

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@2173

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@2173

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/fastify@2173

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@2173

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@2173

commit: eaf4444

@FU-max-boop
Copy link
Copy Markdown
Author

CI note: the Node 20/22 failures are both in test/server/cloudflareWorkers.test.ts with Miniflare reporting Network connection lost. The Node 24 job passed the same suite, and the local server-focused checks in the PR body passed. I tried to rerun failed jobs, but GitHub requires repository admin rights for reruns from this fork.

@FU-max-boop
Copy link
Copy Markdown
Author

Closing this because it duplicates my earlier PR #2169 for the same issue (#2162). #2169 is already open and has the full check suite green, so keeping one thread should be easier for maintainers.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

invalid argument should throw protocol error, rather than tool execution error

1 participant