Hmbown/CodeWhale · error
MCP command cannot be empty
Error message
MCP command cannot be empty
What it means
parse_mcp_command rejects input that is empty after trimming. The parser accepts either a local command line or an http(s) URL for an MCP server; before any parsing it requires non-whitespace input, so an empty string fails here rather than producing a server with no command and no URL.
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 0c42157ee5)
Solutions
- Treat blank input as 'no server configured' at the call site: check trimmed emptiness before parsing.
- Require the field in your config schema validation so empty commands fail at load time with a path to the offending key.
- Pass either a full command line (e.g. 'npx @modelcontextprotocol/server-filesystem /tmp') or an http(s) URL.
Example fix
// before
let parsed = parse_mcp_command(&cfg.mcp_command)?; // panics path on ""
// after
let cmd = cfg.mcp_command.trim();
if cmd.is_empty() {
return Ok(None); // no MCP server configured
}
let parsed = parse_mcp_command(cmd)?; Defensive patterns
Strategy: validation
Validate before calling
fn parse_optional_mcp_command(input: &str) -> Result<Option<ParsedMcpServer>> {
let input = input.trim();
if input.is_empty() {
return Ok(None);
}
parse_mcp_command(input).map(Some)
} Prevention
- Make the MCP command field required (non-blank) in your config schema validation.
- Treat blank as 'unset' at the boundary rather than forwarding it to the parser.
- Accept that parse_mcp_command takes a command line or an http(s) URL, nothing else.
When it happens
Trigger: Calling parse_mcp_command("") or with a whitespace-only string; forwarding an unvalidated config field, CLI argument, or chat input that can be blank.
Common situations: Optional MCP command fields in config or prompts where empty means 'unset'; form inputs submitted blank; template-substituted command strings that resolve to nothing.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- unknown field '{field_key}' for built-in provider '{provider
- unknown field '{field_key}' for custom provider '{provider_i
- The Codewhale service returned an account without an ID
- invalid value '{provider}' for '--provider <PROVIDER>': expe
- --worktree-repo and --branch must be provided together
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/41d8cde973be01da.
Report an issue: GitHub.