{"record":{"id":"20015a790d9d5f1e","repo":"Hmbown/CodeWhale","slug":"invalid-mcp-server-definition-list-in-key-mcp-ser","errorCode":null,"errorMessage":"invalid MCP server definition list in key {MCP_SERVER_DEFINITIONS_KEY}; contents were omitted","messagePattern":"invalid MCP server definition list in key (.+?); contents were omitted","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/lib.rs","lineNumber":5188,"sourceCode":"        Err(err) => {\n            eprintln!(\n                \"warning: failed to parse persisted MCP server definitions ({MCP_SERVER_DEFINITIONS_KEY}): {err}\"\n            );\n            Vec::new()\n        }\n    }\n}\n\nfn parse_mcp_server_definitions(raw: &str) -> Result<Vec<McpServerDefinition>> {\n    if let Ok(parsed) = serde_json::from_str::<Vec<McpServerDefinition>>(raw) {\n        return Ok(parsed);\n    }\n\n    let unwrapped: String = serde_json::from_str(raw).map_err(|_| {\n        anyhow!(\"invalid JSON payload at key {MCP_SERVER_DEFINITIONS_KEY}; contents were omitted\")\n    })?;\n    serde_json::from_str::<Vec<McpServerDefinition>>(&unwrapped).map_err(|_| {\n        anyhow!(\n            \"invalid MCP server definition list in key {MCP_SERVER_DEFINITIONS_KEY}; contents were omitted\"\n        )\n    })\n}\n\nfn persist_mcp_server_definitions(\n    store: &mut ConfigStore,\n    definitions: &[McpServerDefinition],\n) -> Result<()> {\n    let encoded =\n        serde_json::to_string(definitions).context(\"failed to encode MCP server definitions\")?;\n    store\n        .config\n        .set_value(MCP_SERVER_DEFINITIONS_KEY, &encoded)?;\n    store.save()\n}\n\n/// Delegate a long-running server command (`serve --http`/`--mobile`,","sourceCodeStart":5170,"sourceCodeEnd":5206,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/cli/src/lib.rs#L5170-L5206","documentation":"After unwrapping the raw value at MCP_SERVER_DEFINITIONS_KEY into a JSON string, parse_mcp_server_definitions still fails to deserialize it into Vec<McpServerDefinition>. The raw value was valid JSON (a string) but its contents are not an array of valid server definitions. Contents are omitted from the message to avoid leaking embedded secrets.","triggerScenarios":"The key holds a JSON string whose inner text is not a JSON array of McpServerDefinition — e.g. an object instead of an array, missing required fields (name/command/args), or wrong field types like a numeric port where a string is expected.","commonSituations":"Schema drift after a CLI upgrade changed McpServerDefinition fields; hand-written definitions missing a required field; copying an example that no longer matches the current struct.","solutions":["Check the McpServerDefinition struct in the CLI source for required fields and types and fix the JSON to match.","Ensure the inner payload is an array: wrap a single definition object in `[...]`.","Run `jq` against the unwrapped string to spot the schema mismatch.","Upgrade or downgrade the CLI to the version matching your config schema."],"exampleFix":"// before\n\"mcpServers\": {\"name\": \"fs\"}\n// after\n\"mcpServers\": \"[{\\\"name\\\":\\\"fs\\\",\\\"command\\\":\\\"npx\\\",\\\"args\\\":[\\\"-y\\\",\\\"@modelcontextprotocol/server-fs\\\"]}]\"","handlingStrategy":"validation","validationCode":"// check shape against the expected schema\nconst defs = JSON.parse(unwrapped);\nif (!Array.isArray(defs) || !defs.every(d => typeof d.name === 'string' && typeof d.command === 'string')) {\n  throw new Error('each MCP server definition needs string name and command');\n}","typeGuard":"function isMcpServerDefinition(d) {\n  return typeof d === 'object' && d !== null && typeof d.name === 'string' && typeof d.command === 'string';\n}","tryCatchPattern":"try {\n  let defs = JSON.parse(unwrapped);\n  if (!Array.isArray(defs)) throw new Error('expected an array of definitions');\n} catch (e) {\n  console.error(`Invalid MCP definition list: ${e.message}`);\n}","preventionTips":["Validate definitions against the current McpServerDefinition schema after each CLI upgrade.","Wrap single definitions in a JSON array.","Round-trip your config through the CLI's own set command to normalize it."],"tags":["json","mcp","schema","config"],"backgroundTag":"schema-validation-failed","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"}