Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/run/legacy-clients.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ On one worker that is invisible. On two, it is the whole problem: a request that
events to a client reconnecting to the *same* session), not a session store. It never makes a
session reachable from another process.

!!! note "Request cleanup preserves newer streams"
Closing an HTTP request releases its own streams, including during cancellation.
If you reuse a JSON-RPC request ID after the previous request completes, cleanup from an
older connection does not close the newer request's streams. This does not reserve request IDs.

## Session lifetime and limits

A legacy session does not live forever, and one process does not hold an unlimited number of
Expand Down
10 changes: 9 additions & 1 deletion src/mcp/server/sse.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,15 @@ async def sse_writer():
)

try:
async with anyio.create_task_group() as tg:
async with (
read_stream_writer,
read_stream,
write_stream,
write_stream_reader,
sse_stream_writer,
sse_stream_reader,
anyio.create_task_group() as tg,
):

async def response_wrapper(scope: Scope, receive: Receive, send: Send):
"""The EventSourceResponse returning signals a client close / disconnect.
Expand Down
Loading
Loading