Protect your server by validating bearer tokens issued by external systems.
New in version: 2.11.0
Token verification enables your FastMCP server to validate bearer tokens issued by external systems without participating in user authentication flows. Your server acts as a pure resource server, focusing on token validation and authorization decisions while delegating identity management to other systems in your infrastructure.
TokenVerifier
class to handle token validation complexity while remaining flexible about token sources and validation strategies.
TokenVerifier
focuses exclusively on token validation without providing OAuth discovery metadata. This makes it ideal for internal systems where clients already know how to obtain tokens, or for microservices that trust tokens from known issuers.
The class validates token signatures, checks expiration timestamps, and extracts authorization information from token claims. It supports various token formats and validation strategies while maintaining a consistent interface for authorization decisions.
You can subclass TokenVerifier
to implement custom validation logic for specialized token formats or validation requirements. The base class handles common patterns while allowing extension for unique use cases.
JWTVerifier
validates JWTs using industry-standard cryptographic techniques and claim validation.
auth.yourcompany.com
. The verifier periodically fetches public keys from the JWKS endpoint and validates incoming tokens against those keys. Only tokens with the correct issuer and audience claims will be accepted.
The issuer
parameter ensures tokens come from your trusted authentication system, while audience
validation prevents tokens intended for other services from being accepted by your MCP server.
Authorization: Bearer dev-alice-token
headers. The server will recognize the token and load the associated claims for authorization decisions. This approach enables immediate development without external dependencies.