Skip to content

Return protocol errors for invalid tool arguments#2169

Open
FU-max-boop wants to merge 3 commits into
modelcontextprotocol:mainfrom
FU-max-boop:fix/invalid-tool-args-protocol-error
Open

Return protocol errors for invalid tool arguments#2169
FU-max-boop wants to merge 3 commits into
modelcontextprotocol:mainfrom
FU-max-boop:fix/invalid-tool-args-protocol-error

Conversation

@FU-max-boop
Copy link
Copy Markdown

Summary

  • propagate ProtocolError from high-level tools/call handling instead of wrapping it as a CallToolResult error
  • keep ordinary tool handler exceptions as tool execution errors
  • add an in-memory regression test showing invalid tool arguments return JSON-RPC InvalidParams and do not invoke the handler

Fixes #2162

Tests

  • npx -y pnpm@10.26.1 --dir packages/server exec vitest run test/server/mcp.compat.test.ts
  • npx -y pnpm@10.26.1 --dir packages/server exec eslint src/server/mcp.ts test/server/mcp.compat.test.ts
  • npx -y pnpm@10.26.1 --dir packages/server exec prettier --ignore-path ../../.prettierignore --check src/server/mcp.ts test/server/mcp.compat.test.ts
  • npx -y pnpm@10.26.1 --dir packages/server run typecheck

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

changeset-bot Bot commented May 28, 2026

🦋 Changeset detected

Latest commit: e307e57

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@2169

@modelcontextprotocol/codemod

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

@modelcontextprotocol/server

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

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: e307e57

@FU-max-boop FU-max-boop force-pushed the fix/invalid-tool-args-protocol-error branch from c8ee820 to 2a4e1d5 Compare May 28, 2026 20:15
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