import { type CreateServerOptions } from './server.js'; /** What `authorize` may return: allow, deny with the default 401, or a Response of your own. */ export type AuthDecision = boolean | Response; export interface McpHandlerOptions extends Pick { /** * Decide whether a request may use the server. Return `true` to allow, `false` * for a 401, or a `Response` to answer with your own (a 403, a redirect, a * WWW-Authenticate challenge). * * One of `authorize`, `apiKey` or `unauthenticated: true` is required. This * endpoint makes outbound calls to Telkomsel on the caller's behalf and accepts * any phone number as an argument, so an unprotected route is an open proxy. * Making the choice explicit means nobody ships one by leaving a field out. */ authorize?: (request: Request) => AuthDecision | Promise; /** Shortcut for `authorize`: require `Authorization: Bearer `. Compared in constant time. */ apiKey?: string; /** Opt out of authentication, for a route that something else already protects. */ unauthenticated?: boolean; /** * Browser origins allowed to call the route. A request carrying an Origin * header that is not listed is refused, which stops a web page from reaching an * MCP server running on the visitor's own machine. Requests with no Origin * header (every MCP client that is not a browser) are unaffected. */ allowedOrigins?: string[]; /** Largest request body accepted, in bytes. Default 1 MiB. */ maxBodyBytes?: number; } export type McpRequestHandler = (request: Request) => Promise; /** * A Web-standard handler for a Telkomsel MCP endpoint: `(Request) => Promise`. * * It uses no framework API, so the same function is a Next.js App Router route * handler, a Hono or Bun `fetch`, a Cloudflare-style worker entry or a Deno * `serve` callback. * * Stateless by design. Each request gets a new server and a new transport and * keeps nothing afterwards, which is what lets it run on serverless platforms * where the next request may land on a different machine, and what makes the * session-id and in-memory-map problems of stateful hosting disappear. The cost * is that nothing carries over between calls: a client passes `msisdn` per call * rather than setting a default. * * Responses are plain JSON rather than an event stream. Every tool here is a * request and a response; nothing is pushed. A stream would hold a serverless * invocation open for nothing and cannot be cut off cleanly when the function * times out. */ export declare function createMcpHandler(options?: McpHandlerOptions): McpRequestHandler;