{"record":{"id":"2afc07c96635e7ed","repo":"Hmbown/CodeWhale","slug":"source-has-no-supported-mcp-server-map","errorCode":null,"errorMessage":"Source has no supported MCP server map","messagePattern":"Source has no supported MCP server map","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp/external_import.rs","lineNumber":136,"sourceCode":"    out\n}\n\nfn discover_from_json_file(path: &Path, kind: ExternalMcpSourceKind) -> Vec<ImportCandidate> {\n    checked_source(path, kind).unwrap_or_default()\n}\n\nfn checked_source(\n    path: &Path,\n    kind: ExternalMcpSourceKind,\n) -> anyhow::Result<Vec<ImportCandidate>> {\n    super::validate_mcp_config_path(path)?;\n    let Some(raw) = super::read_mcp_config_file(path)? else {\n        return Ok(Vec::new());\n    };\n    let hash = hex_sha256(raw.as_bytes());\n    let value: Value = serde_json::from_str(&raw)\n        .map_err(|_| anyhow::anyhow!(\"Source is not valid JSON; contents omitted\"))?;\n    anyhow::ensure!(\n        value\n            .get(\"mcpServers\")\n            .or_else(|| value.get(\"servers\"))\n            .is_some_and(Value::is_object)\n            || value.is_array(),\n        \"Source has no supported MCP server map\"\n    );\n    let mut out = Vec::new();\n    for (name, mut config) in extract_servers_map(&value) {\n        anyhow::ensure!(\n            super::mcp_name_is_command_safe(&name) && name.len() <= 128,\n            \"Source contains an unsupported server name\"\n        );\n        if value.is_array()\n            && let Some(map) = config.as_object_mut()\n        {\n            map.remove(\"name\");\n        }","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/mcp/external_import.rs#L118-L154","documentation":"After parsing, checked_source requires the JSON to contain an object under \"mcpServers\" or \"servers\", or to be a top-level array of server entries. Valid JSON lacking any of these shapes is rejected — there is no server map to import.","triggerScenarios":"discover / discover_from_json_file on a file that is valid JSON but has no mcpServers/servers object and is not an array — e.g. {\"foo\": 1}, a settings file with a different schema, or a JSONL/other format.","commonSituations":"Pointing the importer at the wrong tool's config that uses a different root key; importing a partial fragment like a single server object {\"command\": ...} without the wrapping map; Claude/Codex-style configs whose root key was renamed.","solutions":["Wrap server entries under a \"mcpServers\" (or \"servers\") object in the source file, or use a top-level array of entries","Verify you selected the right source file — one that actually exports MCP servers under a supported key","Rename the root key in the source to mcpServers if the exporting tool used a custom key"],"exampleFix":"// before (valid JSON, no server map)\n{ \"myTools\": { \"fs\": { \"command\": \"npx\" } } }\n// after\n{ \"mcpServers\": { \"fs\": { \"command\": \"npx\" } } }","handlingStrategy":"validation","validationCode":"fn has_supported_server_map(path: &std::path::Path) -> bool {\n    std::fs::read_to_string(path).ok()\n        .and_then(|s| serde_json::from_str::<serde_json::Value>(&s).ok())\n        .map(|v| v.get(\"mcpServers\").or_else(|| v.get(\"servers\"))\n            .is_some_and(|m| m.is_object()) || v.is_array())\n        .unwrap_or(false)\n}","typeGuard":"fn extract_server_map<'a>(v: &'a serde_json::Value) -> Option<&'a serde_json::Map<String, serde_json::Value>> {\n    v.get(\"mcpServers\").or_else(|| v.get(\"servers\"))?.as_object()\n}","tryCatchPattern":"match discover(&path) {\n    Err(e) if e.to_string().contains(\"no supported MCP server map\") => {\n        eprintln!(\"source has no mcpServers/servers object and is not an array; fix the root shape\");\n    }\n    r => r?,\n}","preventionTips":["Confirm the exporting tool writes under mcpServers or servers before importing","Wrap bare server objects in {\"mcpServers\": {...}} for import","Check the root key name when a tool update changes its export format","Prefer top-level arrays or mcpServers/servers objects — no other roots are accepted"],"tags":["mcp","import","schema"],"backgroundTag":"unexpected-response-shape","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"}