Skip to content

StreamableHttp -- resumability support for servers - #587

Merged
ihrpr merged 57 commits into
mainfrom
ihrpr/resumability-server
May 2, 2025
Merged

StreamableHttp -- resumability support for servers#587
ihrpr merged 57 commits into
mainfrom
ihrpr/resumability-server

Conversation

@ihrpr

@ihrprihrpr commented Apr 25, 2025

Copy link
Copy Markdown
Contributor

Adding support for resumability to servers.

As we already have Typescript client that support resumability, testing it with it and the follow up is to add support for resumability on typescript client.
###How to test:

Start Python example server:

uv run mcp-simple-streamablehttp --log-level DEBUG

In the new terminal start Typescript client

npx tsx src/examples/client/simpleStreamableHttp.ts

Follow steps:

  • type start-notifications 10 10
  • wait 20 seconds -
  • press esc and Enter
  • type connect
  • type start-notifications 10 10 - you'll see missing events were replayed and the tool continues to send notifications

stacked on top of #573

Comment threadsrc/mcp/server/streamableHttp.py Outdated
Comment threadsrc/mcp/server/streamableHttp.py Outdated
Comment threadsrc/mcp/server/streamableHttp.py Outdated
Comment threadsrc/mcp/server/streamableHttp.py Outdated
Comment threadsrc/mcp/server/streamableHttp.py Outdated
Comment on lines +764 to +767
msg_writer, msg_reader = anyio.create_memory_object_stream[
tuple[JSONRPCMessage, str | None]
](0)
self._request_streams[stream_id] = msg_writer

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this cause leaking streams and unclosed resources?

@ihrprihrprApr 25, 2025

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have a separate PR to review all resources and close them: #604

dsp-ant
dsp-ant previously approved these changes May 2, 2025
Comment threadsrc/mcp/server/streamable_http.py Outdated
Comment on lines +551 to +554
last_event_id = request.headers.get(LAST_EVENT_ID_HEADER)
if last_event_id:
await self._replay_events(last_event_id, request, send)
return

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
last_event_id=request.headers.get(LAST_EVENT_ID_HEADER)
iflast_event_id:
awaitself._replay_events(last_event_id, request, send)
return
iflast_event_id:=request.headers.get(LAST_EVENT_ID_HEADER):
awaitself._replay_events(last_event_id, request, send)
return

Base automatically changed from ihrpr/client to mainMay 2, 2025 12:59
@ihrpr
ihrpr dismissed dsp-ant’s stale reviewMay 2, 2025 12:59

The base branch was changed.

@ihrpr
ihrpr merged commit 3978c6e into mainMay 2, 2025
@ihrpr
ihrpr deleted the ihrpr/resumability-server branch May 2, 2025 13:10
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@ihrpr@dsp-ant