Skip to content

Commit 7e02ddd

Browse files
authored
fix-test_streamablehttp_client_resumption-failure
Fix resumption token whitespace handling
2 parents 9b5ef4d + a0d24ca commit 7e02ddd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/mcp/client/streamable_http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ async def _handle_sse_event(
169169
and resumption_callback
170170
and not isinstance(message.root, JSONRPCResponse | JSONRPCError)
171171
):
172-
await resumption_callback(sse.id)
172+
await resumption_callback(sse.id.strip())
173173

174174
# If this is a response or error return True indicating completion
175175
# Otherwise, return False to continue listening
@@ -218,7 +218,7 @@ async def _handle_resumption_request(self, ctx: RequestContext) -> None:
218218
"""Handle a resumption request using GET with SSE."""
219219
headers = self._update_headers_with_session(ctx.headers)
220220
if ctx.metadata and ctx.metadata.resumption_token:
221-
headers[LAST_EVENT_ID] = ctx.metadata.resumption_token
221+
headers[LAST_EVENT_ID] = ctx.metadata.resumption_token.strip()
222222
else:
223223
raise ResumptionError("Resumption request requires a resumption token")
224224

0 commit comments

Comments
 (0)