Choosing an Auth Approach
rust-mcp-sdk supports several authentication patterns. Which one you need depends on your infrastructure.
Decision treeโ
Do you run your own identity provider?
โโโ YES โ Does it support Dynamic Client Registration (DCR)?
โ โโโ YES โ RemoteAuthProvider (Keycloak, WorkOS, Scalekit)
โ โโโ NO โ OAuthProxy (coming soon - not yet in v1.0.0)
โ
โโโ NO โ Do tokens come from an external system you don't control?
โโโ YES โ Token Verification (validate JWTs or call introspection)
โโโ NO โ You probably don't need auth yet
Approach comparisonโ
| Approach | Use case | DCR | Complexity | Docs |
|---|---|---|---|---|
| RemoteAuthProvider | Your own IdP with DCR (Keycloak, WorkOS, Scalekit) | โ Auto | Medium | RemoteAuthProvider |
| OAuthProxy (coming soon) | Your own IdP without DCR | Proxy | High | OAuthProxy |
| Token Verification | Accept tokens from external systems | N/A | Low | Token Verification |
note
OAuthProxy is still work-in-progress and not included in v1.0.0. Until it ships, pair RemoteAuthProvider with a DCR-capable IdP.
Provider support matrixโ
| Provider | Crate | DCR | Docs |
|---|---|---|---|
| Keycloak | rust-mcp-extra | โ | Keycloak |
| WorkOS AuthKit | rust-mcp-extra | โ | WorkOS |
| Scalekit | rust-mcp-extra | โ | Scalekit |
| Custom OIDC | rust-mcp-sdk (core) | if supported | RemoteAuthProvider |
Client-side authโ
If you're building an MCP client that needs to authenticate:
- Use the built-in OAuth client flow โ Client OAuth Flow
- DCR auto-registers your client โ DCR
- PKCE secures the authorization code exchange โ handled automatically
- Tokens are persisted via a pluggable store โ Token Store
Extra: ID generators and token verifiersโ
The rust-mcp-extra crate provides utilities beyond auth providers:
- ID generators - NanoId, TimeBase64, RandomBase62, Snowflake - for session IDs
- Token verifiers - pluggable JWT validation