fastmcp.server.auth.providers.workos
WorkOS authentication providers for FastMCP.
This module provides two WorkOS authentication strategies:
- WorkOSProvider - OAuth proxy for WorkOS Connect applications (non-DCR)
- AuthKitProvider - DCR-compliant provider for WorkOS AuthKit
Classes
WorkOSProviderSettings
Settings for WorkOS OAuth provider.
WorkOSTokenVerifier
Token verifier for WorkOS OAuth tokens.
WorkOS AuthKit tokens are opaque, so we verify them by calling
the /oauth2/userinfo endpoint to check validity and get user info.
Methods:
verify_token
WorkOSProvider
Complete WorkOS OAuth provider for FastMCP.
This provider implements WorkOS AuthKit OAuth using the OAuth Proxy pattern.
It provides OAuth2 authentication for users through WorkOS Connect applications.
Features:
- Transparent OAuth proxy to WorkOS AuthKit
- Automatic token validation via userinfo endpoint
- User information extraction from ID tokens
- Support for standard OAuth scopes (openid, profile, email)
- Create a WorkOS Connect application in your dashboard
- Note your AuthKit domain (e.g., “https://your-app.authkit.app”)
- Configure redirect URI as: http://localhost:8000/auth/callback
- Note your Client ID and Client Secret
AuthKitProviderSettings
AuthKitProvider
AuthKit metadata provider for DCR (Dynamic Client Registration).
This provider implements AuthKit integration using metadata forwarding
instead of OAuth proxying. This is the recommended approach for WorkOS DCR
as it allows WorkOS to handle the OAuth flow directly while FastMCP acts
as a resource server.
IMPORTANT SETUP REQUIREMENTS:
-
Enable Dynamic Client Registration in WorkOS Dashboard:
- Go to Applications → Configuration
- Toggle “Dynamic Client Registration” to enabled
-
Configure your FastMCP server URL as a callback:
- Add your server URL to the Redirects tab in WorkOS dashboard
- Example: https://your-fastmcp-server.com/oauth2/callback
get_routes
mcp_path
: The path where the MCP endpoint is mounted (e.g., “/mcp”)mcp_endpoint
: The MCP endpoint handler to protect with auth