fix(mcp): refuse subscriptions/listen streams — MCP serving is stateless (EVE-95) (#548)

This commit is contained in:
Ben Senescu 2026-08-26 11:48:20 -04:00 committed by GitHub
parent 0abde80109
commit 824e914eb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -143,6 +143,11 @@ export function createOpenSeoMcpServer(authProps: McpProps) {
], ],
}, },
{ {
// The tool list is fixed per request and no list_changed notification
// is ever published, so don't advertise the capability — modern clients
// use it to decide whether to open a subscriptions/listen stream.
// Without the pre-declaration, registerTool defaults it to true.
capabilities: { tools: { listChanged: false } },
instructions: instructions:
"OpenSEO research tools use credits. Proceed with normal focused research, but ask the user for confirmation before planned batches over 2,000 credits.", "OpenSEO research tools use credits. Proceed with normal focused research, but ask the user for confirmation before planned batches over 2,000 credits.",
}, },

View File

@ -128,6 +128,12 @@ function createRequestHandler(
route: MCP_ROUTE, route: MCP_ROUTE,
allowedOriginHostnames, allowedOriginHostnames,
legacy: "reject", legacy: "reject",
// MCP serving is strictly stateless: no notification is ever published,
// so refuse subscriptions/listen outright (in-band -32603 before the
// ack). The SSE streams it would otherwise hold open pin isolates for
// hours and turn every isolate death into a burst of exceededMemory
// request outcomes (EVE-95).
maxSubscriptions: 0,
}); });
return async (request: Request, env: unknown, ctx: ExecutionContext) => { return async (request: Request, env: unknown, ctx: ExecutionContext) => {