{"record":{"id":"700573ec9191dae3","repo":"Hmbown/CodeWhale","slug":"one-or-more-mcp-servers-failed-validation","errorCode":null,"errorMessage":"one or more MCP servers failed validation","messagePattern":"one or more MCP servers failed validation","errorType":"error_code","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":10262,"sourceCode":"            println!(\"Disabled MCP server '{name}'\");\n            Ok(())\n        }\n        McpCommand::Validate => {\n            let mut pool = McpPool::from_config_path_with_workspace_and_plugins(\n                &config_path,\n                workspace,\n                std::sync::Arc::new(plugins.clone()),\n            )?;\n            let errors = pool.connect_all().await;\n            if errors.is_empty() {\n                println!(\"MCP config is valid. All enabled servers connected.\");\n                return Ok(());\n            }\n            eprintln!(\"MCP validation failed:\");\n            for (name, err) in errors {\n                eprintln!(\"  - {name}: {err:#}\");\n            }\n            bail!(\"one or more MCP servers failed validation\");\n        }\n        McpCommand::AddSelf { name, workspace } => {\n            let exe_path = std::env::current_exe()\n                .map_err(|e| anyhow!(\"Cannot resolve current binary path: {e}\"))?;\n            let exe_str = exe_path.to_string_lossy().to_string();\n\n            let mut args = Vec::with_capacity(if workspace.is_some() { 4 } else { 2 });\n            if let Some(ref ws) = workspace {\n                args.push(\"--workspace\".to_string());\n                args.push(ws.clone());\n            }\n            args.push(\"serve\".to_string());\n            args.push(\"--mcp\".to_string());\n\n            crate::mcp::mutate_config(&config_path, None, |cfg| {\n                if cfg.servers.contains_key(&name) {\n                    bail!(\n                        \"MCP server '{name}' already exists in {}. Use `codewhale mcp remove {name}` first, or choose a different --name.\",","sourceCodeStart":10244,"sourceCodeEnd":10280,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/lib.rs#L10244-L10280","documentation":"The `codewhale mcp validate` subcommand checks all configured MCP servers and prints each named failure to stderr; when any validation error exists it aborts with this anyhow bail instead of continuing. It is a deliberate fail-loud gate: the config is considered unusable until every server definition passes validation.","triggerScenarios":"Running `codewhale mcp validate` (or a flow that invokes it) when `errors` collected from validating `cfg.servers` is non-empty — e.g. a server entry has a bad command, missing required fields, or an unresolvable workspace.","commonSituations":"Hand-editing mcp config JSON with a typo, adding a server via `codewhale mcp add` with an invalid command path, or copying config from another machine where paths/binary names don't exist.","solutions":["Read the per-server lines printed above the bail (`- {name}: {err:#}`) to see exactly which server and why.","Fix or remove the offending server entry with `codewhale mcp remove <name>` and re-add it correctly.","Re-run `codewhale mcp validate` until it reports no failures before starting the TUI."],"exampleFix":"// before (config.json)\n{\"servers\": {\"fs\": {\"command\": \"/usr/local/bin/mcp-fs\"}}}\n// after (binary actually exists)\n{\"servers\": {\"fs\": {\"command\": \"/home/user/.local/bin/mcp-fs\"}}}","handlingStrategy":"validation","validationCode":"let ok = std::process::Command::new(\"codewhale\").args([\"mcp\", \"validate\"]).status()?.success();\nif !ok { eprintln!(\"fix MCP config before proceeding\"); }\n","typeGuard":null,"tryCatchPattern":"match codewhale_mcp::validate_config(&cfg) {\n    Ok(()) => start_tui(),\n    Err(e) => eprintln!(\"MCP validation failed: {e:#}\"),\n}\n","preventionTips":["Run `codewhale mcp validate` as a CI/setup step after every config edit.","Add servers only via `codewhale mcp add`, not by hand-editing JSON.","Keep server commands as absolute paths that exist on the target machine."],"tags":["mcp","config","cli","validation"],"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"}