modelcontextprotocol / modelcontextprotocol/typescript-sdk
Spec-method requests with invalid params answer -32603 instead of -32602
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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