Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions apps/mcp/src/index.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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 }
Expand Down