FrontMCP includes a built-in OAuth 2.1 authorization server for self-contained authentication scenarios.Documentation Index
Fetch the complete documentation index at: https://docs.agentfront.dev/llms.txt
Use this file to discover all available pages before exploring further.
Basic Configuration
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
consent | ConsentConfig | { enabled: false } | Consent UI configuration |
tokenStorage | 'memory' | { redis: RedisConfig } | 'memory' | Token storage backend |
allowDefaultPublic | boolean | false | Allow unauthenticated access |
anonymousScopes | string[] | ['anonymous'] | Scopes for anonymous sessions |
incrementalAuth | IncrementalAuthConfig | { enabled: true } | Progressive authorization config |
OAuth Endpoints
Local mode exposes standard OAuth 2.1 endpoints:| Endpoint | Method | Description |
|---|---|---|
/oauth/authorize | GET | Start authorization flow |
/oauth/token | POST | Exchange code for tokens |
/oauth/register | POST | Dynamic Client Registration |
/oauth/userinfo | GET | Get user profile |
/.well-known/oauth-authorization-server | GET | Server metadata |
/.well-known/jwks.json | GET | Public signing keys |
Authorization Request
Token Exchange
OAuth Callback Flow (/oauth/callback)
The callback endpoint processes the user’s response from the authorization page and creates an authorization code. It executes through the following stages:
| Stage | Description |
|---|---|
parseInput | Extract query parameters (email, pending_auth_id, etc.) |
validatePendingAuth | Verify pending auth record and validate providers |
handleIncrementalAuth | Process progressive authorization for apps |
handleFederatedAuth | Chain through federated identity providers |
createAuthorizationCode | Generate authorization code with consent data |
redirectToClient | Redirect user back to client with code |
Callback Query Parameters
| Parameter | Description |
|---|---|
pending_auth_id | Reference to pending authorization record |
email | User’s email address |
name | User’s display name (optional) |
incremental | Set to true for progressive auth (optional) |
app_id | Target app for incremental authorization (optional) |
federated | Set to true for federated login (optional) |
providers | Selected provider IDs (optional, array or string) |
tools | Selected tool IDs for consent (optional, array) |
Federated Provider Chaining
Whenfederated=true and providers are selected:
- A federated session is created to track progress
- PKCE is generated for the first provider
- User is redirected to the first provider’s authorization URL
- After each provider completes, the chain continues to the next
- Once all providers complete, an authorization code is created
Error Handling
- Missing
pending_auth_id: Returns 400 with error page - Expired authorization: Returns 400 with “request expired” message
- Invalid provider selection: Returns 400 with “invalid provider selection” message
- Missing required fields: Returns 500 with error page
Key Management
Auto-Generated Keys
By default, FrontMCP generates RS256 keys at startup:Auto-generated keys are lost on restart. Existing tokens become invalid.
Persistent Keys
Provide keys for stable token validation:ES256 Keys
Use ES256 for smaller tokens:Dynamic Client Registration
DCR allows clients to register programmatically. DCR is enabled by default in development.Registration Request
Registration Response
Per-App Configuration
Configure local auth per app withsplitByApp: true:
Token Storage
In-Memory (Development)
Redis (Production)
Consent Configuration
Enable and customize the consent UI:Complete Example
Auth UI Template Builders
FrontMCP provides server-side HTML template builders for all authentication UI pages. These render with Tailwind CSS and require no build step.| Builder | Purpose |
|---|---|
buildLoginPage() | Email/password login form |
buildConsentPage() | Multi-app tool authorization with Authorize/Skip buttons |
buildIncrementalAuthPage() | Single-app auth for previously skipped apps |
buildFederatedLoginPage() | Multi-provider selection UI with optional skip |
buildToolConsentPage() | Tool-level consent within an app |
buildErrorPage() | Error display with description |
Customization
Templates accept aThemeConfig for visual customization:
| Option | Type | Description |
|---|---|---|
colors | ThemeColors | Primary, background, text, border colors |
fonts | ThemeFonts | Heading and body font families |
Layout Variants
| Layout | Function | Use Case |
|---|---|---|
centeredCardLayout() | Small centered card | Login, error pages |
wideLayout() | Full-width card | Consent with many tools |
extraWideLayout() | Extra-wide card | Federated login with many providers |
Troubleshooting
Tokens invalid after restart
Tokens invalid after restart
Auto-generated keys are lost on restart. Either:
- Provide persistent keys via
local.signKey - Use Redis for token storage
- Accept that users must re-authenticate
PKCE verification failed
PKCE verification failed
Ensure you’re using S256 challenge method and the code_verifier matches the original code_challenge.
Session not found across instances
Session not found across instances
When running multiple server instances, use Redis for token storage to share session state.
Next Steps
Remote OAuth
Connect to external identity providers
Progressive Authorization
Implement incremental app authorization
Production Checklist
Security requirements for deployment
Tokens & Sessions
Configure token lifetimes