modelcontextprotocol / modelcontextprotocol/typescript-sdk

storeEvent in EventStore Receives Hardcoded `streamId`

Open
#1,004 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug

I'm writing an EventStore using Redis. There can be several users, whose data must be seperate. But since streamId is sometimes hardcoded as _GET_stream, I can't distinguish the users in storeEvent. If I do something like the one in InMemoryEventStore, I think all users will be able to read the same stream (_GET_stream)

To Reproduce

Steps to reproduce the behavior:

  1. Add a console.log to storeEvent method of InMemoryEventStore
async storeEvent(streamId: string, message: JSONRPCMessage): Promise<string> {
  const eventId = this.generateEventId(streamId);
  console.log(streamId, eventId);
  
  this.events.set(eventId, { streamId, message });
  return eventId;
}
  1. Start server at src/examples/server/simpleStreamableHttp.ts
  2. Start client at src/examples/client/simpleStreamableHttp.ts
  3. In the client, run multi-greet hey
  4. Check the logs of the server:
_GET_stream _GET_stream_1759497356533_y5aw8vh7
_GET_stream _GET_stream_1759497357535_3hvrf2jx
_GET_stream _GET_stream_1759497358537_5pb6ci89

streamId is _GET_stream in each one. Yes, eventId makes it possible to differenciate them. In replayEventsAfter, these events are sorted and returned after the lastEventId. But now imagine that this is in production and this.events is a list or stream on Redis. All users get the same streamId in storeEvent. There is no way to differentiate their streams.

Expected behavior

There should be a way to differentiate users in storeEvent, instead of getting the same streamId.

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 with src/server/streamableHttp.ts, especially storeEvent, replayEventsAfter, and the streamId call sites, then compare src/examples/shared/inMemoryEventStore.ts and the simpleStreamableHttp server and client examples. Reproduce the multi-greet request and trace how stream IDs are assigned. Done means an EventStore can distinguish independent users and replay only the appropriate events without breaking the existing examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
redis, typescript
Domain
api, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.