modelcontextprotocol / modelcontextprotocol/typescript-sdk
storeEvent in EventStore Receives Hardcoded `streamId`
Nobody has claimed this yet.
- 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:
- Add a console.log to
storeEventmethod ofInMemoryEventStore
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;
}
- Start server at
src/examples/server/simpleStreamableHttp.ts - Start client at
src/examples/client/simpleStreamableHttp.ts - In the client, run
multi-greet hey - 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
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 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