diff --git a/apps/mcp/src/index.ts b/apps/mcp/src/index.ts index 0586492f..e717b31f 100644 --- a/apps/mcp/src/index.ts +++ b/apps/mcp/src/index.ts @@ -1,5 +1,5 @@ import { cors } from "hono/cors" -import { Hono } from "hono" +import { Hono, type Context } from "hono" import { SupermemoryMCP } from "./server" import { isApiKey, validateApiKey, validateOAuthToken } from "./auth" import { initPosthog } from "./posthog" @@ -100,7 +100,7 @@ const mcpHandler = SupermemoryMCP.mount("/mcp", { }, }) -app.all("/mcp/*", async (c) => { +const handleMcpRequest = async (c: Context<{ Bindings: Bindings }>) => { const authHeader = c.req.header("Authorization") const token = authHeader?.replace(/^Bearer\s+/i, "") const containerTag = c.req.header("x-sm-project") @@ -169,7 +169,10 @@ app.all("/mcp/*", async (c) => { } as ExecutionContext & { props: Props } return mcpHandler.fetch(c.req.raw, c.env, ctx) -}) +} + +app.all("/mcp", handleMcpRequest) +app.all("/mcp/*", handleMcpRequest) // Export the Durable Object class for Cloudflare Workers export { SupermemoryMCP }