Skip to main content
FrontMCP provides flexible token and session management with support for both stateful and stateless patterns.

Token Types


Session Modes

FrontMCP supports two session management strategies:

Stateful Sessions

Tokens stored server-side. Clients hold lightweight references.Pros:
  • Silent token refresh
  • Revocation without client update
  • Secure token storage
Cons:
  • Requires shared storage (Redis)
  • State management complexity

Stateless Sessions

All data embedded in JWT. No server-side storage.Pros:
  • Horizontally scalable
  • No shared state
  • Simple architecture
Cons:
  • No silent refresh
  • Larger token size
  • Can’t revoke without expiry

Stateful Session Configuration

Stateless Session Configuration

Stateful sessions require shared storage when running multiple server instances. Without Redis, each instance maintains its own session state.

Token Storage

In-Memory (Development)

In-memory storage loses all data on restart. Use only for development.

Redis (Production)

Storage Contents


OrchestratedTokenStore Interface

When using local or remote mode with federated authentication, FrontMCP stores provider tokens using the OrchestratedTokenStore interface.

Interface Methods

Token Migration

The migrateTokens() method is used internally during federated auth completion to transfer tokens from a pending authorization ID to the final authorization ID:
migrateTokens() is called automatically during the OAuth token exchange flow when completing federated authentication.

Token Lifetimes

FrontMCP uses default token lifetimes:

Token Refresh Configuration

Token lifetimes are currently set at the server level. Refresh tokens are rotated on each use per OAuth 2.1 best practices.

Token Refresh Flow

Refresh tokens are rotated on each use (OAuth 2.1 best practice):

JWT Structure

Access tokens are JWTs with standard claims:

Custom Claims

Custom claims are sourced from the upstream identity provider (or the in-tree IdP for local mode) — FrontMCP does not mint extra claims. Configure your IdP to include the claims you need (roles, tenant ID, etc.) and then read them via this.context.authInfo?.user (raw) or this.auth.claims (typed) inside tools, resources, prompts, and agents.
Enable consent to let users select granted permissions:
  1. User authenticates
  2. FrontMCP displays available tools/resources/prompts
  3. User selects which to grant
  4. Access token includes only selected scopes

Tool-Level Scopes


JWKS Management

FrontMCP manages cryptographic keys for token signing:

Auto-Generated Keys

By default, keys are auto-generated at startup:
Auto-generated keys are lost on restart. Tokens signed with old keys become invalid.

Persistent Keys

Provide keys for stable token validation across restarts:

Key Rotation

For production, perform key rotation by deploying a new build with an updated signKey while keeping the previous keys in jwks until in-flight tokens have expired:
signKey holds the private signing material; jwks is the public key set published at /.well-known/jwks.json for clients to verify tokens. Never put private JWKs into jwks — doing so exposes the private key.

Token Verification

Verification Flow

Verification Options


Error Responses

Token-related errors follow OAuth 2.0 error format:

Example Error Response


Next Steps

Authorization Modes

Choose the right auth mode for your use case

Progressive Authorization

Implement incremental app authorization

Production Checklist

Security requirements for deployment

Remote OAuth

Connect to external identity providers