/** * Verify Scalekit access tokens for an mcp-use resource server. * * @packageDocumentation */ import { type OAuthProvider, type OAuthResourceOptions } from "./provider.js"; /** Verified Scalekit caller exposed to authenticated MCP callbacks. */ export interface ScalekitOAuthUser { /** Token `sub`. A person under authorization_code; the client under client_credentials. */ id: string; /** Distinguishes a person from a machine client so tools do not store a client id as a user id. */ subjectType: "user" | "machine"; /** Organization identifier from the access token's `org_id` claim. */ organizationId?: string; /** Session identifier from the access token's `sid` claim. */ sessionId?: string; } /** Configures Scalekit JWT verification and protected-resource metadata. */ export interface ScalekitOAuthProviderOptions extends OAuthResourceOptions { /** * Scalekit environment URL from the dashboard. * * @defaultValue `MCP_USE_OAUTH_SCALEKIT_ENVIRONMENT_URL` */ environmentUrl?: URL | string; /** * MCP resource id (`res_…`). Default JWT audience and the per-server binding. * * @defaultValue `MCP_USE_OAUTH_SCALEKIT_RESOURCE_ID` */ resourceId?: string; /** * Extra JWT audience required *together with* the resource id. * * Default verification only requires `resourceId` in `aud`. Set this when * tokens also carry a Server URL and you want both values present. This * does not replace the resource-id check. */ audience?: string; } /** * Creates a provider that verifies Scalekit access tokens and maps their claims. * * Advertised authorization-server metadata uses the resource-scoped issuer. * The verifier accepts both the environment-root issuer and the resource-scoped * issuer so tokens survive Scalekit's issuer migration. * * @param options - Scalekit environment URL, resource id, and resource-server settings. Defaults to v1 environment variables. * @returns A provider that verifies Scalekit-issued access tokens against the resource id. * @throws An `Error` if environment URL or resource id is missing. Throws a `TypeError` if they are invalid, `resourceId` does not start with `res_`, or `audience` is empty. * * @example * ```ts * import { oauthScalekitProvider } from "mcp-use/oauth/scalekit"; * * const oauth = oauthScalekitProvider({ * environmentUrl: "https://your-env.scalekit.dev", * resourceId: "res_example", * }); * ``` */ export declare function oauthScalekitProvider(options?: ScalekitOAuthProviderOptions): OAuthProvider;