Skip to content

Commit c275a0d

Browse files
committed
remove session validation in handleUnsupportedRequest
1 parent 8c2086e commit c275a0d

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/server/streamableHttp.test.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,19 @@ function createMockResponse(): jest.Mocked<ServerResponse> {
3939
describe("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);

src/server/streamableHttp.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ export class StreamableHTTPServerTransport implements Transport {
9898
* For now we support only POST and DELETE requests. Support for GET for SSE connections will be added later.
9999
*/
100100
private async handleUnsupportedRequest(req: IncomingMessage, res: ServerResponse): Promise<void> {
101-
if (this._sessionId !== undefined && !this.validateSession(req, res)) {
102-
return;
103-
}
104101

105102
res.writeHead(405, {
106103
"Allow": "POST, DELETE"

0 commit comments

Comments
 (0)