/** * Verify access tokens from the Better Auth OAuth 2.1 Provider plugin. * * @packageDocumentation */ import { type OAuthProvider, type OAuthResourceOptions } from "./provider.js"; /** Verified Better Auth claims exposed to authenticated MCP callbacks. */ export interface BetterAuthOAuthUser { /** Better Auth subject identifier. */ id: string; /** Primary email address, when included in the access token. */ email?: string; /** Display name, when included in the access token. */ name?: string; /** Profile image URL, when included in the access token. */ picture?: string; /** Whether Better Auth has verified {@link BetterAuthOAuthUser.email}. */ emailVerified?: boolean; /** Better Auth session identifier. */ sessionId?: string; /** Whether the session belongs to an anonymous user. */ isAnonymous?: boolean; /** Roles from the access token's `roles` claim. */ roles: string[]; } /** Configures Better Auth JWT verification and protected-resource metadata. */ export interface BetterAuthOAuthProviderOptions extends OAuthResourceOptions { /** * Full Better Auth issuer URL, including its base path. * * @defaultValue `MCP_USE_OAUTH_BETTER_AUTH_URL` */ authURL?: URL | string; } /** * Creates a provider for Better Auth's OAuth 2.1 Provider plugin. * * Better Auth owns registration, authorization, consent, and token issuance. * mcp-use advertises those endpoints and verifies the resulting access-token * JWTs against Better Auth's JWKS endpoint. * * @param options - Better Auth issuer URL and resource-server settings. Defaults to v1 environment variables. * @returns A provider that rejects tokens not issued for the resolved MCP resource. * @throws An `Error` if no issuer URL is configured, or a `TypeError` if it is not a valid HTTP or HTTPS URL. * * @example * ```ts * import { oauthBetterAuthProvider } from "mcp-use/oauth/better-auth"; * * const oauth = oauthBetterAuthProvider({ * authURL: "https://auth.example.com/api/auth", * }); * ``` */ export declare function oauthBetterAuthProvider(options?: BetterAuthOAuthProviderOptions): OAuthProvider;