@@ -8,17 +8,17 @@ import { z } from "zod";
88import { AuthInfo } from "./auth/types.js" ;
99
1010async function getFreePort ( ) {
11- return new Promise ( res => {
12- const srv = netCreateServer ( ) ;
13- srv . listen ( 0 , ( ) => {
14- const address = srv . address ( ) !
15- if ( typeof address === "string" ) {
16- throw new Error ( "Unexpected address type: " + typeof address ) ;
17- }
18- const port = ( address as AddressInfo ) . port ;
19- srv . close ( ( err ) => res ( port ) )
20- } ) ;
21- } )
11+ return new Promise ( res => {
12+ const srv = netCreateServer ( ) ;
13+ srv . listen ( 0 , ( ) => {
14+ const address = srv . address ( ) !
15+ if ( typeof address === "string" ) {
16+ throw new Error ( "Unexpected address type: " + typeof address ) ;
17+ }
18+ const port = ( address as AddressInfo ) . port ;
19+ srv . close ( ( _err ) => res ( port ) )
20+ } ) ;
21+ } )
2222}
2323
2424/**
@@ -377,7 +377,7 @@ describe("StreamableHTTPServerTransport", () => {
377377 return { content : [ { type : "text" , text : `Hello, ${ name } !` } , { type : "text" , text : `${ JSON . stringify ( requestInfo ) } ` } ] } ;
378378 }
379379 ) ;
380-
380+
381381 const toolCallMessage : JSONRPCMessage = {
382382 jsonrpc : "2.0" ,
383383 method : "tools/call" ,
@@ -828,7 +828,7 @@ describe("StreamableHTTPServerTransport", () => {
828828
829829 // Send request with matching protocol version
830830 const response = await sendPostRequest ( baseUrl , TEST_MESSAGES . toolsList , sessionId ) ;
831-
831+
832832 expect ( response . status ) . toBe ( 200 ) ;
833833 } ) ;
834834
@@ -846,7 +846,7 @@ describe("StreamableHTTPServerTransport", () => {
846846 } ,
847847 body : JSON . stringify ( TEST_MESSAGES . toolsList ) ,
848848 } ) ;
849-
849+
850850 expect ( response . status ) . toBe ( 200 ) ;
851851 } ) ;
852852
@@ -864,21 +864,21 @@ describe("StreamableHTTPServerTransport", () => {
864864 } ,
865865 body : JSON . stringify ( TEST_MESSAGES . toolsList ) ,
866866 } ) ;
867-
867+
868868 expect ( response . status ) . toBe ( 400 ) ;
869869 const errorData = await response . json ( ) ;
870870 expectErrorResponse ( errorData , - 32000 , / B a d R e q u e s t : U n s u p p o r t e d p r o t o c o l v e r s i o n \( s u p p o r t e d v e r s i o n s : .+ \) / ) ;
871871 } ) ;
872872
873873 it ( "should accept when protocol version differs from negotiated version" , async ( ) => {
874874 sessionId = await initializeServer ( ) ;
875-
875+
876876 // Spy on console.warn to verify warning is logged
877877 const warnSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ) ;
878878
879879 // Send request with different but supported protocol version
880880 const response = await fetch ( baseUrl , {
881- method : "POST" ,
881+ method : "POST" ,
882882 headers : {
883883 "Content-Type" : "application/json" ,
884884 Accept : "application/json, text/event-stream" ,
@@ -887,10 +887,10 @@ describe("StreamableHTTPServerTransport", () => {
887887 } ,
888888 body : JSON . stringify ( TEST_MESSAGES . toolsList ) ,
889889 } ) ;
890-
890+
891891 // Request should still succeed
892892 expect ( response . status ) . toBe ( 200 ) ;
893-
893+
894894 warnSpy . mockRestore ( ) ;
895895 } ) ;
896896
@@ -906,7 +906,7 @@ describe("StreamableHTTPServerTransport", () => {
906906 "mcp-protocol-version" : "invalid-version" ,
907907 } ,
908908 } ) ;
909-
909+
910910 expect ( response . status ) . toBe ( 400 ) ;
911911 const errorData = await response . json ( ) ;
912912 expectErrorResponse ( errorData , - 32000 , / B a d R e q u e s t : U n s u p p o r t e d p r o t o c o l v e r s i o n \( s u p p o r t e d v e r s i o n s : .+ \) / ) ;
@@ -923,7 +923,7 @@ describe("StreamableHTTPServerTransport", () => {
923923 "mcp-protocol-version" : "invalid-version" ,
924924 } ,
925925 } ) ;
926-
926+
927927 expect ( response . status ) . toBe ( 400 ) ;
928928 const errorData = await response . json ( ) ;
929929 expectErrorResponse ( errorData , - 32000 , / B a d R e q u e s t : U n s u p p o r t e d p r o t o c o l v e r s i o n \( s u p p o r t e d v e r s i o n s : .+ \) / ) ;
@@ -965,12 +965,12 @@ describe("StreamableHTTPServerTransport with AuthInfo", () => {
965965 method : "tools/call" ,
966966 params : {
967967 name : "profile" ,
968- arguments : { active : true } ,
968+ arguments : { active : true } ,
969969 } ,
970970 id : "call-1" ,
971971 } ;
972972
973- const response = await sendPostRequest ( baseUrl , toolCallMessage , sessionId , { 'authorization' : 'Bearer test-token' } ) ;
973+ const response = await sendPostRequest ( baseUrl , toolCallMessage , sessionId , { 'authorization' : 'Bearer test-token' } ) ;
974974 expect ( response . status ) . toBe ( 200 ) ;
975975
976976 const text = await readSSEEvent ( response ) ;
@@ -992,7 +992,7 @@ describe("StreamableHTTPServerTransport with AuthInfo", () => {
992992 id : "call-1" ,
993993 } ) ;
994994 } ) ;
995-
995+
996996 it ( "should calls tool without authInfo when it is optional" , async ( ) => {
997997 sessionId = await initializeServer ( ) ;
998998
@@ -1001,7 +1001,7 @@ describe("StreamableHTTPServerTransport with AuthInfo", () => {
10011001 method : "tools/call" ,
10021002 params : {
10031003 name : "profile" ,
1004- arguments : { active : false } ,
1004+ arguments : { active : false } ,
10051005 } ,
10061006 id : "call-1" ,
10071007 } ;
@@ -1485,7 +1485,7 @@ describe("StreamableHTTPServerTransport in stateless mode", () => {
14851485 // Open first SSE stream
14861486 const stream1 = await fetch ( baseUrl , {
14871487 method : "GET" ,
1488- headers : {
1488+ headers : {
14891489 Accept : "text/event-stream" ,
14901490 "mcp-protocol-version" : "2025-03-26"
14911491 } ,
@@ -1495,7 +1495,7 @@ describe("StreamableHTTPServerTransport in stateless mode", () => {
14951495 // Open second SSE stream - should still be rejected, stateless mode still only allows one
14961496 const stream2 = await fetch ( baseUrl , {
14971497 method : "GET" ,
1498- headers : {
1498+ headers : {
14991499 Accept : "text/event-stream" ,
15001500 "mcp-protocol-version" : "2025-03-26"
15011501 } ,
0 commit comments