/** @internal `_meta` key ChatGPT reads for a tool-result auth challenge. */ export declare const WWW_AUTHENTICATE_META_KEY: "mcp/www_authenticate"; /** @internal Why a request was refused. */ export type AuthChallengeReason = "missing_token" | "invalid_token" | "insufficient_scope"; /** * @internal A sign-in challenge, independent of how it reaches the client. * * Every refusal is built here, whether the gate sends it as HTTP 401/403 or * as ChatGPT's `isError` tool result, so both formats always agree. */ export interface AuthChallenge { reason: AuthChallengeReason; /** Human-readable `error_description`, also the tool-result text. */ description: string; /** The full scope set the request needs, advertised as `scope`. */ scopes: readonly string[]; /** RFC 9728 metadata URL advertised as `resource_metadata`. */ resourceMetadataUrl: string; } /** @internal Inputs for {@link createAuthChallenge}. */ export interface AuthChallengeOptions { reason: AuthChallengeReason; /** * The full scope set the request needs: the provider's `requiredScopes` * plus the item's scopes, not only the missing ones. Clients request this * set on sign-in or step-up. */ scopes: readonly string[]; /** RFC 9728 metadata URL advertised as `resource_metadata`. */ resourceMetadataUrl: string; /** Scopes the presented token lacks, named in the description. */ missingScopes?: readonly string[]; /** Description override, such as the verifier's reason for `invalid_token`. */ description?: string; } /** * Build a sign-in challenge. * * @internal */ export declare function createAuthChallenge(options: AuthChallengeOptions): AuthChallenge; /** * The spec's transport challenge: `401` for a missing or invalid token, * `403` for missing scopes, with an RFC 6750 `WWW-Authenticate` header * carrying `error`, `error_description`, `scope`, and `resource_metadata`. * Claude and other spec clients start or step up OAuth from it. * * @internal */ export declare function authChallengeHttpResponse(challenge: AuthChallenge): Response; /** * ChatGPT's in-band challenge: an `isError` tool result whose * `_meta["mcp/www_authenticate"]` carries the same header value. * * @internal */ export declare function authChallengeToolResult(challenge: AuthChallenge): { content: [{ type: "text"; text: string; }]; isError: true; _meta: { [WWW_AUTHENTICATE_META_KEY]: string[]; }; }; /** * Whether a refused `tools/call` should use the tool-result format. Only * ChatGPT needs it; a missing User-Agent gets HTTP. * * @internal */ export declare function prefersToolResultChallenge(request: Request): boolean;