This function initializes and starts the MCP server, handling any errors that may occur. # Errors This function will return an error if the MCP server fails to start.
()
| 22 | /// |
| 23 | /// This function will return an error if the MCP server fails to start. |
| 24 | pub async fn start_mcp_server_async() -> Result<(), McpError> { |
| 25 | // Initialize the MCP server |
| 26 | let server = McpServer::new(); |
| 27 | |
| 28 | // Try to create the service with proper error handling |
| 29 | let service = server.serve(stdio()).await |
| 30 | .map_err(|err| McpError::internal_error(t!("mcp.mod.failedToInitialize", error = err.to_string()), None))?; |
| 31 | |
| 32 | // Wait for the service to complete with proper error handling |
| 33 | service.waiting().await |
| 34 | .map_err(|err| McpError::internal_error(t!("mcp.mod.serverWaitFailed", error = err.to_string()), None))?; |
| 35 | |
| 36 | tracing::info!("{}", t!("mcp.mod.serverStopped")); |
| 37 | Ok(()) |
| 38 | } |
| 39 | |
| 40 | /// Synchronous wrapper to start the MCP server |
| 41 | /// |
no test coverage detected