Skip to content
Open
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
6 changes: 4 additions & 2 deletions src/mcp/client/streamable_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,11 @@ async def _handle_sse_response(
is_initialization=is_initialization,
)
# If the SSE event indicates completion, like returning response/error
# break the loop
# break the loop. Drain the SSE stream to EOF instead of
# closing early — an aclose() before EOF leaves the keepalive
# connection in a half-drained state, causing ~260ms latency
# on the next request that reuses the same connection.
if is_complete:
await response.aclose()
return # Normal completion, no reconnect needed
except Exception:
logger.debug("SSE stream ended", exc_info=True) # pragma: no cover
Expand Down
Loading