fix: return protocol errors for invalid tool args - #2163
Conversation
🦋 Changeset detectedLatest commit: 58dc27d The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
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 |
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
d683549 to
7641e96
Compare
|
CI note: I checked the remaining red Node 20 job. The invalid-argument coverage added in this PR passes in that run; the failure is in test/server/cloudflareWorkers.test.ts with a Miniflare network connection lost error, which is outside the touched server validation path. I also tried to rerun the failed job, but GitHub requires repo admin rights for that. |
7641e96 to
e814d61
Compare
|
Rebased on current Validated locally:
The pre-push hook also completed the repo-wide build, typecheck, and lint steps successfully. |
e814d61 to
5ef13fd
Compare
|
Rebased and force-pushed the branch. I also updated the e2e contract expectations so invalid tool arguments now assert JSON-RPC -32602 instead of an isError tool result. Targeted validation passed:
One combined e2e invocation hit a Vitest worker process exit after the relevant files had already run; rerunning the scenarios individually passed, so I split the validation above. The push hook also completed the repo-level build/typecheck/lint successfully. |
|
Rebased onto current Focused validation after the rebase: Result: server I also tried the touched e2e file: That is blocked locally before collecting tests because the current workspace install cannot resolve |
52a087b to
2223551
Compare
2223551 to
0c8eaef
Compare
|
One more try on this. Invalid tool arguments currently escape as generic errors instead of the protocol's InvalidParams shape, which makes client-side handling guesswork. The patch maps them onto the proper protocol error and adds coverage for the malformed cases. |
…tocol-error # Conflicts: # packages/server/test/server/mcp.compat.test.ts # test/integration/test/server/mcp.test.ts # test/integration/test/standardSchema.test.ts
Summary
To verify
Fixes #2162