-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
examples/servers/simple-streamablehttp/mcp_simple_streamablehttp/event_store.py
Outdated
Show resolved
Hide resolved
examples/servers/simple-streamablehttp/mcp_simple_streamablehttp/event_store.py
Outdated
Show resolved
Hide resolved
examples/servers/simple-streamablehttp/mcp_simple_streamablehttp/event_store.py
Outdated
Show resolved
Hide resolved
examples/servers/simple-streamablehttp/mcp_simple_streamablehttp/event_store.py
Outdated
Show resolved
Hide resolved
examples/servers/simple-streamablehttp/mcp_simple_streamablehttp/event_store.py
Outdated
Show resolved
Hide resolved
src/mcp/server/streamableHttp.py
Outdated
msg_writer, msg_reader = anyio.create_memory_object_stream[ | ||
tuple[JSONRPCMessage, str | None] | ||
](0) | ||
self._request_streams[stream_id] = msg_writer |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
src/mcp/server/streamable_http.py
Outdated
last_event_id = request.headers.get(LAST_EVENT_ID_HEADER) | ||
if last_event_id: | ||
await self._replay_events(last_event_id, request, send) | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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:
In the new terminal start Typescript client
Follow steps:
start-notifications 10 10
esc
andEnter
connect
start-notifications 10 10
- you'll see missing events were replayed and the tool continues to send notificationsstacked on top of #573