{"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":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp.rs","lineNumber":2672,"sourceCode":"            return self\n                .connections\n                .get_mut(server_name)\n                .ok_or_else(|| anyhow::anyhow!(\"MCP connection disappeared for {server_name}\"));\n        }\n\n        self.drop_connection(server_name, \"reconnect\");\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 = 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        connection.catalog_generation = self.catalog_generation.load(Ordering::SeqCst);\n\n        self.connections.insert(server_name.to_string(), connection);\n        self.connections\n            .get_mut(server_name)\n            .ok_or_else(|| anyhow::anyhow!(\"Failed to store MCP connection for {server_name}\"))\n    }\n\n    /// Connect to all enabled servers, returning errors for failed connections","sourceCodeStart":2654,"sourceCodeEnd":2690,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/tui/src/mcp.rs#L2654-L2690","documentation":"get_or_connect found the server in static config or dynamic_servers, but McpServerConfig::is_enabled() returned false, so it refuses to spawn/connect. The server exists but was explicitly disabled (an enabled: false style flag in the server entry, or however the config expresses opt-out), and the pool treats that as a hard stop rather than silently connecting.","triggerScenarios":"Any access path (tool call, resource read, prompt get, connect_all) naming a server whose config sets the enabled flag to false; also dynamic registrations created in a disabled state.","commonSituations":"Users temporarily disabling a broken server in config and forgetting to re-enable; config templates that ship servers disabled by default; programmatic callers enumerating all keys in the file without filtering on enabled; flip-flopping the flag while a session holds old state.","solutions":["Set the server's enabled flag to true in the MCP config (or remove the disabling override) and save, then retry — the lazy reload picks up the mtime change.","Filter call sites on is_enabled() so disabled servers are skipped instead of erroring.","If it should stay disabled, remove or stop calling the code path that references it.","For dynamic servers, register with the enabled state you actually want."],"exampleFix":"# before (.mcp.json)\n{\"servers\": {\"github\": {\"command\": \"gh-mcp\", \"enabled\": false}}}\n\n# after\n{\"servers\": {\"github\": {\"command\": \"gh-mcp\", \"enabled\": true}}}","handlingStrategy":"validation","validationCode":"// Rust: check enablement before dispatch\nif let Some(cfg) = pool.config().servers.get(name) {\n    if !cfg.is_enabled() {\n        bail!(\"server '{name}' is disabled in config; enable it or skip the call\");\n    }\n}\nlet conn = pool.get_or_connect(name).await?;","typeGuard":null,"tryCatchPattern":"// Rust: catch and route around disabled servers\nmatch pool.get_or_connect(name).await {\n    Err(e) if e.to_string().contains(\"server is disabled\") => {\n        return Ok(fallback_without(name)); // skip feature relying on this server\n    }\n    o => o,\n}","preventionTips":["Filter iteration over config.servers on is_enabled() before issuing calls.","Keep disabled servers out of model-visible tool catalogs.","When toggling enabled, expect one reload cycle before the change takes effect."],"tags":["mcp","config","disabled","flag"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}