{"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/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/runtime_mcp.rs#L16-L52","documentation":"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.","triggerScenarios":"Calling parse_mcp_command with \"\", whitespace-only input (\"   \\t\\n\"), or an empty/undefined string propagated from config or a tool call argument.","commonSituations":"An MCP server entry in configuration left blank; a UI/tool call passing an unset variable; trimming reduced a whitespace-padded value to nothing.","solutions":["Provide a real command or URL, e.g. `npx @modelcontextprotocol/server-filesystem /tmp` or `https://huggingface.co/mcp`","Check the config field / variable feeding the input is not empty or undefined","Guard the call site: skip creating the server entry when the input trims to empty"],"exampleFix":"// before\nparse_mcp_command(config.mcp_command) // may be \"\"\n// after\nif !config.mcp_command.trim().is_empty() {\n    parse_mcp_command(config.mcp_command)?;\n}","handlingStrategy":"validation","validationCode":"if input.trim().is_empty() { return Err(\"provide an MCP command or URL\"); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave MCP server command fields blank in config","Trim and check emptiness at the config-load boundary","Skip creating server entries whose command is unset"],"tags":["mcp","input-validation","empty-input"],"backgroundTag":"empty-required-field","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}