Is your feature request related to a problem? Please describe.
createMcpAuthRouter requires env-dependent initialization at app construction time. This does not work in request-scoped runtimes where bindings only exist per request.
In Cloudflare Workers (using Hono), Supabase Edge Functions, Deno Deploy, and similar environments, env is only available inside the request handler (for example c.env). There is no stable app-level env at construction time.
The only working pattern today is to reconstruct the router on every request:
app.post("/token", (c) =>
createMcpAuthRouter(c.env).fetch(c.req.raw, c.env)
);
This is awkward and suggests the API assumes a long-lived Node-style server.
Describe the solution you'd like
Support a request-time execution model that does not require env at construction time.
Examples:
const handler = createMcpAuthHandler();
app.all("/oauth/*", (c) => handler(c.req.raw, c.env));
or:
app.use("/oauth/*", (c) => mcpAuthHandler(c));
or:
mcpAuthRouter({ getEnv: (c) => c.env });
Any approach where env is provided at request time instead of construction time would resolve this.
Describe alternatives you've considered
Per-request router construction:
(c) => createMcpAuthRouter(c.env).fetch(c.req.raw, c.env)
This works but:
- recreates the router on every request
- prevents reuse of internal state or memoization
- requires repetitive route wiring
Additional context
Request-scoped runtimes are now common deployment targets:
- Cloudflare Workers
- Supabase Edge Functions
- Vercel Edge Runtime
- Deno Deploy
All share the same constraint: env is only available per request.
The current API design makes the SDK difficult to use in these environments and effectively limits it to Node-style servers. Supporting a fetch-style or context-driven handler would make the SDK compatible with edge runtimes without workarounds.
Is your feature request related to a problem? Please describe.
createMcpAuthRouterrequires env-dependent initialization at app construction time. This does not work in request-scoped runtimes where bindings only exist per request.In Cloudflare Workers (using Hono), Supabase Edge Functions, Deno Deploy, and similar environments,
envis only available inside the request handler (for examplec.env). There is no stable app-level env at construction time.The only working pattern today is to reconstruct the router on every request:
This is awkward and suggests the API assumes a long-lived Node-style server.
Describe the solution you'd like
Support a request-time execution model that does not require env at construction time.
Examples:
or:
or:
Any approach where env is provided at request time instead of construction time would resolve this.
Describe alternatives you've considered
Per-request router construction:
This works but:
Additional context
Request-scoped runtimes are now common deployment targets:
All share the same constraint: env is only available per request.
The current API design makes the SDK difficult to use in these environments and effectively limits it to Node-style servers. Supporting a fetch-style or context-driven handler would make the SDK compatible with edge runtimes without workarounds.