fix(mcp): register handler on bare /mcp path to match MCP transport spec (#733)

This commit is contained in:
Evandro Camargo 2026-04-11 20:57:26 -03:00 committed by GitHub
parent 26ad0e32e2
commit 5b57f4ddf3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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"
@ -109,7 +109,7 @@ const mcpHandler = SupermemoryMCP.serve("/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")
@ -186,7 +186,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 }