-
Notifications
You must be signed in to change notification settings - Fork 337
Open
Labels
enhancementNew feature or requestNew feature or requeston the roadmapFeature accepted and planned for implementationFeature accepted and planned for implementation
Description
Here's what I like to do:
export default {
fetch: async (request, env, ctx) => {
const url = new URL(request.url)
if (url.pathname === '/mcp') {
ctx.props.baseUrl = url.origin
const mcp = EpicMeMCP.serve('/mcp', {
binding: 'EPIC_ME_MCP_OBJECT',
})
return mcp.fetch(request, env, ctx)
}
return new Response('Not found', { status: 404 })
},
} satisfies ExportedHandler<Env>The satisfies ExportedHandler<Env> makes it so I don't have to manually type my fetch, but I'm getting an error when setting ctx.props.baseUrl because ctx.props is unknown. Here's my workaround:
export default {
fetch: async (request: Request, env: Env, ctx: ExecutionContext<Props>) => {
const url = new URL(request.url)
if (url.pathname === '/mcp') {
ctx.props.baseUrl = url.origin
const mcp = EpicMeMCP.serve('/mcp', {
binding: 'EPIC_ME_MCP_OBJECT',
})
return mcp.fetch(request, env, ctx)
}
return new Response('Not found', { status: 404 })
},
}I don't like the workaround as much.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requeston the roadmapFeature accepted and planned for implementationFeature accepted and planned for implementation