@@ -73,7 +73,7 @@ describe("StreamableHTTPServerTransport", () => {
7373 method : "POST" ,
7474 headers : {
7575 "content-type" : "application/json" ,
76- "accept" : "application/json" ,
76+ "accept" : "application/json, text/event-stream " ,
7777 } ,
7878 body : JSON . stringify ( initializeMessage ) ,
7979 } ) ;
@@ -93,7 +93,7 @@ describe("StreamableHTTPServerTransport", () => {
9393 method : "GET" ,
9494 headers : {
9595 "mcp-session-id" : "invalid-session-id" ,
96- "accept" : "text/event-stream"
96+ "accept" : "application/json, text/event-stream"
9797 } ,
9898 } ) ;
9999
@@ -109,7 +109,7 @@ describe("StreamableHTTPServerTransport", () => {
109109 const req = createMockRequest ( {
110110 method : "GET" ,
111111 headers : {
112- accept : "text/event-stream" ,
112+ accept : "application/json, text/event-stream" ,
113113 // No mcp-session-id header
114114 } ,
115115 } ) ;
@@ -143,7 +143,7 @@ describe("StreamableHTTPServerTransport", () => {
143143 method : "POST" ,
144144 headers : {
145145 "content-type" : "application/json" ,
146- "accept" : "application/json" ,
146+ "accept" : "application/json, text/event-stream " ,
147147 } ,
148148 body : JSON . stringify ( message ) ,
149149 } ) ;
@@ -161,7 +161,7 @@ describe("StreamableHTTPServerTransport", () => {
161161 method : "POST" ,
162162 headers : {
163163 "content-type" : "application/json" ,
164- "accept" : "application/json" ,
164+ "accept" : "application/json, text/event-stream " ,
165165 "mcp-session-id" : "invalid-session-id" , // This would cause a 404 in stateful mode
166166 } ,
167167 body : JSON . stringify ( {
@@ -195,7 +195,7 @@ describe("StreamableHTTPServerTransport", () => {
195195 method : "POST" ,
196196 headers : {
197197 "content-type" : "application/json" ,
198- "accept" : "application/json" ,
198+ "accept" : "application/json, text/event-stream " ,
199199 "mcp-session-id" : "non-existent-session-id" , // This would be rejected in stateful mode
200200 } ,
201201 body : JSON . stringify ( message ) ,
@@ -216,7 +216,7 @@ describe("StreamableHTTPServerTransport", () => {
216216 method : "POST" ,
217217 headers : {
218218 "content-type" : "application/json" ,
219- accept : "text/event-stream" ,
219+ accept : "application/json, text/event-stream" ,
220220 } ,
221221 body : JSON . stringify ( {
222222 jsonrpc : "2.0" ,
@@ -242,7 +242,7 @@ describe("StreamableHTTPServerTransport", () => {
242242 method : "POST" ,
243243 headers : {
244244 "content-type" : "application/json" ,
245- accept : "text/event-stream" ,
245+ accept : "application/json, text/event-stream" ,
246246 "mcp-session-id" : "some-random-session-id" ,
247247 } ,
248248 body : JSON . stringify ( {
@@ -264,7 +264,7 @@ describe("StreamableHTTPServerTransport", () => {
264264 ) ;
265265 } ) ;
266266
267- it ( "should handle initialization requests properly in statefull mode" , async ( ) => {
267+ it ( "should handle initialization requests properly in stateful mode" , async ( ) => {
268268 // Initialize message that would typically be sent during initialization
269269 const initializeMessage : JSONRPCMessage = {
270270 jsonrpc : "2.0" ,
@@ -281,7 +281,7 @@ describe("StreamableHTTPServerTransport", () => {
281281 method : "POST" ,
282282 headers : {
283283 "content-type" : "application/json" ,
284- "accept" : "application/json" ,
284+ "accept" : "application/json, text/event-stream " ,
285285 } ,
286286 body : JSON . stringify ( initializeMessage ) ,
287287 } ) ;
@@ -314,7 +314,7 @@ describe("StreamableHTTPServerTransport", () => {
314314 method : "POST" ,
315315 headers : {
316316 "content-type" : "application/json" ,
317- "accept" : "application/json" ,
317+ "accept" : "application/json, text/event-stream " ,
318318 } ,
319319 body : JSON . stringify ( initializeMessage ) ,
320320 } ) ;
@@ -333,7 +333,7 @@ describe("StreamableHTTPServerTransport", () => {
333333 const req = createMockRequest ( {
334334 method : "GET" ,
335335 headers : {
336- "accept" : "text/event-stream" ,
336+ "accept" : "application/json, text/event-stream" ,
337337 "mcp-session-id" : transport . sessionId ,
338338 } ,
339339 } ) ;
@@ -380,7 +380,7 @@ describe("StreamableHTTPServerTransport", () => {
380380 method : "POST" ,
381381 headers : {
382382 "content-type" : "application/json" ,
383- "accept" : "text/event-stream" ,
383+ "accept" : "application/json, text/event-stream" ,
384384 } ,
385385 body : JSON . stringify ( message ) ,
386386 } ) ;
@@ -394,7 +394,7 @@ describe("StreamableHTTPServerTransport", () => {
394394 expect ( mockResponse . writeHead ) . toHaveBeenCalledWith (
395395 200 ,
396396 expect . objectContaining ( {
397- "Content-Type " : "text/event-stream" ,
397+ "mcp-session-id " : transport . sessionId ,
398398 } )
399399 ) ;
400400 } ) ;
@@ -435,7 +435,7 @@ describe("StreamableHTTPServerTransport", () => {
435435 method : "POST" ,
436436 headers : {
437437 "content-type" : "application/json" ,
438- "accept" : "application/json" ,
438+ "accept" : "application/json, text/event-stream " ,
439439 "mcp-session-id" : transport . sessionId ,
440440 } ,
441441 body : JSON . stringify ( batchMessages ) ,
@@ -488,7 +488,7 @@ describe("StreamableHTTPServerTransport", () => {
488488 method : "POST" ,
489489 headers : {
490490 "content-type" : "text/plain" ,
491- "accept" : "application/json" ,
491+ "accept" : "application/json, text/event-stream " ,
492492 "mcp-session-id" : transport . sessionId ,
493493 } ,
494494 body : "test" ,
@@ -532,7 +532,7 @@ describe("StreamableHTTPServerTransport", () => {
532532 method : "POST" ,
533533 headers : {
534534 "content-type" : "application/json" ,
535- "accept" : "text/event-stream" ,
535+ "accept" : "application/json, text/event-stream" ,
536536 "mcp-session-id" : transport . sessionId
537537 } ,
538538 body : JSON . stringify ( requestMessage )
@@ -571,7 +571,7 @@ describe("StreamableHTTPServerTransport", () => {
571571 method : "POST" ,
572572 headers : {
573573 "content-type" : "application/json" ,
574- "accept" : "text/event-stream" ,
574+ "accept" : "application/json, text/event-stream" ,
575575 "mcp-session-id" : transport . sessionId
576576 } ,
577577 body : JSON . stringify ( requestMessage )
@@ -620,7 +620,7 @@ describe("StreamableHTTPServerTransport", () => {
620620 method : "POST" ,
621621 headers : {
622622 "content-type" : "application/json" ,
623- "accept" : "text/event-stream" ,
623+ "accept" : "application/json, text/event-stream" ,
624624 "mcp-session-id" : transport . sessionId
625625 } ,
626626 body : JSON . stringify ( requestMessage1 ) ,
@@ -639,7 +639,7 @@ describe("StreamableHTTPServerTransport", () => {
639639 method : "POST" ,
640640 headers : {
641641 "content-type" : "application/json" ,
642- "accept" : "text/event-stream" ,
642+ "accept" : "application/json, text/event-stream" ,
643643 "mcp-session-id" : transport . sessionId
644644 } ,
645645 body : JSON . stringify ( requestMessage2 ) ,
@@ -691,7 +691,7 @@ describe("StreamableHTTPServerTransport", () => {
691691 method : "POST" ,
692692 headers : {
693693 "content-type" : "application/json" ,
694- "accept" : "application/json" ,
694+ "accept" : "application/json, text/event-stream " ,
695695 } ,
696696 body : "invalid json" ,
697697 } ) ;
@@ -712,7 +712,7 @@ describe("StreamableHTTPServerTransport", () => {
712712 method : "POST" ,
713713 headers : {
714714 "content-type" : "application/json" ,
715- "accept" : "application/json" ,
715+ "accept" : "application/json, text/event-stream " ,
716716 } ,
717717 body : JSON . stringify ( { invalid : "message" } ) ,
718718 } ) ;
@@ -745,7 +745,7 @@ describe("StreamableHTTPServerTransport", () => {
745745 method : "POST" ,
746746 headers : {
747747 "content-type" : "application/json" ,
748- "accept" : "application/json" ,
748+ "accept" : "application/json, text/event-stream " ,
749749 } ,
750750 // No body provided here - it will be passed as parsedBody
751751 } ) ;
@@ -761,7 +761,7 @@ describe("StreamableHTTPServerTransport", () => {
761761 expect ( mockResponse . writeHead ) . toHaveBeenCalledWith (
762762 200 ,
763763 expect . objectContaining ( {
764- "Content-Type " : "application/json" ,
764+ "mcp-session-id " : transport . sessionId ,
765765 } )
766766 ) ;
767767 } ) ;
@@ -787,7 +787,7 @@ describe("StreamableHTTPServerTransport", () => {
787787 method : "POST" ,
788788 headers : {
789789 "content-type" : "application/json" ,
790- "accept" : "text/event-stream" ,
790+ "accept" : "application/json, text/event-stream" ,
791791 "mcp-session-id" : transport . sessionId ,
792792 } ,
793793 // No body provided here - it will be passed as parsedBody
@@ -825,7 +825,7 @@ describe("StreamableHTTPServerTransport", () => {
825825 method : "POST" ,
826826 headers : {
827827 "content-type" : "application/json" ,
828- "accept" : "application/json" ,
828+ "accept" : "application/json, text/event-stream " ,
829829 "mcp-session-id" : transport . sessionId ,
830830 } ,
831831 body : JSON . stringify ( requestBodyMessage ) ,
@@ -863,7 +863,7 @@ describe("StreamableHTTPServerTransport", () => {
863863 method : "POST" ,
864864 headers : {
865865 "content-type" : "application/json" ,
866- accept : "text/event-stream" ,
866+ accept : "application/json, text/event-stream" ,
867867 "mcp-session-id" : transportWithHeaders . sessionId
868868 } ,
869869 body : JSON . stringify ( {
@@ -888,41 +888,11 @@ describe("StreamableHTTPServerTransport", () => {
888888 ) ;
889889 } ) ;
890890
891- it ( "should include custom headers in JSON response" , async ( ) => {
892- const message : JSONRPCMessage = {
893- jsonrpc : "2.0" ,
894- method : "test" ,
895- params : { } ,
896- id : 1 ,
897- } ;
898-
899- const req = createMockRequest ( {
900- method : "POST" ,
901- headers : {
902- "content-type" : "application/json" ,
903- "accept" : "application/json" ,
904- "mcp-session-id" : transportWithHeaders . sessionId
905- } ,
906- body : JSON . stringify ( message ) ,
907- } ) ;
908-
909- await transportWithHeaders . handleRequest ( req , mockResponse ) ;
910-
911- expect ( mockResponse . writeHead ) . toHaveBeenCalledWith (
912- 200 ,
913- expect . objectContaining ( {
914- ...customHeaders ,
915- "Content-Type" : "application/json" ,
916- "mcp-session-id" : transportWithHeaders . sessionId
917- } )
918- ) ;
919- } ) ;
920-
921891 it ( "should include custom headers in error responses" , async ( ) => {
922892 const req = createMockRequest ( {
923893 method : "GET" ,
924894 headers : {
925- accept : "text/event-stream" ,
895+ accept : "application/json, text/event-stream" ,
926896 "mcp-session-id" : "invalid-session-id"
927897 } ,
928898 } ) ;
@@ -948,7 +918,7 @@ describe("StreamableHTTPServerTransport", () => {
948918 method : "POST" ,
949919 headers : {
950920 "content-type" : "application/json" ,
951- accept : "text/event-stream" ,
921+ accept : "application/json, text/event-stream" ,
952922 "mcp-session-id" : transportWithConflictingHeaders . sessionId
953923 } ,
954924 body : JSON . stringify ( {
@@ -979,7 +949,7 @@ describe("StreamableHTTPServerTransport", () => {
979949 method : "POST" ,
980950 headers : {
981951 "content-type" : "application/json" ,
982- accept : "text/event-stream" ,
952+ accept : "application/json, text/event-stream" ,
983953 "mcp-session-id" : transportWithoutHeaders . sessionId
984954 } ,
985955 body : JSON . stringify ( {
0 commit comments