Update src/server/streamableHttp.ts

Co-authored-by: Cliff Hall <cliff@futurescale.com>
This commit is contained in:
qikaigao 2025-04-17 11:08:34 -07:00 • committed by GitHub
commit 0058c30032
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -463,7 +463,12 @@ export class StreamableHTTPServerTransport implements Transport {
* Returns true if the session is valid, false otherwise
*/
private validateSession(req: IncomingMessage, res: ServerResponse): boolean {
if (this.sessionId && !this._initialized) {
if (this.sessionId === undefined) {
// If the session ID is not set, the session management is disabled
// and we don't need to validate the session ID
return true;
}
if (!this._initialized) {
// If the server has not been initialized yet, reject all requests
res.writeHead(400).end(JSON.stringify({
jsonrpc: "2.0",