Hmbown/CodeWhale · error

Provide either a command or URL for MCP server '{name}'.

Error message

Provide either a command or URL for MCP server '{name}'.

What it means

add_server_config (backing the 'add MCP server' flow) requires exactly one launch style: a local command (stdio) or a URL (HTTP/SSE). Passing neither would create a server entry that can never start, so it fails fast with this message before the config file is read or written.

Source

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

            format!("Failed to create MCP config directory {}", parent.display())
        })?;
    }
    let template = mcp_template_json()?;
    write_atomic(path, template.as_bytes())
        .with_context(|| format!("Failed to write MCP config {}", path.display()))?;
    Ok(status)
}

pub fn add_server_config(
    path: &Path,
    name: String,
    command: Option<String>,
    url: Option<String>,
    args: Vec<String>,
    transport: Option<String>,
) -> Result<()> {
    if command.is_none() && url.is_none() {
        anyhow::bail!("Provide either a command or URL for MCP server '{name}'.");
    }
    validate_mcp_transport(transport.as_deref())?;
    let mut cfg = load_config(path)?;
    cfg.servers.insert(
        name,
        McpServerConfig {
            command,
            args,
            env: HashMap::new(),
            cwd: None,
            url,
            transport,
            connect_timeout: None,
            execute_timeout: None,
            read_timeout: None,
            disabled: false,
            enabled: true,
            required: false,

View on GitHub (pinned to 8880682c63)

Solutions

  1. Provide either a command (stdio server) or a URL (remote HTTP/SSE server) for the add operation
  2. For remote servers pass the URL plus the correct transport; for local servers pass command and args
  3. Fix the CLI/UI code path that collects the fields before calling add_server_config

Example fix

# before
$ codewhale mcp add my-server

# after
$ codewhale mcp add my-server --command npx --args -y --args some-server
Defensive patterns

Strategy: validation

Validate before calling

// Validate before calling add_server_config:
anyhow::ensure!(command.is_some() || url.is_some(), "supply --command or --url for '{name}'");
add_server_config(&path, name, command, url, args, transport)?;

Type guard

fn has_launch_method(command: &Option<String>, url: &Option<String>) -> bool {
    command.is_some() || url.is_some()
}

Prevention

When it happens

Trigger: Calling add_server_config with both command and url as None; a CLI add invoked without --command or --url; a form/UI submission that drops empty-string fields into None.

Common situations: Scripting the CLI and forgetting the launch flag; UI wiring that maps empty inputs to None; typos in flag names so values never reach the call.

Related errors


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