{"record":{"id":"53f0c03955cd124c","repo":"Hmbown/CodeWhale","slug":"invalid-mcp-entry-contents-omitted","errorCode":null,"errorMessage":"Invalid MCP entry; contents omitted","messagePattern":"Invalid MCP entry; contents omitted","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp/external_import.rs","lineNumber":157,"sourceCode":"            .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        }\n        let fields = config\n            .as_object()\n            .ok_or_else(|| anyhow::anyhow!(\"Invalid MCP entry; contents omitted\"))?;\n        const ALLOWED: &[&str] = &[\n            \"command\",\n            \"args\",\n            \"env\",\n            \"cwd\",\n            \"url\",\n            \"allow_private_network\",\n            \"transport\",\n            \"connect_timeout\",\n            \"execute_timeout\",\n            \"read_timeout\",\n            \"disabled\",\n            \"enabled\",\n            \"required\",\n            \"enabled_tools\",\n            \"disabled_tools\",\n            \"headers\",\n            \"env_headers\",","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/mcp/external_import.rs#L139-L175","documentation":"Each imported server entry must be a JSON object. If a value in the server map (or an array element) is a string, number, array, or null, checked_source throws this error instead of attempting to import it. Contents are omitted from the message.","triggerScenarios":"discover / discover_from_json_file where any entry under mcpServers/servers (or any element of a top-level array) is not a JSON object — e.g. \"fs\": \"npx some-server\" shorthand, or null placeholders.","commonSituations":"Importing a config that uses string shorthand for commands; entries left as null after manual cleanup; a list of names rather than a map of objects; copy-paste dropped an object's braces.","solutions":["Expand shorthand entries into full objects with a command field: \"fs\": {\"command\": \"npx\", \"args\": [...]}","Remove or replace null/placeholder entries in the source map before importing","If the source uses string shorthands, convert them manually — the importer only accepts object entries"],"exampleFix":"// before (string shorthand entry)\n{ \"mcpServers\": { \"fs\": \"npx -y fs\" } }\n// after\n{ \"mcpServers\": { \"fs\": { \"command\": \"npx\", \"args\": [\"-y\", \"fs\"] } } }","handlingStrategy":"validation","validationCode":"fn entries_are_objects(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        .and_then(|v| v.get(\"mcpServers\").or_else(|| v.get(\"servers\")).cloned())\n        .and_then(|m| m.as_object().cloned())\n        .map(|m| m.values().all(|e| e.is_object()))\n        .unwrap_or(false)\n}","typeGuard":"fn as_server_object(v: &serde_json::Value) -> Option<&serde_json::Map<String, serde_json::Value>> {\n    v.as_object()\n}","tryCatchPattern":"match discover(&path) {\n    Err(e) if e.to_string().contains(\"Invalid MCP entry\") => {\n        eprintln!(\"a server entry is not a JSON object; expand shorthand strings to objects\");\n    }\n    r => r?,\n}","preventionTips":["Always write server entries as objects with a command (or url) field","Avoid null placeholders in server maps; remove unused entries entirely","Do not use string shorthand like \"fs\": \"npx -y fs\" in exported configs","Lint the source map: every value must be a JSON object before import"],"tags":["mcp","import","validation"],"backgroundTag":"type-mismatch","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T06:17:15.046Z"}