UNPKG

mcp-use

Version:

Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents, Clients and Servers with support for ChatGPT Apps, Code Mode, OAuth, Notifications, Sampling, Observability and more.

226 lines 6.46 kB
/** * OAuth Provider Factory Functions * * Export factory functions for creating OAuth providers with better * type safety and developer experience. */ import type { OAuthProvider } from "./providers/types.js"; import type { UserInfo } from "./providers/types.js"; /** * Configuration for Supabase OAuth provider */ export interface SupabaseProviderConfig { projectId: string; jwtSecret?: string; skipVerification?: boolean; } /** * Configuration for Auth0 OAuth provider */ export interface Auth0ProviderConfig { domain: string; audience: string; verifyJwt?: boolean; } /** * Configuration for Keycloak OAuth provider */ export interface KeycloakProviderConfig { serverUrl: string; realm: string; clientId?: string; verifyJwt?: boolean; } /** * Configuration for WorkOS OAuth provider */ export interface WorkOSProviderConfig { subdomain: string; clientId?: string; apiKey?: string; verifyJwt?: boolean; } /** * Configuration for Custom OAuth provider */ export interface CustomProviderConfig { issuer: string; jwksUrl: string; authEndpoint: string; tokenEndpoint: string; scopesSupported?: string[]; grantTypesSupported?: string[]; verifyToken: (token: string) => Promise<any>; getUserInfo?: (payload: any) => UserInfo; } /** * Create a Supabase OAuth provider * * Supports zero-config setup via environment variables: * - MCP_USE_OAUTH_SUPABASE_PROJECT_ID (required) * - MCP_USE_OAUTH_SUPABASE_JWT_SECRET (optional) * * @param config - Optional Supabase configuration (overrides environment variables) * @returns OAuthProvider instance * * @example Zero-config with environment variables * ```typescript * const server = new MCPServer({ * name: 'my-server', * version: '1.0.0', * oauth: oauthSupabaseProvider() * }); * ``` * * @example With explicit configuration * ```typescript * const server = new MCPServer({ * name: 'my-server', * version: '1.0.0', * oauth: oauthSupabaseProvider({ * projectId: 'my-project', * jwtSecret: process.env.SUPABASE_JWT_SECRET * }) * }); * ``` */ export declare function oauthSupabaseProvider(config?: Partial<SupabaseProviderConfig>): OAuthProvider; /** * Create an Auth0 OAuth provider * * Supports zero-config setup via environment variables: * - MCP_USE_OAUTH_AUTH0_DOMAIN (required) * - MCP_USE_OAUTH_AUTH0_AUDIENCE (required) * * @param config - Optional Auth0 configuration (overrides environment variables) * @returns OAuthProvider instance * * @example Zero-config with environment variables * ```typescript * const server = new MCPServer({ * name: 'my-server', * version: '1.0.0', * oauth: oauthAuth0Provider() * }); * ``` * * @example With explicit configuration * ```typescript * const server = new MCPServer({ * name: 'my-server', * version: '1.0.0', * oauth: oauthAuth0Provider({ * domain: 'my-tenant.auth0.com', * audience: 'https://my-api.com' * }) * }); * ``` */ export declare function oauthAuth0Provider(config?: Partial<Auth0ProviderConfig>): OAuthProvider; /** * Create a Keycloak OAuth provider * * Supports zero-config setup via environment variables: * - MCP_USE_OAUTH_KEYCLOAK_SERVER_URL (required) * - MCP_USE_OAUTH_KEYCLOAK_REALM (required) * - MCP_USE_OAUTH_KEYCLOAK_CLIENT_ID (optional) * * @param config - Optional Keycloak configuration (overrides environment variables) * @returns OAuthProvider instance * * @example Zero-config with environment variables * ```typescript * const server = new MCPServer({ * name: 'my-server', * version: '1.0.0', * oauth: oauthKeycloakProvider() * }); * ``` * * @example With explicit configuration * ```typescript * const server = new MCPServer({ * name: 'my-server', * version: '1.0.0', * oauth: oauthKeycloakProvider({ * serverUrl: 'https://keycloak.example.com', * realm: 'my-realm', * clientId: 'my-client' * }) * }); * ``` */ export declare function oauthKeycloakProvider(config?: Partial<KeycloakProviderConfig>): OAuthProvider; /** * Create a WorkOS OAuth provider * * Supports two OAuth modes: * * **1. Dynamic Client Registration (DCR)** - Recommended for MCP * - Don't set MCP_USE_OAUTH_WORKOS_CLIENT_ID * - MCP clients register themselves automatically with WorkOS * - Enable DCR in WorkOS Dashboard under Connect → Configuration * * **2. Pre-registered OAuth Client** - For custom setups * - Set MCP_USE_OAUTH_WORKOS_CLIENT_ID to your OAuth client ID from WorkOS Dashboard * - Create the client in WorkOS Dashboard under Connect → OAuth Applications * - Configure redirect URIs in the dashboard to match your MCP client * * Environment variables: * - MCP_USE_OAUTH_WORKOS_SUBDOMAIN (required) * - MCP_USE_OAUTH_WORKOS_CLIENT_ID (optional, for pre-registered client) * - MCP_USE_OAUTH_WORKOS_API_KEY (optional, for WorkOS API calls) * * @param config - Optional WorkOS configuration (overrides environment variables) * @returns OAuthProvider instance * * @example Dynamic Client Registration (recommended) * ```typescript * const server = new MCPServer({ * name: 'my-server', * version: '1.0.0', * oauth: oauthWorkOSProvider({ * subdomain: 'my-company' * }) * }); * ``` * * @example Pre-registered OAuth Client * ```typescript * const server = new MCPServer({ * name: 'my-server', * version: '1.0.0', * oauth: oauthWorkOSProvider({ * subdomain: 'my-company', * clientId: 'client_01KB5DRXBDDY1VGCBKY108SKJW' * }) * }); * ``` */ export declare function oauthWorkOSProvider(config?: Partial<WorkOSProviderConfig>): OAuthProvider; /** * Create a custom OAuth provider * * @param config - Custom provider configuration * @returns OAuthProvider instance * * @example * ```typescript * const server = new MCPServer({ * name: 'my-server', * version: '1.0.0', * oauth: oauthCustomProvider({ * issuer: 'https://oauth.example.com', * jwksUrl: 'https://oauth.example.com/.well-known/jwks.json', * authEndpoint: 'https://oauth.example.com/authorize', * tokenEndpoint: 'https://oauth.example.com/token', * verifyToken: async (token) => { * // Custom verification logic * return jwtVerify(token, ...); * } * }) * }); * ``` */ export declare function oauthCustomProvider(config: CustomProviderConfig): OAuthProvider; //# sourceMappingURL=providers.d.ts.map