Hmbown/CodeWhale · error

MCP command cannot be empty

Error message

MCP command cannot be empty

What it means

parse_mcp_command validates user input before creating an MCP server entry. After trimming, an empty string carries no command or URL to parse, so it bails immediately with this error rather than producing a server with no executable.

Solutions

  1. Provide a real command or URL, e.g. `npx @modelcontextprotocol/server-filesystem /tmp` or `https://huggingface.co/mcp`
  2. Check the config field / variable feeding the input is not empty or undefined
  3. Guard the call site: skip creating the server entry when the input trims to empty

Example fix

// before
parse_mcp_command(config.mcp_command) // may be ""
// after
if !config.mcp_command.trim().is_empty() {
    parse_mcp_command(config.mcp_command)?;
}
Defensive patterns

Strategy: validation

Validate before calling

if input.trim().is_empty() { return Err("provide an MCP command or URL"); }

Prevention

When it happens

Trigger: Calling parse_mcp_command with "", whitespace-only input (" \t\n"), or an empty/undefined string propagated from config or a tool call argument.

Common situations: An MCP server entry in configuration left blank; a UI/tool call passing an unset variable; trimming reduced a whitespace-padded value to nothing.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at crates/tui/src/tools/runtime_mcp.rs:34

    ApprovalRequirement, ToolCapability, ToolContext, ToolError, ToolResult, ToolSpec,
};

// === Parsing Functions ===

#[derive(Debug, Clone)]
pub struct ParsedMcpServer {
    pub name: String,
    pub config: McpServerConfig,
}

/// Parse a command string or URL into an MCP server configuration.
///
/// - Local command: `npx @modelcontextprotocol/server-filesystem /tmp`
/// - Remote URL: `https://huggingface.co/mcp`
pub fn parse_mcp_command(input: &str) -> Result<ParsedMcpServer> {
    let input = input.trim();
    if input.is_empty() {
        anyhow::bail!("MCP command cannot be empty");
    }

    if input.starts_with("http://") || input.starts_with("https://") {
        let name = extract_name_from_url(input)?;
        return Ok(ParsedMcpServer {
            name,
            config: McpServerConfig {
                command: None,
                args: Vec::new(),
                env: HashMap::new(),
                cwd: None,
                url: Some(input.to_string()),
                transport: None,
                connect_timeout: None,
                execute_timeout: None,
                read_timeout: None,
                disabled: false,
                enabled: true,

View on GitHub (pinned to 73e0f67d83)