#[non_exhaustive]pub struct OAuthConfig {
pub server_url: String,
pub client_id: String,
pub client_secret: String,
pub app_name: String,
pub passkey_store_path: PathBuf,
pub setup_token: Option<String>,
pub token_lifetime_secs: u64,
pub code_lifetime_secs: u64,
pub allowed_redirect_uris: Vec<String>,
pub rate_limits: RateLimitConfig,
pub capacity: CapacityConfig,
pub scopes: Vec<String>,
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.server_url: StringThe public-facing URL of this server (e.g. <https://my-mcp.fly.dev>).
client_id: StringPre-registered OAuth client ID.
client_secret: StringPre-registered OAuth client secret.
app_name: StringHuman-readable app name shown on pages.
passkey_store_path: PathBufWhere to persist registered passkeys (JSON file).
setup_token: Option<String>One-time token for first passkey registration (when no passkeys exist yet).
token_lifetime_secs: u64Access token lifetime in seconds. Default: 86400 (24 hours).
code_lifetime_secs: u64Authorization code lifetime in seconds. Default: 300 (5 minutes).
allowed_redirect_uris: Vec<String>Redirect URIs that are always accepted (beyond per-client registered URIs). Defaults to the Claude.ai callback URLs.
rate_limits: RateLimitConfigPer-IP rate limiting tiers.
capacity: CapacityConfigIn-memory capacity limits for transient state.
scopes: Vec<String>OAuth scopes supported and returned in token responses.
Defaults to ["mcp:tools"].
Implementations§
Source§impl OAuthConfig
impl OAuthConfig
Sourcepub fn with_defaults(
server_url: String,
client_id: String,
client_secret: String,
app_name: String,
passkey_store_path: PathBuf,
setup_token: Option<String>,
) -> Self
pub fn with_defaults( server_url: String, client_id: String, client_secret: String, app_name: String, passkey_store_path: PathBuf, setup_token: Option<String>, ) -> Self
Create a new OAuthConfig with default token lifetimes.
§Panics
Panics if client_id or client_secret is empty.
Sourcepub fn builder(
server_url: String,
client_id: String,
client_secret: String,
app_name: String,
passkey_store_path: PathBuf,
) -> OAuthConfigBuilder
pub fn builder( server_url: String, client_id: String, client_secret: String, app_name: String, passkey_store_path: PathBuf, ) -> OAuthConfigBuilder
Create a builder for OAuthConfig with required parameters.
§Example
use mcp_oauth::OAuthConfig;
use std::path::PathBuf;
let config = OAuthConfig::builder(
"https://my-mcp.example.com".into(),
"my-client-id".into(),
"my-client-secret".into(),
"My MCP Server".into(),
PathBuf::from("passkeys.json"),
)
.setup_token("initial-setup-token")
.token_lifetime_secs(3600)
.add_redirect_uri("https://myapp.example.com/callback")
.build()
.expect("valid config");