Skip to main content

OAuthConfig

Struct OAuthConfig 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§server_url: String

The public-facing URL of this server (e.g. <https://my-mcp.fly.dev>).

§client_id: String

Pre-registered OAuth client ID.

§client_secret: String

Pre-registered OAuth client secret.

§app_name: String

Human-readable app name shown on pages.

§passkey_store_path: PathBuf

Where 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: u64

Access token lifetime in seconds. Default: 86400 (24 hours).

§code_lifetime_secs: u64

Authorization 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: RateLimitConfig

Per-IP rate limiting tiers.

§capacity: CapacityConfig

In-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

Source

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.

Source

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");

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,