modelcontextprotocol / modelcontextprotocol/csharp-sdk

Add DeleteStreamsForSessionAsync to ISseEventStreamStore

Open
#1,287 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement P3 ready for work
Dominant language
C#
Stars
4.5k
Forks
814
Avg merge
9d 19h
Merged PRs (30d)
4

Description

Is your feature request related to a problem? Please describe.

When an MCP session ends, the SSE event streams stored by ISseEventStreamStore for that session are not proactively cleaned up. They persist until cache expiration removes them. This wastes storage, especially in high-throughput scenarios with many short-lived sessions.

Describe the solution you'd like

Add a DeleteStreamsForSessionAsync(string sessionId, CancellationToken) method to ISseEventStreamStore that deletes all stored streams and their associated events for a given session.

Describe alternatives you've considered

An alternative is to rely solely on cache expiration to keep resource consumption low. Since it is relatively easy to catch session terminations (with RunSessionHandler), it seems reasonable to provide a means to delete the streams for this session since they are known to be no longer needed.

Additional context

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 ISseEventStreamStore and trace its implementations and callers, especially session termination through RunSessionHandler. Add the requested asynchronous deletion operation and verify that all streams and associated events for the given session are removed, with cancellation supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.