Hmbown/CodeWhale · error · anyhow::Error

MCP server '{name}' not found

Error message

MCP server '{name}' not found

What it means

The MCP OAuth login flow reloads the MCP config (workspace + plugins) and requires the named server in cfg.servers; a miss bails 'MCP server \u2018{name}\u2019 not found'. The TUI shows the error instead of opening the browser OAuth flow. Note the config is loaded fresh here, so it can disagree with an older in-app server list.

Source

Thrown at crates/tui/src/tui/ui/handlers.rs:485

            mcp::set_server_enabled(&path, &name, false)
                .map(|()| message = Some(format!("Disabled MCP server '{name}'")))
        }
        crate::tui::app::McpUiAction::Remove { name } => {
            changed = true;
            mcp::remove_server_config(&path, &name)
                .map(|()| message = Some(format!("Removed MCP server '{name}'")))
        }
        crate::tui::app::McpUiAction::Login { name, scopes } => {
            let result = async {
                let cfg = mcp::load_config_with_workspace_and_plugins(
                    &path,
                    &app.workspace,
                    app.plugin_registry.as_ref(),
                )?;
                let server = cfg
                    .servers
                    .get(&name)
                    .ok_or_else(|| anyhow::anyhow!("MCP server '{name}' not found"))?;
                let explicit_scopes = (!scopes.is_empty()).then_some(scopes);
                mcp::oauth::perform_oauth_login_for_server(
                    &name,
                    server,
                    explicit_scopes,
                    config.mcp_oauth_callback_port,
                    config.mcp_oauth_callback_url.as_deref(),
                )
                .await
            }
            .await;
            result.map(|()| {
                changed = true;
                message = Some(format!(
                    "Stored OAuth credentials for MCP server '{name}'. Run /mcp reload to reconnect it."
                ));
            })
        }

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Re-read the MCP config and use the exact server key (map keys are case-sensitive)
  2. Run /mcp reload or restart the TUI so the list matches the config
  3. Check that the plugin providing the server is installed and enabled
Defensive patterns

Strategy: validation

Validate before calling

// Rust - confirm the server exists in the freshly loaded config before login
let cfg = mcp::load_config_with_workspace_and_plugins(&path, &app.workspace, app.plugin_registry.as_ref())?;
if !cfg.servers.contains_key(&name) {
    return Err(anyhow::anyhow!("MCP server '{name}' not found"));
}
// proceed with perform_oauth_login_for_server(...)

Try / catch

match cfg.servers.get(&name) {
    Some(server) => mcp::oauth::perform_oauth_login_for_server(&name, server, scopes, port, url).await,
    None => show_hint("run /mcp reload; server names are case-sensitive config keys"),
}

Prevention

When it happens

Trigger: McpUiAction::Login for a name that is absent from the freshly loaded config: typo or case mismatch, server removed from the config file after the UI listed it, the plugin that supplied it disabled, or workspace config not present.

Common situations: Editing MCP config while the TUI is open; disabling a plugin that owned the server; stale in-app server list; wrong workspace selected.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/730ccd573c2a9823. Report an issue: GitHub.