From f0fbfc7fcbc1489177f5c81cad7f49ba88b8244e Mon Sep 17 00:00:00 2001 From: qikaigao <33371207+qikaigao@users.noreply.github.com> Date: Mon, 14 Apr 2025 00:46:13 -0700 Subject: [PATCH] StreamableHTTPServerTransport should only check init status when there is an sessionId When using stateless mode, the backend will create a new transport for each request. For new transport, the initialized filed is always false. So we should only check the initialized filed if there is session existing --- src/server/streamableHttp.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/streamableHttp.ts b/src/server/streamableHttp.ts index ec8d2aa7..fc13e762 100644 --- a/src/server/streamableHttp.ts +++ b/src/server/streamableHttp.ts @@ -371,7 +371,7 @@ export class StreamableHTTPServerTransport implements Transport { * Returns true if the session is valid, false otherwise */ private validateSession(req: IncomingMessage, res: ServerResponse): boolean { - if (!this._initialized) { + if (this.sessionId && !this._initialized) { // If the server has not been initialized yet, reject all requests res.writeHead(400).end(JSON.stringify({ jsonrpc: "2.0",