Skip to main content
Version: 1.1.0

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โ€‹

ApproachUse caseDCRComplexityDocs
RemoteAuthProviderYour own IdP with DCR (Keycloak, WorkOS, Scalekit)โœ… AutoMediumRemoteAuthProvider
OAuthProxy (coming soon)Your own IdP without DCRProxyHighOAuthProxy
Token VerificationAccept tokens from external systemsN/ALowToken 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โ€‹

ProviderCrateDCRDocs
Keycloakrust-mcp-extraโœ…Keycloak
WorkOS AuthKitrust-mcp-extraโœ…WorkOS
Scalekitrust-mcp-extraโœ…Scalekit
Custom OIDCrust-mcp-sdk (core)if supportedRemoteAuthProvider

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

โ†’ rust-mcp-extra overview