{"record":{"id":"9b2bf02b0a70081e","repo":"Hmbown/CodeWhale","slug":"mcp-entry-must-have-one-target","errorCode":null,"errorMessage":"MCP entry must have one target","messagePattern":"MCP entry must have one target","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp/external_import.rs","lineNumber":196,"sourceCode":"            \"scopes\",\n            \"oauth\",\n            \"oauth_resource\",\n        ];\n        anyhow::ensure!(\n            fields.keys().all(|key| ALLOWED.contains(&key.as_str())),\n            \"Source contains unsupported MCP fields; review it at its source\"\n        );\n        if let Some(oauth) = fields.get(\"oauth\").filter(|v| !v.is_null()) {\n            anyhow::ensure!(\n                oauth\n                    .as_object()\n                    .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\"","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/mcp/external_import.rs#L178-L214","documentation":"An imported MCP server must specify exactly one target: either a local `command` or a remote `url`, never both and never neither. The invariant `command.is_some() != url.is_some()` is enforced with XOR; violating it rejects the entry.","triggerScenarios":"An entry has both `command` and `url` set, or an entry has neither (only optional fields like transport, env, or headers).","commonSituations":"Merging two config files by hand so both keys survive; converting a remote entry to local by adding `command` without removing `url`; an empty stub entry with only metadata fields.","solutions":["Delete either the `command` or the `url` key so exactly one target remains","If the server is remote, remove command/args; if local, remove url/transport","Split genuinely dual-mode servers into two distinct named entries"],"exampleFix":"// before\n{\"mcpServers\":{\"api\":{\"command\":\"npx\",\"url\":\"https://mcp.example.com\"}}}\n// after\n{\"mcpServers\":{\"api\":{\"url\":\"https://mcp.example.com\"}}}","handlingStrategy":"validation","validationCode":"function oneTargetOk(e) { return (\"command\" in e) !== (\"url\" in e); }","typeGuard":null,"tryCatchPattern":"catch, then check whether the offending entry has 0 or 2 targets and fix accordingly","preventionTips":["Never add `command` to an existing url entry (or vice versa) without deleting the other","Diff config merges so dual-target entries can't survive","One entry = one target; model dual-mode servers as two entries"],"tags":["mcp","config-validation","xor"],"backgroundTag":"mutually-exclusive-options","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"}