Why OAuth 2.1?
The Model Context Protocol specification recommends OAuth 2.1 as the standard auth mechanism for HTTP-based MCP servers. It provides:- Short-lived access tokens that limit the impact of token leakage
- Refresh tokens for long-lived sessions without re-authentication
- Fine-grained scopes to control what clients can do
- PKCE to prevent authorization code interception attacks (mandatory —
plainmethod not accepted)
How it works
Resource Indicators (RFC 8707)
Access tokens are bound to a specific server URI using RFC 8707 Resource Indicators. A token issued formy-server.mcp.ezforge.ai cannot be used to call any other server. This prevents token replay attacks across servers.
MCP scopes
| Scope | Description |
|---|---|
mcp:read | List available tools on the server |
mcp:write | Call tools that modify state |
mcp:execute | Execute any tool call (most permissive) |
offline_access | Request long-lived refresh tokens |
ezforge_managed mode
When a server usesezforge_managed auth (the default), ezForge acts as the OAuth authorization server:
- ezForge registers the MCP client
- Handles the authorization flow
- Issues and validates tokens
- No configuration required from you
BYOA mode (Bring Your Own Auth)
If you already run an OAuth 2.1 authorization server, you can configure your ezForge server to accept tokens from it:- Fetching your JWKS endpoint to get public keys
- Verifying the JWT signature
- Checking the
issclaim matches your configured issuer - Checking the
audclaim includes the server’s URI (RFC 8707) - Verifying the token is not expired
Protected Resource Metadata
All ezForge-hosted servers expose the RFC 9728 standard endpoint:Token lifetimes
| Token | Lifetime | Notes |
|---|---|---|
| Authorization code | 5 minutes | Single-use; consumed on token exchange |
| Access token | 15 minutes | Short-lived; limits blast radius of leakage |
| Refresh token | 30 days | Rotated on each use |
Security recommendations
- Request only the scopes your application needs
- Use
offline_accessonly when a long-lived session is necessary - Treat access tokens as secrets — don’t log them or include them in URLs
- Rotate refresh tokens regularly; ezForge rotates them automatically on use