get_bind_socket_addr

Function get_bind_socket_addr 

Source
pub fn get_bind_socket_addr() -> Result<SocketAddr, ConfigError>
Expand description

Get server bind address as SocketAddr

Examples found in repository?
examples/oauth_standard_mcp_server.rs (line 30)
10async fn main() -> AppResult<()> {
11    // Load environment variables
12    dotenv::dotenv().ok();
13
14    // Initialize tracing
15    init_tracing()?;
16
17    tracing::info!("Starting MCP OAuth server with microkernel architecture...");
18
19    // Create OAuth provider
20    let github_config = get_github_oauth_provider_config()?;
21    let oauth_provider = GitHubOAuthProvider::new_github(github_config);
22
23    // Log configuration
24    log_startup_info();
25
26    // Create microkernel server with all handlers composed
27    let microkernel = create_full_github_microkernel(oauth_provider);
28
29    // Start the microkernel server
30    let bind_address = get_bind_socket_addr()?;
31    microkernel.serve(bind_address).await?;
32
33    Ok(())
34}
More examples
Hide additional examples
examples/oauth_cognito_mcp_server.rs (line 38)
13async fn main() -> AppResult<()> {
14    // Load environment variables
15    dotenv::dotenv().ok();
16
17    // Initialize tracing
18    init_tracing()?;
19
20    tracing::info!("Starting MCP OAuth server with Cognito and microkernel architecture...");
21
22    // Create Cognito OAuth provider
23    let cognito_config = get_cognito_oauth_provider_config()?;
24    let oauth_provider = CognitoOAuthProvider::new_cognito(
25        cognito_config,
26        get_cognito_domain()?,
27        get_cognito_region()?,
28        get_cognito_user_pool_id()?,
29    );
30
31    // Log configuration
32    log_startup_info();
33
34    // Create microkernel server with all handlers composed
35    let microkernel = create_full_cognito_microkernel(oauth_provider);
36
37    // Start the microkernel server
38    let bind_address = get_bind_socket_addr()?;
39    microkernel.serve(bind_address).await?;
40
41    Ok(())
42}
examples/oauth_cognito_dynamodb_mcp_server.rs (line 101)
63async fn main() -> AppResult<()> {
64    // Load environment variables
65    dotenv::dotenv().ok();
66
67    // Initialize tracing
68    init_tracing()?;
69
70    tracing::info!("Starting MCP OAuth server with Cognito and DynamoDB storage...");
71
72    // Create Cognito OAuth configuration
73    let cognito_config = get_cognito_oauth_provider_config()?;
74
75    // Get DynamoDB configuration
76    let table_name =
77        env::var("DYNAMODB_TABLE_NAME").unwrap_or_else(|_| "oauth-storage".to_string());
78    let create_table = env::var("DYNAMODB_CREATE_TABLE")
79        .unwrap_or_else(|_| "true".to_string())
80        .parse::<bool>()
81        .unwrap_or(true);
82
83    // Log configuration
84    log_startup_info(&table_name, create_table);
85
86    // Create microkernel server with Cognito OAuth and DynamoDB storage
87    let microkernel = create_full_cognito_microkernel_dynamodb(
88        cognito_config,
89        get_cognito_domain()?,
90        get_cognito_region()?,
91        get_cognito_user_pool_id()?,
92        table_name,
93        create_table,
94    )
95    .await
96    .map_err(|e| {
97        remote_mcp_kernel::error::AppError::Internal(format!("Failed to create microkernel: {}", e))
98    })?;
99
100    // Start the microkernel server
101    let bind_address = get_bind_socket_addr()?;
102    microkernel.serve(bind_address).await?;
103
104    Ok(())
105}
examples/custom_mcp_server_example.rs (line 483)
421async fn main() -> AppResult<()> {
422    // Load environment variables
423    dotenv::dotenv().ok();
424
425    // Initialize tracing
426    init_tracing()?;
427
428    tracing::info!("Starting Custom MCP Server example with Cognito and DynamoDB storage...");
429
430    // Create Cognito OAuth configuration
431    let cognito_config = get_cognito_oauth_provider_config()?;
432
433    // Get DynamoDB configuration
434    let table_name =
435        env::var("DYNAMODB_TABLE_NAME").unwrap_or_else(|_| "oauth-storage".to_string());
436    let create_table = env::var("DYNAMODB_CREATE_TABLE")
437        .unwrap_or_else(|_| "true".to_string())
438        .parse::<bool>()
439        .unwrap_or(true);
440
441    // Log configuration
442    log_startup_info(&table_name, create_table);
443
444    // Create DynamoDB storage
445    let (storage, client_manager) = create_dynamodb_storage(
446        table_name.clone(),
447        create_table,
448        Some("expires_at".to_string()),
449    )
450    .await
451    .map_err(|e| {
452        remote_mcp_kernel::error::AppError::Internal(format!(
453            "Failed to create DynamoDB storage: {}",
454            e
455        ))
456    })?;
457
458    // Create Cognito OAuth provider with DynamoDB storage
459    let oauth_handler = oauth_provider_rs::CognitoOAuthHandler::new_simple(
460        storage,
461        client_manager,
462        cognito_config,
463        get_cognito_domain()?,
464        get_cognito_region()?,
465        get_cognito_user_pool_id()?,
466    );
467
468    let oauth_provider = OAuthProvider::new(
469        oauth_handler,
470        oauth_provider_rs::http_integration::config::OAuthProviderConfig::default(),
471    );
472
473    // Create custom MCP server
474    let custom_mcp_server = CustomMcpServer::new("Custom File & System MCP Server".to_string());
475
476    // Build microkernel with custom MCP server using convenience methods
477    let microkernel = MicrokernelServer::new()
478        .with_oauth_provider(oauth_provider)
479        .with_mcp_streamable_handler(custom_mcp_server.clone())
480        .with_mcp_sse_handler(custom_mcp_server, SseHandlerConfig::default());
481
482    // Start the microkernel server
483    let bind_address = get_bind_socket_addr()?;
484    tracing::info!("🚀 Starting microkernel server on {}", bind_address);
485    microkernel.serve(bind_address).await?;
486
487    Ok(())
488}