@@ -39,12 +39,19 @@ function createMockResponse(): jest.Mocked<ServerResponse> {
3939describe ( "StreamableHTTPServerTransport" , ( ) => {
4040 let transport : StreamableHTTPServerTransport ;
4141 let mockResponse : jest . Mocked < ServerResponse > ;
42+ let mockRequest : string ;
4243
4344 beforeEach ( ( ) => {
4445 transport = new StreamableHTTPServerTransport ( {
4546 sessionId : randomUUID ( ) ,
4647 } ) ;
4748 mockResponse = createMockResponse ( ) ;
49+ mockRequest = JSON . stringify ( {
50+ jsonrpc : "2.0" ,
51+ method : "test" ,
52+ params : { } ,
53+ id : 1 ,
54+ } ) ;
4855 } ) ;
4956
5057 afterEach ( ( ) => {
@@ -90,11 +97,13 @@ describe("StreamableHTTPServerTransport", () => {
9097
9198 it ( "should reject invalid session ID" , async ( ) => {
9299 const req = createMockRequest ( {
93- method : "GET " ,
100+ method : "POST " ,
94101 headers : {
95102 "mcp-session-id" : "invalid-session-id" ,
96- "accept" : "application/json, text/event-stream"
103+ "accept" : "application/json, text/event-stream" ,
104+ "content-type" : "application/json" ,
97105 } ,
106+ body : mockRequest ,
98107 } ) ;
99108
100109 await transport . handleRequest ( req , mockResponse ) ;
@@ -107,11 +116,13 @@ describe("StreamableHTTPServerTransport", () => {
107116
108117 it ( "should reject non-initialization requests without session ID with 400 Bad Request" , async ( ) => {
109118 const req = createMockRequest ( {
110- method : "GET " ,
119+ method : "POST " ,
111120 headers : {
112- accept : "application/json, text/event-stream" ,
121+ "accept" : "application/json, text/event-stream" ,
122+ "content-type" : "application/json" ,
113123 // No mcp-session-id header
114124 } ,
125+ body : mockRequest
115126 } ) ;
116127
117128 await transport . handleRequest ( req , mockResponse ) ;
0 commit comments