Hmbown/CodeWhale · error

MCP server '{name}' not found

Error message

MCP server '{name}' not found

What it means

remove_server_config loads the config file and deletes the named entry from the servers map. If the key is absent, nothing is removed and the operation fails with 'not found' rather than silently rewriting the file as a no-op.

Source

Thrown at crates/tui/src/mcp.rs:4058

            required: false,
            enabled_tools: Vec::new(),
            disabled_tools: Vec::new(),
            headers: HashMap::new(),
            env_headers: HashMap::new(),
            bearer_token_env_var: None,
            scopes: Vec::new(),
            oauth: None,
            oauth_resource: None,
            reviewed_plugin: None,
        },
    );
    save_config(path, &cfg)
}

pub fn remove_server_config(path: &Path, name: &str) -> Result<()> {
    let mut cfg = load_config(path)?;
    if cfg.servers.remove(name).is_none() {
        anyhow::bail!("MCP server '{name}' not found");
    }
    save_config(path, &cfg)
}

pub fn set_server_enabled(path: &Path, name: &str, enabled: bool) -> Result<()> {
    let mut cfg = load_config(path)?;
    let server = cfg
        .servers
        .get_mut(name)
        .ok_or_else(|| anyhow::anyhow!("MCP server '{name}' not found"))?;
    server.enabled = enabled;
    server.disabled = !enabled;
    save_config(path, &cfg)
}

#[cfg(test)]
pub fn manager_snapshot_from_config(
    path: &Path,

View on GitHub (pinned to 8880682c63)

Solutions

  1. List configured servers (config snapshot or jq '.servers | keys' on mcp.json) and use the exact key
  2. If the target is a dynamic/runtime server, remove it via the runtime API (remove_runtime_server_config), not the file config
  3. Check casing and whitespace in the name
Defensive patterns

Strategy: validation

Validate before calling

// Check existence before removing:
let cfg = load_config(&path)?;
anyhow::ensure!(cfg.servers.contains_key(name), "server '{name}' is not in {}", path.display());
remove_server_config(&path, name)?;

Type guard

fn server_exists(cfg: &McpConfig, name: &str) -> bool {
    cfg.servers.contains_key(name)
}

Prevention

When it happens

Trigger: Calling remove_server_config (the remove-server flow) with a name that is not a key in mcp.json - a typo, casing mismatch, or a server contributed dynamically at runtime or by a plugin rather than declared in the file.

Common situations: Trying to remove a plugin-contributed or dynamic runtime server through the file-based API; a name copied from another machine's config; the server was already removed.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/0c036b26ad634eec. Report an issue: GitHub.