/** * Verify Keycloak access tokens for an mcp-use resource server. * * @packageDocumentation */ import { type OAuthProvider, type OAuthResourceOptions } from "./provider.js"; /** Verified Keycloak user and role claims exposed to authenticated MCP callbacks. */ export interface KeycloakOAuthUser { /** Keycloak 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; /** Preferred username, when included in the access token. */ preferredUsername?: string; /** Given name, when included in the access token. */ givenName?: string; /** Family name, when included in the access token. */ familyName?: string; /** Whether Keycloak has verified {@link KeycloakOAuthUser.email}. */ emailVerified?: boolean; /** Realm roles from `realm_access.roles`. */ roles: string[]; /** Unmodified `realm_access` claim, when present. */ realmAccess?: Record; /** Unmodified `resource_access` claim, when present. */ resourceAccess?: Record; } /** Configures Keycloak JWT verification and protected-resource metadata. */ export interface KeycloakOAuthProviderOptions extends OAuthResourceOptions { /** * Base URL of the Keycloak server. * * @defaultValue `MCP_USE_OAUTH_KEYCLOAK_SERVER_URL` */ serverUrl?: URL | string; /** * Keycloak realm that issues accepted access tokens. * * @defaultValue `MCP_USE_OAUTH_KEYCLOAK_REALM` */ realm?: string; } /** * Creates a provider that verifies Keycloak access tokens and maps their claims. * * @param options - Keycloak server URL, realm, 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 the server URL or realm is missing, or a `TypeError` if either is invalid. * * @example * ```ts * import { oauthKeycloakProvider } from "mcp-use/oauth/keycloak"; * * const oauth = oauthKeycloakProvider({ * serverUrl: "https://keycloak.example.com", * realm: "production", * }); * ``` */ export declare function oauthKeycloakProvider(options?: KeycloakOAuthProviderOptions): OAuthProvider;