Skip to content

Commit a51fea3

Browse files
committed
Merge remote-tracking branch 'qikaigao/patch-1' into ihrpr/example-clients
2 parents 39f7fdf + 88f962d commit a51fea3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/server/streamableHttp.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,11 @@ export class StreamableHTTPServerTransport implements Transport {
463463
* Returns true if the session is valid, false otherwise
464464
*/
465465
private validateSession(req: IncomingMessage, res: ServerResponse): boolean {
466+
if (this.sessionId === undefined) {
467+
// If the session ID is not set, the session management is disabled
468+
// and we don't need to validate the session ID
469+
return true;
470+
}
466471
if (!this._initialized) {
467472
// If the server has not been initialized yet, reject all requests
468473
res.writeHead(400).end(JSON.stringify({
@@ -475,11 +480,7 @@ export class StreamableHTTPServerTransport implements Transport {
475480
}));
476481
return false;
477482
}
478-
if (this.sessionId === undefined) {
479-
// If the session ID is not set, the session management is disabled
480-
// and we don't need to validate the session ID
481-
return true;
482-
}
483+
483484
const sessionId = req.headers["mcp-session-id"];
484485

485486
if (!sessionId) {

0 commit comments

Comments
 (0)