modelcontextprotocol / modelcontextprotocol/typescript-sdk

Spec-method requests with invalid params answer -32603 instead of -32602

Open
#2,284 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug fix proposed P2 ready for work v2 v2-fixes
Dominant language
TypeScript
Stars
13.4k
Forks
2.2k
Avg merge
3d 15h
Merged PRs (30d)
4

Description

When a built-in spec method receives schema-invalid params (e.g. logging/setLevel with { level: 'not-a-level' }), the dispatch-time parse failure (protocol.ts:915) escapes as a raw ZodError and hits the generic wrap (protocol.ts:562), which defaults non-numeric codes to -32603 InternalError.

JSON-RPC 2.0 assigns invalid method parameters -32602, so callers sending bad params are currently told the server broke rather than that their params were wrong.

Mapping the dispatch-time parse failure to ProtocolError(InvalidParams) fixes it. Wire-visible, so it needs a changeset — deployed peers may match on the current -32603.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/core/src/shared/protocol.ts at the dispatch-time parse failure near line 915, then trace how the generic wrap near line 562 assigns the error code. Confirm schema-invalid spec-method parameters produce JSON-RPC -32602 rather than -32603, and add the requested changeset for the wire-visible behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.