{"record":{"id":"d5fe2f0c42495543","repo":"Hmbown/CodeWhale","slug":"required-mcp-server-failed-to-initialize","errorCode":null,"errorMessage":"required MCP server failed to initialize","messagePattern":"required MCP server failed to initialize","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp.rs","lineNumber":3763,"sourceCode":"    pub(crate) fn push_required_server_errors(&self, errors: &mut Vec<McpConnectError>) {\n        for (name, server_cfg) in &self.config.servers {\n            // Only stand in for a missing diagnosis. When the connect attempt\n            // above already reported why this server failed, appending a\n            // second, contentless entry for the same name buries it: callers\n            // fold these pairs into a `HashMap<name, message>`, so the later\n            // generic string silently replaced the real cause.\n            if self.server_allowed(name)\n                && server_cfg.required\n                && server_cfg.is_enabled()\n                && !self\n                    .connections\n                    .get(name)\n                    .is_some_and(McpConnection::is_ready)\n                && !errors.iter().any(|(failed, _)| failed == name)\n            {\n                errors.push((\n                    name.clone(),\n                    anyhow::anyhow!(\"required MCP server failed to initialize\"),\n                ));\n            }\n        }\n    }\n\n    /// Handshake the pending servers concurrently without holding the pool\n    /// lock. Callers insert results under a short lock so a live turn can\n    /// snapshot ready tools while optional servers are still connecting.\n    pub(crate) fn spawn_pending_connects(\n        pending: Vec<McpPendingConnect>,\n        timeouts: McpTimeouts,\n        network_policy: Option<NetworkPolicyDecider>,\n        catalog_generation: u64,\n    ) -> tokio::task::JoinSet<(String, Result<McpConnection, anyhow::Error>)> {\n        let semaphore = std::sync::Arc::new(tokio::sync::Semaphore::new(Self::CONNECT_CONCURRENCY));\n        let mut joins: tokio::task::JoinSet<(String, Result<McpConnection, anyhow::Error>)> =\n            tokio::task::JoinSet::new();\n        for (name, config) in pending {","sourceCodeStart":3745,"sourceCodeEnd":3781,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/mcp.rs#L3745-L3781","documentation":"After a connect pass completes, the pool checks servers marked required and reports this error for any that never reached the ready state and have no other recorded error. It ensures a required server's absence is loud even when the individual handshake produced no diagnostic.","triggerScenarios":"A server listed as required in MCP config failed to become ready (is_ready() false) after the concurrent handshake pass, and it is absent from the errors list.","commonSituations":"Required server binary missing or failing silently at spawn; required server disabled in config; slow server that did not finish handshake within the pass.","solutions":["Check the server's command/URL in the MCP config and verify it starts manually (e.g. run the listed command directly)","Ensure the required server is enabled in config (is_enabled)","Check server logs/stderr for why the handshake did not complete; if it is simply slow, retry the connect"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before startup, verify each required server is configured and enabled\nfor name in required_servers {\n    let cfg = config.server_config(&name).ok_or_else(|| anyhow!(\"required server '{name}' missing\"))?;\n    anyhow::ensure!(cfg.is_enabled(), \"required server '{name}' disabled\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mark servers required only when truly needed; prefer optional + explicit errors","Smoke-test required server commands manually before wiring them into config","Watch the status row for required servers at startup"],"tags":["mcp","initialization","required-server","startup"],"backgroundTag":"module-init-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}