{"record":{"id":"bd020ca3328f77d1","repo":"Hmbown/CodeWhale","slug":"failed-to-connect-mcp-server-server-name-serv","errorCode":null,"errorMessage":"Failed to connect MCP server '{server_name}': server is disabled","messagePattern":"Failed to connect MCP server '(.+?)': server is disabled","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp.rs","lineNumber":3199,"sourceCode":"            tracing::debug!(\n                target: \"mcp\",\n                server = %server_name,\n                reason = \"reconnect\",\n                \"detached MCP connection for reconnect\"\n            );\n        }\n\n        // Check static config first, then dynamic servers\n        let server_config = self\n            .config\n            .servers\n            .get(server_name)\n            .cloned()\n            .or_else(|| self.dynamic_servers.read().get(server_name).cloned())\n            .ok_or_else(|| anyhow::anyhow!(\"Failed to find MCP server: {server_name}\"))?;\n\n        if !server_config.is_enabled() {\n            anyhow::bail!(\"Failed to connect MCP server '{server_name}': server is disabled\");\n        }\n\n        let mut connection = match McpConnection::connect_with_policy(\n            server_name.to_string(),\n            server_config,\n            &self.config.timeouts,\n            self.network_policy.as_ref(),\n        )\n        .await\n        {\n            Ok(connection) => connection,\n            Err(error) => {\n                self.note_connect_failure(server_name, &error);\n                if let Some(previous) = previous_connection {\n                    tracing::debug!(\n                        target: \"mcp\",\n                        server = %server_name,\n                        \"reconnect failed; restored the previous MCP connection and its last-good catalog\"","sourceCodeStart":3181,"sourceCodeEnd":3217,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/mcp.rs#L3181-L3217","documentation":"An explicit connect request targeted a named MCP server whose configuration has `enabled = false`. The pool looks the server up in configured or dynamic servers, finds it, then refuses to start a connection because the server is disabled in config.","triggerScenarios":"Calling the pool's connect method for `server_name` when `server_config.is_enabled()` returns false.","commonSituations":"Server disabled in mcp config file (`enabled = false` or disabled via UI/CLI), stale dynamic server entry disabled earlier, user forgot they disabled a server after an auth failure.","solutions":["Enable the server in the MCP config (`enabled = true`) or via the UI/CLI toggle, then retry.","Remove the `enabled = false` / disabled flag from the server's config block.","If the server should not be used, stop calling connect for it and handle it as intentionally unavailable."],"exampleFix":"// before (mcp config)\n[server.myserver]\nenabled = false\n// after\n[server.myserver]\nenabled = true","handlingStrategy":"validation","validationCode":"if let Some(cfg) = pool.server_config(name) {\n    if !cfg.is_enabled() {\n        return Err(format!(\"server '{name}' is disabled; enable it before connecting\"));\n    }\n}","typeGuard":null,"tryCatchPattern":"match pool.connect(name).await {\n    Err(e) if e.to_string().ends_with(\"server is disabled\") => {\n        // surface 'server disabled' to the user; do not retry\n    }\n    r => r?,\n}","preventionTips":["Check `is_enabled()` from the server listing before issuing connects.","Keep disabled servers out of auto-connect/startup lists.","When toggling a server off, also drop pending/retry connect attempts for it."],"tags":["mcp","configuration","disabled"],"backgroundTag":"feature-not-enabled","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"}