import { type OAuthTokenVerifier } from "@modelcontextprotocol/server"; import { type FetchMiddleware } from "../fetch-app.js"; import type { ToolSecurityScheme } from "../tools.js"; /** @internal Options for {@link createOAuthGate}. */ export interface OAuthGateOptions { /** Verifier bound to the canonical MCP resource. */ verifier: OAuthTokenVerifier; /** RFC 9728 metadata URL advertised in every challenge. */ resourceMetadataUrl: string; /** Provider `requiredScopes`, enforced on every sign-in request. */ baselineScopes: readonly string[]; /** Whether signed-out callers may connect, list, and call `noauth` tools. */ mixedAuth: boolean; /** Resolved schemes for a tool name, or `undefined` for an unknown tool. */ toolSchemes: (name: string) => readonly ToolSecurityScheme[] | undefined; /** * Resource URIs that `resources/read` serves signed out on a `mixedAuth` * server: the tools' views. */ openResourceUris: Iterable; } /** * Build the bearer gate that fronts the MCP endpoint. * * A token that is sent is always verified first; an invalid or expired one is * refused with `401` on every request. Then the JSON-RPC method, and for * `tools/call` the tool's `securitySchemes`, decide whether the request needs * sign-in, and which scopes. Verified identity is stashed on the request bag for the mount. * * Without `mixedAuth`, every request needs a token with the provider's * `requiredScopes`, plus the scopes of the tool it calls. * * @internal */ export declare function createOAuthGate(options: OAuthGateOptions): FetchMiddleware;