Struct Config

Source
pub struct Config {
    pub server: ServerConfig,
    pub oauth: OAuthConfig,
    pub github: GitHubConfig,
    pub cognito: CognitoConfig,
    pub logging: LoggingConfig,
}
Expand description

Application configuration

Fields§

§server: ServerConfig§oauth: OAuthConfig§github: GitHubConfig§cognito: CognitoConfig§logging: LoggingConfig

Implementations§

Source§

impl Config

Source

pub fn default() -> Self

Create configuration with default values (for testing/development)

Source

pub fn from_env() -> Result<Self, ConfigError>

Load configuration from environment variables with sensible defaults

Examples found in repository?
examples/oauth_standard_mcp_server.rs (line 11)
6async fn main() -> AppResult<()> {
7    // Load environment variables
8    dotenv::dotenv().ok();
9
10    // Load configuration
11    let config = Config::from_env()?;
12
13    // Initialize tracing
14    init_tracing(&config)?;
15
16    tracing::info!("Starting MCP OAuth server with microkernel architecture...");
17
18    // Create OAuth provider
19    let github_config = GitHubOAuthConfig {
20        client_id: config.github.client_id.clone(),
21        client_secret: config.github.client_secret.clone(),
22        redirect_uri: config.github.redirect_uri.clone(),
23        scope: config.github.scope.clone(),
24        provider_name: "github".to_string(),
25    };
26    let oauth_provider = GitHubOAuthProvider::new_github(github_config);
27
28    // Log configuration
29    log_startup_info(&config);
30
31    // Create microkernel server with all handlers composed
32    let microkernel = create_full_github_microkernel(oauth_provider);
33
34    // Start the microkernel server
35    let bind_address = config.bind_socket_addr()?;
36    microkernel.serve(bind_address).await?;
37
38    Ok(())
39}
More examples
Hide additional examples
examples/oauth_cognito_mcp_server.rs (line 11)
6async fn main() -> AppResult<()> {
7    // Load environment variables
8    dotenv::dotenv().ok();
9
10    // Load configuration
11    let config = Config::from_env()?;
12
13    // Initialize tracing
14    init_tracing(&config)?;
15
16    tracing::info!("Starting MCP OAuth server with Cognito and microkernel architecture...");
17
18    // Create Cognito OAuth provider
19    let cognito_config = CognitoOAuthConfig {
20        client_id: config.cognito.client_id.clone(),
21        client_secret: config.cognito.client_secret.clone().unwrap_or_default(),
22        redirect_uri: config.cognito.redirect_uri.clone(),
23        scope: config.cognito.scope.clone(),
24        provider_name: "cognito".to_string(),
25    };
26    let oauth_provider = CognitoOAuthProvider::new_cognito(
27        cognito_config,
28        config.cognito.cognito_domain.clone(),
29        config.cognito.region.clone(),
30        config.cognito.user_pool_id.clone(),
31    );
32
33    // Log configuration
34    log_startup_info(&config);
35
36    // Create microkernel server with all handlers composed
37    let microkernel = create_full_cognito_microkernel(oauth_provider);
38
39    // Start the microkernel server
40    let bind_address = config.bind_socket_addr()?;
41    microkernel.serve(bind_address).await?;
42
43    Ok(())
44}
examples/oauth_cognito_dynamodb_mcp_server.rs (line 64)
59async fn main() -> AppResult<()> {
60    // Load environment variables
61    dotenv::dotenv().ok();
62
63    // Load configuration
64    let config = Config::from_env()?;
65
66    // Initialize tracing
67    init_tracing(&config)?;
68
69    tracing::info!("Starting MCP OAuth server with Cognito and DynamoDB storage...");
70
71    // Create Cognito OAuth configuration
72    let cognito_config = CognitoOAuthConfig {
73        client_id: config.cognito.client_id.clone(),
74        client_secret: config.cognito.client_secret.clone().unwrap_or_default(),
75        redirect_uri: format!(
76            "http://{}:{}/oauth/callback",
77            config.server.host, config.server.port
78        ),
79        scope: config.cognito.scope.clone(),
80        provider_name: "cognito".to_string(),
81    };
82
83    // Get DynamoDB configuration
84    let table_name =
85        env::var("DYNAMODB_TABLE_NAME").unwrap_or_else(|_| "oauth-storage".to_string());
86    let create_table = env::var("DYNAMODB_CREATE_TABLE")
87        .unwrap_or_else(|_| "true".to_string())
88        .parse::<bool>()
89        .unwrap_or(true);
90
91    // Log configuration
92    log_startup_info(&config, &table_name, create_table);
93
94    // Create microkernel server with Cognito OAuth and DynamoDB storage
95    let microkernel = create_full_cognito_microkernel_dynamodb(
96        cognito_config,
97        config.cognito.cognito_domain.clone(),
98        config.cognito.region.clone(),
99        config.cognito.user_pool_id.clone(),
100        table_name,
101        create_table,
102    )
103    .await
104    .map_err(|e| {
105        remote_mcp_kernel::error::AppError::Internal(format!("Failed to create microkernel: {}", e))
106    })?;
107
108    // Start the microkernel server
109    let bind_address = config.bind_socket_addr()?;
110    microkernel.serve(bind_address).await?;
111
112    Ok(())
113}
Source

pub fn github_oauth_config(&self) -> GitHubOAuthConfig

Get GitHub OAuth configuration

Source

pub fn github_oauth_provider_config(&self) -> OAuthProviderConfig

Get OAuth provider configuration for GitHub

Source

pub fn cognito_oauth_config(&self) -> CognitoOAuthConfig

Get Cognito OAuth configuration

Source

pub fn cognito_oauth_provider_config(&self) -> OAuthProviderConfig

Get OAuth provider configuration for Cognito

Source

pub fn oauth_provider_config(&self) -> OAuthProviderConfig

Get OAuth provider configuration

Source

pub fn bind_socket_addr(&self) -> Result<SocketAddr, ConfigError>

Get server bind address as SocketAddr

Examples found in repository?
examples/oauth_standard_mcp_server.rs (line 35)
6async fn main() -> AppResult<()> {
7    // Load environment variables
8    dotenv::dotenv().ok();
9
10    // Load configuration
11    let config = Config::from_env()?;
12
13    // Initialize tracing
14    init_tracing(&config)?;
15
16    tracing::info!("Starting MCP OAuth server with microkernel architecture...");
17
18    // Create OAuth provider
19    let github_config = GitHubOAuthConfig {
20        client_id: config.github.client_id.clone(),
21        client_secret: config.github.client_secret.clone(),
22        redirect_uri: config.github.redirect_uri.clone(),
23        scope: config.github.scope.clone(),
24        provider_name: "github".to_string(),
25    };
26    let oauth_provider = GitHubOAuthProvider::new_github(github_config);
27
28    // Log configuration
29    log_startup_info(&config);
30
31    // Create microkernel server with all handlers composed
32    let microkernel = create_full_github_microkernel(oauth_provider);
33
34    // Start the microkernel server
35    let bind_address = config.bind_socket_addr()?;
36    microkernel.serve(bind_address).await?;
37
38    Ok(())
39}
More examples
Hide additional examples
examples/oauth_cognito_mcp_server.rs (line 40)
6async fn main() -> AppResult<()> {
7    // Load environment variables
8    dotenv::dotenv().ok();
9
10    // Load configuration
11    let config = Config::from_env()?;
12
13    // Initialize tracing
14    init_tracing(&config)?;
15
16    tracing::info!("Starting MCP OAuth server with Cognito and microkernel architecture...");
17
18    // Create Cognito OAuth provider
19    let cognito_config = CognitoOAuthConfig {
20        client_id: config.cognito.client_id.clone(),
21        client_secret: config.cognito.client_secret.clone().unwrap_or_default(),
22        redirect_uri: config.cognito.redirect_uri.clone(),
23        scope: config.cognito.scope.clone(),
24        provider_name: "cognito".to_string(),
25    };
26    let oauth_provider = CognitoOAuthProvider::new_cognito(
27        cognito_config,
28        config.cognito.cognito_domain.clone(),
29        config.cognito.region.clone(),
30        config.cognito.user_pool_id.clone(),
31    );
32
33    // Log configuration
34    log_startup_info(&config);
35
36    // Create microkernel server with all handlers composed
37    let microkernel = create_full_cognito_microkernel(oauth_provider);
38
39    // Start the microkernel server
40    let bind_address = config.bind_socket_addr()?;
41    microkernel.serve(bind_address).await?;
42
43    Ok(())
44}
examples/oauth_cognito_dynamodb_mcp_server.rs (line 109)
59async fn main() -> AppResult<()> {
60    // Load environment variables
61    dotenv::dotenv().ok();
62
63    // Load configuration
64    let config = Config::from_env()?;
65
66    // Initialize tracing
67    init_tracing(&config)?;
68
69    tracing::info!("Starting MCP OAuth server with Cognito and DynamoDB storage...");
70
71    // Create Cognito OAuth configuration
72    let cognito_config = CognitoOAuthConfig {
73        client_id: config.cognito.client_id.clone(),
74        client_secret: config.cognito.client_secret.clone().unwrap_or_default(),
75        redirect_uri: format!(
76            "http://{}:{}/oauth/callback",
77            config.server.host, config.server.port
78        ),
79        scope: config.cognito.scope.clone(),
80        provider_name: "cognito".to_string(),
81    };
82
83    // Get DynamoDB configuration
84    let table_name =
85        env::var("DYNAMODB_TABLE_NAME").unwrap_or_else(|_| "oauth-storage".to_string());
86    let create_table = env::var("DYNAMODB_CREATE_TABLE")
87        .unwrap_or_else(|_| "true".to_string())
88        .parse::<bool>()
89        .unwrap_or(true);
90
91    // Log configuration
92    log_startup_info(&config, &table_name, create_table);
93
94    // Create microkernel server with Cognito OAuth and DynamoDB storage
95    let microkernel = create_full_cognito_microkernel_dynamodb(
96        cognito_config,
97        config.cognito.cognito_domain.clone(),
98        config.cognito.region.clone(),
99        config.cognito.user_pool_id.clone(),
100        table_name,
101        create_table,
102    )
103    .await
104    .map_err(|e| {
105        remote_mcp_kernel::error::AppError::Internal(format!("Failed to create microkernel: {}", e))
106    })?;
107
108    // Start the microkernel server
109    let bind_address = config.bind_socket_addr()?;
110    microkernel.serve(bind_address).await?;
111
112    Ok(())
113}

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> ErasedDestructor for T
where T: 'static,