mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-07 02:58:11 +00:00
fix mcp root transport alias
This commit is contained in:
parent
db990e93ce
commit
113862f4ae
1 changed files with 17 additions and 2 deletions
|
|
@ -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 }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue