Skip to content

Commit 49fa6c2

Browse files
committed
Fix resumption token updates
1 parent 103e201 commit 49fa6c2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/mcp/client/streamable_http.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,14 @@ async def _handle_sse_event(
161161
session_message = SessionMessage(message)
162162
await read_stream_writer.send(session_message)
163163

164-
# Call resumption token callback if we have an ID
165-
if sse.id and resumption_callback:
164+
# Call resumption token callback if we have an ID. Only update
165+
# the resumption token on notifications to avoid overwriting it
166+
# with the token from the final response.
167+
if (
168+
sse.id
169+
and resumption_callback
170+
and not isinstance(message.root, JSONRPCResponse | JSONRPCError)
171+
):
166172
await resumption_callback(sse.id)
167173

168174
# If this is a response or error return True indicating completion

0 commit comments

Comments
 (0)