Skip to content

Commit 558d016

Browse files
nmindzsreedharsreeram
authored andcommitted
fix(mcp): register handler on bare /mcp path to match MCP transport spec (#733)
1 parent c7d90e6 commit 558d016

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

apps/mcp/src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { cors } from "hono/cors"
2-
import { Hono } from "hono"
2+
import { Hono, type Context } from "hono"
33
import { SupermemoryMCP } from "./server"
44
import { isApiKey, validateApiKey, validateOAuthToken } from "./auth"
55
import { initPosthog } from "./posthog"
@@ -109,7 +109,7 @@ const mcpHandler = SupermemoryMCP.serve("/mcp", {
109109
},
110110
})
111111

112-
app.all("/mcp/*", async (c) => {
112+
const handleMcpRequest = async (c: Context<{ Bindings: Bindings }>) => {
113113
const authHeader = c.req.header("Authorization")
114114
const token = authHeader?.replace(/^Bearer\s+/i, "")
115115
const containerTag = c.req.header("x-sm-project")
@@ -186,7 +186,10 @@ app.all("/mcp/*", async (c) => {
186186
} as ExecutionContext & { props: Props }
187187

188188
return mcpHandler.fetch(c.req.raw, c.env, ctx)
189-
})
189+
}
190+
191+
app.all("/mcp", handleMcpRequest)
192+
app.all("/mcp/*", handleMcpRequest)
190193

191194
// Export the Durable Object class for Cloudflare Workers
192195
export { SupermemoryMCP }

0 commit comments

Comments
 (0)