@@ -406,8 +406,6 @@ export class StreamableHTTPServerTransport implements Transport {
406
406
407
407
if ( allResponsesReady ) {
408
408
if ( this . _enableJsonResponse ) {
409
- // If we are in SSE mode, we don't need to do anything else
410
-
411
409
// All responses ready, send as JSON
412
410
const headers : Record < string , string > = {
413
411
'Content-Type' : 'application/json' ,
@@ -416,18 +414,7 @@ export class StreamableHTTPServerTransport implements Transport {
416
414
headers [ 'mcp-session-id' ] = this . sessionId ;
417
415
}
418
416
419
- // In tests, relatedIds might be coming in non-deterministic order
420
- // We need to sort numerically for numeric IDs, alphabetically for string IDs
421
417
const responses = relatedIds
422
- . sort ( ( a , b ) => {
423
- // If both IDs are numbers, sort numerically
424
- if ( typeof a === 'number' && typeof b === 'number' ) {
425
- return a - b ;
426
- }
427
-
428
- // Otherwise sort by string lexical order
429
- return String ( a ) . localeCompare ( String ( b ) ) ;
430
- } )
431
418
. map ( id => this . _requestResponseMap . get ( id ) ! ) ;
432
419
433
420
response . writeHead ( 200 , headers ) ;
@@ -437,6 +424,7 @@ export class StreamableHTTPServerTransport implements Transport {
437
424
response . end ( JSON . stringify ( responses ) ) ;
438
425
}
439
426
} else {
427
+ // End the SSE stream
440
428
response . end ( ) ;
441
429
}
442
430
// Clean up
0 commit comments