Basic Configuration
Add authentication parameters to yourWidgetMCPServer:
With Audience
Some OAuth providers (like Auth0) require an audience claim:Configuration Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
auth_issuer_url | str | Yes* | OAuth issuer URL (e.g., https://tenant.auth0.com) |
auth_resource_server_url | str | Yes* | Your MCP server URL (e.g., https://example.com/mcp) |
auth_required_scopes | List[str] | No | Required OAuth scopes (e.g., ["user", "read:data"]) |
auth_audience | str | No | JWT audience claim (required by some providers) |
token_verifier | TokenVerifier | No | Custom token verifier (uses JWTVerifier by default) |
auth_issuer_url and auth_resource_server_url must be provided to enable authentication.
Built-in JWT Verification
FastApps includes aJWTVerifier that automatically validates tokens.
How It Works
The built-in verifier:- Discovers JWKS URI from issuer’s
.well-known/openid-configuration - Validates JWT signature using public keys
- Verifies issuer, audience, expiration
- Checks required scopes
- Extracts user claims
Example
- Validates JWT signature
- Verifies issuer matches
https://tenant.auth0.com - Checks audience is
https://api.example.com - Ensures token has
userandread:datascopes
Multiple Scopes
Require multiple scopes for all widgets:Complete Example
Environment Variables
Store OAuth configuration in environment variables:Authentication Inheritance
Per MCP spec: “Missing field: inherit server default policy” When server authentication is enabled:- Widgets without decorators inherit server auth requirements
- Widgets can opt-out with
@no_auth - Widgets can add scopes with
@auth_required(scopes=[...]) - Widgets can make auth optional with
@optional_auth

