Skip to main content
Version: 1.1.0

Client Auth Config

Full Client Auth Configurationโ€‹

McpAuthConfig is a flat config built with builder(). build() returns a ready-to-use McpAuthClient:

use std::sync::Arc;
use rust_mcp_sdk::auth::{InMemoryTokenStore, McpAuthConfig};

let client = McpAuthConfig::builder()
.server_url("https://mcp.example.com/mcp") // required
.client_id("my-client") // optional, skips DCR
.client_secret("my-secret") // optional, token endpoint auth
.scope("mcp tools") // optional, requested scopes
.redirect_uri("http://localhost:3000/callback") // optional, needed for auth-code flows
.resource("https://mcp.example.com/mcp") // optional, RFC 8707 resource indicator
.token_store(Arc::new(InMemoryTokenStore::new())) // optional, default store
.build()?;
FieldRequiredPurpose
server_urlYesBase URL of the MCP server; discovery starts here
client_idNoPre-registered client ID (skips DCR if set)
client_secretNoPre-registered client secret (client_secret_basic/post at the token endpoint)
scopeNoOAuth scopes to request, e.g. "mcp tools"
redirect_uriNoRedirect URI for the authorization-code grant
metadataNoPre-discovered AuthorizationServerMetadata (skips discovery)
resourceNoRFC 8707 resource indicator, sent as the resource parameter
client_metadata_urlNoSEP-991 Client ID Metadata Document URL (replaces DCR when supported)
token_storeNoCustom Arc<dyn TokenStore>; defaults to InMemoryTokenStore

When connecting to an MCP server with auth, the SDK uses the metadata endpoints to discover authorization, token, and registration URLs automatically - see DCR and Token Store.