{"record":{"id":"41d8cde973be01da","repo":"Hmbown/CodeWhale","slug":"mcp-command-cannot-be-empty","errorCode":null,"errorMessage":"MCP command cannot be empty","messagePattern":"MCP command cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/runtime_mcp.rs","lineNumber":34,"sourceCode":"    ApprovalRequirement, ToolCapability, ToolContext, ToolError, ToolResult, ToolSpec,\n};\n\n// === Parsing Functions ===\n\n#[derive(Debug, Clone)]\npub struct ParsedMcpServer {\n    pub name: String,\n    pub config: McpServerConfig,\n}\n\n/// Parse a command string or URL into an MCP server configuration.\n///\n/// - Local command: `npx @modelcontextprotocol/server-filesystem /tmp`\n/// - Remote URL: `https://huggingface.co/mcp`\npub fn parse_mcp_command(input: &str) -> Result<ParsedMcpServer> {\n    let input = input.trim();\n    if input.is_empty() {\n        anyhow::bail!(\"MCP command cannot be empty\");\n    }\n\n    if input.starts_with(\"http://\") || input.starts_with(\"https://\") {\n        let name = extract_name_from_url(input)?;\n        return Ok(ParsedMcpServer {\n            name,\n            config: McpServerConfig {\n                command: None,\n                args: Vec::new(),\n                env: HashMap::new(),\n                cwd: None,\n                url: Some(input.to_string()),\n                transport: None,\n                connect_timeout: None,\n                execute_timeout: None,\n                read_timeout: None,\n                disabled: false,\n                enabled: true,","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tools/runtime_mcp.rs#L16-L52","documentation":"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.","triggerScenarios":"Calling parse_mcp_command(\"\") or with a whitespace-only string; forwarding an unvalidated config field, CLI argument, or chat input that can be blank.","commonSituations":"Optional MCP command fields in config or prompts where empty means 'unset'; form inputs submitted blank; template-substituted command strings that resolve to nothing.","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."],"exampleFix":"// before\nlet parsed = parse_mcp_command(&cfg.mcp_command)?; // panics path on \"\"\n\n// after\nlet cmd = cfg.mcp_command.trim();\nif cmd.is_empty() {\n    return Ok(None); // no MCP server configured\n}\nlet parsed = parse_mcp_command(cmd)?;","handlingStrategy":"validation","validationCode":"fn parse_optional_mcp_command(input: &str) -> Result<Option<ParsedMcpServer>> {\n    let input = input.trim();\n    if input.is_empty() {\n        return Ok(None);\n    }\n    parse_mcp_command(input).map(Some)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["mcp","validation","cli","rust"],"backgroundTag":"missing-required-argument","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}