From 113862f4ae03a19995d14af0f2b2a75d29ea8e3b Mon Sep 17 00:00:00 2001 From: Prasanna A P <106952318+Prasanna721@users.noreply.github.com> Date: Fri, 19 Jun 2026 14:08:19 -0700 Subject: [PATCH] fix mcp root transport alias --- apps/mcp/src/server/index.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/mcp/src/server/index.ts b/apps/mcp/src/server/index.ts index f3b1e586..b2e92bfb 100644 --- a/apps/mcp/src/server/index.ts +++ b/apps/mcp/src/server/index.ts @@ -137,7 +137,10 @@ const mcpHandler = SupermemoryMCP.serve("/mcp", { }, }) -app.all("/mcp/*", async (c) => { +async function handleMcpRequest( + c: Context<{ Bindings: Bindings }>, + rewritePath?: string, +) { const authHeader = c.req.header("Authorization") const token = authHeader?.replace(/^Bearer\s+/i, "") const containerTag = c.req.header("x-sm-project") @@ -202,7 +205,19 @@ app.all("/mcp/*", async (c) => { } satisfies Props, } as ExecutionContext & { props: Props } - return mcpHandler.fetch(c.req.raw, c.env, ctx) + const request = rewritePath + ? new Request(new URL(rewritePath, c.req.url).toString(), c.req.raw) + : c.req.raw + + return mcpHandler.fetch(request, c.env, ctx) +} + +app.all("/", async (c) => { + return handleMcpRequest(c, "/mcp") +}) + +app.all("/mcp/*", async (c) => { + return handleMcpRequest(c) }) export { SupermemoryMCP }