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