Skip to content

Conversation

@mattzcarey
Copy link
Contributor

Summary

  • Add ReceiveRequestMethod generic parameter to Protocol class
  • Client.setRequestHandler() now only accepts server-to-client methods (sampling/createMessage, elicitation/create, roots/list)
  • Server.setRequestHandler() now only accepts client-to-server methods (tools/call, prompts/get, resources/read, etc.)

This prevents accidentally registering handlers for wrong method types, following up on #1446.

The approach uses a generic type parameter on Protocol rather than @ts-expect-error comments, making it a clean TypeScript solution.

Test plan

  • All tests pass (485/485)
  • Type checking passes

🤖 Generated with Claude Code

- Add ReceiveRequestMethod generic parameter to Protocol class
- Client.setRequestHandler() now only accepts server-to-client methods
  (sampling/createMessage, elicitation/create, roots/list)
- Server.setRequestHandler() now only accepts client-to-server methods
  (tools/call, prompts/get, resources/read, etc.)

This prevents accidentally registering handlers for wrong method types.
@mattzcarey mattzcarey requested a review from a team as a code owner February 3, 2026 10:58
@changeset-bot
Copy link

changeset-bot bot commented Feb 3, 2026

⚠️ No Changeset found

Latest commit: a886553

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 3, 2026

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/server

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

@modelcontextprotocol/express

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: a886553

@mattzcarey mattzcarey marked this pull request as draft February 3, 2026 11:51
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.

2 participants