From 33a755a9553c959074a11a13bb6cbdf2c1ff3528 Mon Sep 17 00:00:00 2001 From: gastonfoncea Date: Sun, 17 May 2026 17:57:51 -0300 Subject: [PATCH] =?UTF-8?q?fix(mcp):=20disable=20deprecated=20SSE=20transp?= =?UTF-8?q?ort=20=E2=80=94=20GHB-189?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `/api/mcp/sse` was timing out in prod with 0 bytes received (no HTTP headers). Root cause: mcp-handler 1.1.0's SSE handler hard- requires a TCP Redis URL via REDIS_URL/KV_URL env vars. Our Vercel project has Upstash via Marketplace but only the REST-API env vars (KV_REST_API_URL/_TOKEN) are auto-injected — the TCP URL is not. Without it, initializeRedis() throws synchronously before flushing any response, so the Vercel runtime kills the function and the client sees a 0-byte hang. The README "Redis (optional, for SSE)" is misleading; in the code Redis is mandatory for SSE. Fix: set `disableSse: true` in createMcpHandler config. Per mcp- handler's own type docs, SSE was removed from the MCP spec on 2025-03-26, so `/sse` now returns a clean 404 instead of hanging. Streamable HTTP (`/api/mcp/mcp`) remains the canonical transport and continues to work for all current MCP clients (Claude Code, Cursor, Codex, custom SDKs aligned with the latest spec). Verified locally: - /api/mcp/sse → 404 "Not found" - /api/mcp/mcp → 200 with valid MCP initialize handshake Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/mcp/app/api/mcp/[transport]/route.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/mcp/app/api/mcp/[transport]/route.ts b/apps/mcp/app/api/mcp/[transport]/route.ts index b5bb131..6675e5b 100644 --- a/apps/mcp/app/api/mcp/[transport]/route.ts +++ b/apps/mcp/app/api/mcp/[transport]/route.ts @@ -1,6 +1,14 @@ // Public MCP endpoint. The dynamic route segment `[transport]` is -// `sse` for Streamable HTTP transport. Tools are registered by -// `lib/tools/register.ts`; this file is just the framework shell. +// `mcp` for the Streamable HTTP transport (the only one we support). +// Tools are registered by `lib/tools/register.ts`; this file is just +// the framework shell. +// +// SSE is intentionally disabled (GHB-189). It was removed from the MCP +// spec on 2025-03-26 (see mcp-handler types) and `mcp-handler`'s SSE +// handler hard-requires a TCP Redis URL — without it the handler +// throws before flushing any HTTP headers, which surfaces to clients +// as a 0-byte connection that hangs until they time out. With +// `disableSse: true` the same path returns a clean 404 instead. import { createMcpHandler } from "mcp-handler"; import { registerAllTools } from "@/lib/tools/register"; @@ -16,6 +24,7 @@ const handler = createMcpHandler( }, { basePath: "/api/mcp", + disableSse: true, } );