modelcontextprotocol / modelcontextprotocol/typescript-sdk

Allow receiving messages per stream in client sdk

Open
#387 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement needs decision P3
Dominant language
TypeScript
Stars
13.4k
Forks
2.2k
Avg merge
3d 15h
Merged PRs (30d)
4

Description

Is your feature request related to a problem? Please describe.
Currently the client SDK allows getting progress notifications per request but it does not allow receiving notifications per request. The notification handler is more of a global receiver of all notifications, but it does not surface the event ids associated with the messages. This means if a client has multiple streaming calls going on in parallel, there's no way to delineate the logging per request.

Describe the solution you'd like
I'd like to be able to receive any streaming messages for requests in the same way that we can receive progress notifications. Something like the following:

    const result = await client.request(request, CallToolResultSchema, {
      onprogress: (p) => console.log('Progress notification for this request => ', p),
      onmessage: (m) => console.log('Message notification for this request => ', m)
    });

Describe alternatives you've considered
Alternatively we've considered writing a custom transport to surface this information. We're just not quite sure whether the lack of request level message tracking is an intentional decision or not.

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 at the client.request API and its existing onprogress handling, then trace how streaming notifications are routed by the SDK. Verify how a request-scoped onmessage callback could preserve message or event association for parallel streams; the issue names no files or test paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.