{"record":{"id":"c59ffef4941479c3","repo":"Hmbown/CodeWhale","slug":"invalid-mcp-url","errorCode":null,"errorMessage":"Invalid MCP URL","messagePattern":"Invalid MCP URL","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp/external_import.rs","lineNumber":208,"sourceCode":"                    .is_some_and(|map| map.keys().all(|key| key == \"client_id\")),\n                \"Source contains unsupported OAuth fields\"\n            );\n        }\n        let server: McpServerConfig = serde_json::from_value(config)\n            .map_err(|_| anyhow::anyhow!(\"Invalid MCP entry; contents omitted\"))?;\n        anyhow::ensure!(\n            server.command.is_some() != server.url.is_some(),\n            \"MCP entry must have one target\"\n        );\n        if let Some(command) = &server.command {\n            anyhow::ensure!(\n                !command.trim().is_empty() && !command.chars().any(char::is_control),\n                \"Invalid MCP command\"\n            );\n        }\n        if let Some(url) = &server.url {\n            let parsed =\n                reqwest::Url::parse(url).map_err(|_| anyhow::anyhow!(\"Invalid MCP URL\"))?;\n            anyhow::ensure!(\n                matches!(parsed.scheme(), \"http\" | \"https\")\n                    && parsed.host_str().is_some()\n                    && parsed.username().is_empty()\n                    && parsed.password().is_none(),\n                \"Unsupported MCP URL\"\n            );\n        }\n        super::validate_mcp_transport(server.transport.as_deref())\n            .map_err(|_| anyhow::anyhow!(\"Unsupported MCP transport\"))?;\n        let hard_blocked = !server.is_enabled();\n        out.push(ImportCandidate {\n            summary: server_summary(&name, &server),\n            name,\n            source_kind: kind.clone(),\n            source_path: path.to_path_buf(),\n            content_hash: hash.clone(),\n            hard_blocked,","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/mcp/external_import.rs#L190-L226","documentation":"Remote entries supply a `url` string parsed with reqwest::Url::parse; if the string is not a parseable URL at all, this error is thrown before any scheme/host checks. The bad URL's contents are not echoed.","triggerScenarios":"`url` is missing the scheme (\"mcp.example.com/sse\"), contains spaces, or is otherwise malformed so Url::parse fails.","commonSituations":"Omitting `https://` when copying a server address; trailing quotes or whitespace pasted into the field; using a bare host:port for a local dev server.","solutions":["Add an explicit scheme: `https://mcp.example.com` or `http://localhost:3000`","URL-encode or remove stray spaces and characters from the value","Test the string in a URL parser before saving the config"],"exampleFix":"// before\n{\"mcpServers\":{\"api\":{\"url\":\"mcp.example.com:8080\"}}}\n// after\n{\"mcpServers\":{\"api\":{\"url\":\"http://mcp.example.com:8080\"}}}","handlingStrategy":"validation","validationCode":"try { new URL(u); } catch { throw new Error(`not a URL: ${u}`); }","typeGuard":"function isParseableUrl(u) { try { new URL(u); return true; } catch { return false; } }","tryCatchPattern":"catch, then run the string through a URL parser locally to see the real parse error","preventionTips":["Always include the scheme (http:// or https://) in url fields","Trim whitespace/quotes when pasting URLs","Prefer http://127.0.0.1:<port> for local dev servers"],"tags":["mcp","url","validation"],"backgroundTag":"invalid-url-format","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"}