{"record":{"id":"21ff8a4ad0677659","repo":"Hmbown/CodeWhale","slug":"failed-to-find-mcp-server-server","errorCode":null,"errorMessage":"Failed to find MCP server: {server}","messagePattern":"Failed to find MCP server: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp.rs","lineNumber":2917,"sourceCode":"    pub(crate) fn server_denied_by(rules: &[String], server: &str) -> bool {\n        let namespace = format!(\"mcp_{server}_\").to_ascii_lowercase();\n        rules.iter().any(|rule| {\n            rule.to_ascii_lowercase()\n                .strip_suffix('*')\n                .is_some_and(|prefix| namespace.starts_with(prefix))\n        })\n    }\n\n    fn server_allowed(&self, server: &str) -> bool {\n        !Self::server_denied_by(&self.disallowed_tools, server)\n    }\n\n    pub(crate) fn tool_allowed(&self, name: &str) -> bool {\n        !crate::core::engine::tool_catalog::tool_matches_any_rule(&self.disallowed_tools, name)\n    }\n\n    fn require_server(&self, server: &str) -> Result<()> {\n        anyhow::ensure!(\n            self.server_allowed(server),\n            \"Failed to find MCP server: {server}\"\n        );\n        Ok(())\n    }\n\n    pub(crate) fn authorize_call(\n        rules: &[String],\n        name: &str,\n        input: &serde_json::Value,\n    ) -> Result<()> {\n        anyhow::ensure!(\n            !crate::core::engine::tool_catalog::tool_matches_any_rule(rules, name),\n            \"Unknown MCP tool name: {name}\"\n        );\n        if matches!(\n            name,\n            \"list_mcp_resources\"","sourceCodeStart":2899,"sourceCodeEnd":2935,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/mcp.rs#L2899-L2935","documentation":"require_server() checks the requested MCP server name against the allow rules (server_allowed) and fails with this message when the name is not permitted. The wording deliberately mirrors \"server not found\" so the model cannot probe which servers exist; the real cause is a disallow rule, not a missing server.","triggerScenarios":"Invoking an MCP tool whose input names a server that does not match any allowed server rule — i.e. tool_matches_any_rule matched the disallowed_tools/server-deny configuration for that server name.","commonSituations":"Typo in the server name in a tools/call; calling an MCP server that was removed from or never added to the allowlist; stale session referencing a server disabled in config.","solutions":["Check the server name spelling against the configured MCP servers.","Confirm the server is in the allow rules (not in disallowed_tools) in the MCP config.","List available servers via the MCP listing tooling before dispatching a call.","Reconnect or reload config if the server was recently enabled."],"exampleFix":"// before\nconn.call(\"db-server\", \"query\", input)?\n// after: guard with the same allow rule the pool uses\nif !pool.server_allowed(\"db-server\") { return Err(...); }\nconn.call(\"db-server\", \"query\", input)?","handlingStrategy":"validation","validationCode":"// Resolve the server list and check before calling\nlet servers: Vec<String> = pool.list_server_names();\nassert!(servers.iter().any(|s| s == server), \"unknown MCP server: {server}\");","typeGuard":"fn server_in_list(servers: &[String], name: &str) -> bool {\n    servers.iter().any(|s| s == name)\n}","tryCatchPattern":"match pool.call_tool(server, tool, input) {\n    Err(e) if e.to_string().contains(\"Failed to find MCP server\") => {\n        eprintln!(\"server '{server}' is not available; check spelling and config\");\n    }\n    other => other?,\n}","preventionTips":["Pick server names from the configured list rather than typing them.","Reload config in long-lived sessions after editing MCP servers.","Keep server names stable across renames or provide aliases.","Surface the allowed server list to users/UI before dispatch."],"tags":["mcp","allowlist","server-name"],"backgroundTag":"entity-not-found","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"}