bearer
fastmcp.server.auth.providers.bearer
Classes
JWKData
JSON Web Key data structure.
JWKSData
JSON Web Key Set data structure.
RSAKeyPair
Methods:
generate
Generate an RSA key pair for testing.
Returns:
- (private_key_pem, public_key_pem)
create_token
Generate a test JWT token for testing purposes.
Args:
private_key_pem
: RSA private key in PEM formatsubject
: Subject claim (usually user ID)issuer
: Issuer claimaudience
: Audience claim - can be a string or list of strings (optional)scopes
: List of scopes to includeexpires_in_seconds
: Token expiration time in secondsadditional_claims
: Any additional claims to includekid
: Key ID for JWKS lookup (optional)
Returns:
- Signed JWT token string
BearerAuthProvider
Simple JWT Bearer Token validator for hosted MCP servers. Uses RS256 asymmetric encryption. Supports either static public key or JWKS URI for key rotation.
Note that this provider DOES NOT permit client registration or revocation, or any OAuth flows. It is intended to be used with a control plane that manages clients and tokens.