Skip to content

StreamableHttp -- resumability support for servers #587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 57 commits into from
May 2, 2025

Conversation

ihrpr
Copy link
Contributor

@ihrpr ihrpr commented Apr 25, 2025

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 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
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?

Copy link
Contributor Author

@ihrpr ihrpr Apr 25, 2025

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 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
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)
if last_event_id:
await self._replay_events(last_event_id, request, send)
return
if last_event_id := request.headers.get(LAST_EVENT_ID_HEADER):
await self._replay_events(last_event_id, request, send)
return

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

The base branch was changed.

@ihrpr ihrpr merged commit 3978c6e into main May 2, 2025
9 checks passed
@ihrpr ihrpr deleted the ihrpr/resumability-server branch May 2, 2025 13:10
Sign up for free to 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