Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/web-standard-connection-policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@modelcontextprotocol/server': patch
---

Leave hop-by-hop connection policy for Streamable HTTP SSE responses to the HTTP adapter.
9 changes: 3 additions & 6 deletions packages/server/src/server/streamableHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,7 @@ export class WebStandardStreamableHTTPServerTransport implements Transport {

const headers: Record<string, string> = {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache, no-transform',
Connection: 'keep-alive'
'Cache-Control': 'no-cache, no-transform'
};

// After initialization, always include the session ID if we have one
Expand Down Expand Up @@ -536,8 +535,7 @@ export class WebStandardStreamableHTTPServerTransport implements Transport {

const headers: Record<string, string> = {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache, no-transform',
Connection: 'keep-alive'
'Cache-Control': 'no-cache, no-transform'
};

if (this.sessionId !== undefined) {
Expand Down Expand Up @@ -837,8 +835,7 @@ export class WebStandardStreamableHTTPServerTransport implements Transport {

const headers: Record<string, string> = {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
Connection: 'keep-alive'
'Cache-Control': 'no-cache'
};

// After initialization, always include the session ID if we have one
Expand Down
3 changes: 3 additions & 0 deletions packages/server/test/server/streamableHttp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ describe('Zod v4', () => {
expect(response.status).toBe(200);
expect(response.headers.get('content-type')).toBe('text/event-stream');
expect(response.headers.get('mcp-session-id')).toBeDefined();
expect(response.headers.get('connection'), 'connection policy belongs to the HTTP adapter').toBeNull();
});

it('should reject second initialization request', async () => {
Expand Down Expand Up @@ -358,6 +359,7 @@ describe('Zod v4', () => {
expect(response.status).toBe(200);
expect(response.headers.get('content-type')).toBe('text/event-stream');
expect(response.headers.get('mcp-session-id')).toBe(sessionId);
expect(response.headers.get('connection'), 'connection policy belongs to the HTTP adapter').toBeNull();
});

it('should reject GET without Accept: text/event-stream', async () => {
Expand Down Expand Up @@ -857,6 +859,7 @@ describe('Zod v4', () => {
createRequest('GET', undefined, { sessionId, extraHeaders: { 'Last-Event-ID': primingId! } })
);
expect(reconnect.status).toBe(200);
expect(reconnect.headers.get('connection'), 'connection policy belongs to the HTTP adapter').toBeNull();
release();
const replayed = await readSSEEvent(reconnect);
expect(replayed).toContain('notifications/progress');
Expand Down
Loading