Hmbown/CodeWhale · error · anyhow::Error

Choose exactly one server mode: --mcp…

Error message

Choose exactly one server mode: --mcp, --http/--mobile/--web, or --acp

What it means

Exactly one server mode must be selected: MCP, the HTTP family (--http/--mobile/--web), or ACP. The validator counts the selected modes and bails when the count is not exactly 1 — covering zero modes selected or multiple selected.

Solutions

  1. Pass exactly one of: --mcp, --http (or --mobile/--web), --acp
  2. If no mode was intended, check the script — the command cannot start a server without one mode
  3. Remove extra mode flags until only one remains

Example fix

// before
codewhale serve --mcp --acp
// after
codewhale serve --mcp
Defensive patterns

Strategy: validation

Validate before calling

let modes = [mcp, http || mobile || web, acp].iter().filter(|b| **b).count();
if modes != 1 { eprintln!("select exactly one server mode"); std::process::exit(2); }

Try / catch

match result { Err(e) if e.to_string().contains("Choose exactly one server mode") => { eprintln!("{}", e); std::process::exit(2); }, other => other? }

Prevention

When it happens

Trigger: Running a serve/server subcommand with no mode flag at all (count 0), or with two or more of --mcp, --http/--mobile/--web, --acp (count >= 2).

Common situations: Forgetting to pass any server-mode flag in a script; adding --mcp on top of --http; copy-paste errors combining flags from different examples.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/0d35836cf460cef8. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/lib.rs:1412

    mcp: bool,
    http: bool,
    mobile: bool,
    web: bool,
    acp: bool,
) -> Result<bool> {
    if http && mobile {
        bail!("--http and --mobile are mutually exclusive; choose one");
    }
    if web && (http || mobile) {
        bail!("--web is mutually exclusive with --http and --mobile");
    }
    let http_selected = http || mobile || web;
    let selected_modes = [mcp, http_selected, acp]
        .into_iter()
        .filter(|selected| *selected)
        .count();
    if selected_modes != 1 {
        bail!("Choose exactly one server mode: --mcp, --http/--mobile/--web, or --acp");
    }
    Ok(http_selected)
}

#[derive(Subcommand, Debug, Clone)]
enum McpCommand {
    /// List configured MCP servers
    List,
    /// Create a template MCP config at the configured path
    Init {
        /// Overwrite an existing MCP config file
        #[arg(long, default_value_t = false)]
        force: bool,
    },
    /// Connect to MCP servers and report status
    Connect {
        /// Optional server name to connect to
        #[arg(value_name = "SERVER")]

View on GitHub (pinned to 73e0f67d83)