From fb7b09ad6c231e8a3c6ebedb6d8e9aa2e5d80915 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 22 Oct 2026 20:05:44 -0400 Subject: [PATCH] fix: Close MCP subscriptions/listen streams at once (#14254) The tool and resource lists never change during a request, so do not advertise listChanged. This stops 2026-07-28 clients from holding open SSE streams that the router interrupts. --- server/mcp/index.ts | 6 ++++-- server/routes/mcp/index.test.ts | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/server/mcp/index.ts b/server/mcp/index.ts index 2436a4066f..51a6638bba 100644 --- a/server/mcp/index.ts +++ b/server/mcp/index.ts @@ -49,9 +49,11 @@ export function createMcpServer( ], }, { + // The lists never change during a request, so subscriptions/listen + // completes at once instead of holding a stream open. capabilities: { - tools: {}, - resources: {}, + tools: { listChanged: false }, + resources: { listChanged: false, subscribe: false }, extensions: { [skillsExtensionId]: {}, }, diff --git a/server/routes/mcp/index.test.ts b/server/routes/mcp/index.test.ts index 7cb5236007..ec55bce762 100644 --- a/server/routes/mcp/index.test.ts +++ b/server/routes/mcp/index.test.ts @@ -131,6 +131,30 @@ describe("POST /mcp/", () => { expect(result?.content?.[0]?.text).toContain(collection.id); }); + it("should complete a subscriptions/listen request at once", async () => { + const { accessToken } = await buildOAuthUser(); + const { body, resultId } = mcpRequest("subscriptions/listen", { + notifications: { + toolsListChanged: true, + resourcesListChanged: true, + }, + _meta: modernMeta("2026-07-28"), + }); + const res = await server.post("/mcp/", { + headers: { + ...mcpHeaders(accessToken), + "MCP-Protocol-Version": "2026-07-28", + "Mcp-Method": "subscriptions/listen", + }, + body, + }); + expect(res.status).toEqual(200); + + const text = await res.text(); + expect(text).toContain('"resultType":"complete"'); + expect(text).toContain(`"id":${resultId}`); + }); + it("should handle initialize and return capabilities", async () => { const { accessToken } = await buildOAuthUser(); const { body } = mcpRequest("initialize", {