From e291f7238720a9507f54ed6abe4b0ad7d1ff6fd2 Mon Sep 17 00:00:00 2001 From: Liu Zixian Date: Tue, 16 Dec 2025 13:13:46 +0800 Subject: [PATCH] Handle 204 No Content status in response processing Fixes https://github.com/modelcontextprotocol/typescript-sdk/issues/1303 --- src/client/streamableHttp.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/client/streamableHttp.ts b/src/client/streamableHttp.ts index 736587973..1074c7891 100644 --- a/src/client/streamableHttp.ts +++ b/src/client/streamableHttp.ts @@ -555,9 +555,11 @@ export class StreamableHTTPClientTransport implements Transport { this._hasCompletedAuthFlow = false; this._lastUpscopingHeader = undefined; - // If the response is 202 Accepted, there's no body to process - if (response.status === 202) { - await response.body?.cancel(); + // If the response is 202 Accepted or 204 No Content, there's no body to process + if (response.status === 202 || response.status === 204) { + if (response.status === 202) { + await response.body?.cancel(); + } // if the accepted notification is initialized, we start the SSE stream // if it's supported by the server if (isInitializedNotification(message)) {