Hmbown/CodeWhale · error
MCP import preview failed
Error message
MCP import preview failed
What it means
Generic fallback error raised when the MCP import preview task completes but its inner operation returns Err — the actual preview failure detail is discarded (`Err(_)`) and replaced with this fixed message. The preview renders what an import would change (servers, config diff) before the user approves it.
Solutions
- Check the source MCP config file exists, is readable, and parses as valid JSON/YAML.
- Validate the file's schema against the expected MCP config format (server entries, required fields).
- Retry the preview — the underlying error is swallowed, so verify the input rather than guessing from this message.
- If the format is from a different tool/version, convert it to the native MCP config shape first.
Example fix
// before
Err(_) => Err(anyhow::anyhow!("MCP import preview failed")),
// after: keep the cause
Err(err) => Err(anyhow::anyhow!("MCP import preview failed: {err:#}")), Defensive patterns
Strategy: validation
Validate before calling
// before requesting a preview, ensure the source parses
let text = std::fs::read_to_string(&import_path)?;
let parsed: serde_json::Value = serde_json::from_str(&text)
.or_else(|_| serde_yaml::from_str(&text))?;
if parsed.get("servers").is_none() {
eprintln!("import file has no 'servers' section");
} Try / catch
match preview_import(&import_path).await {
Ok(text) => show_preview(text),
Err(e) => show_error(format!("MCP import preview failed: {e:#}")),
} Prevention
- Validate the import file (exists, readable, valid JSON/YAML, `servers` present) before previewing.
- Confirm the file matches the expected MCP config schema/version for this build.
- Avoid hand-editing exported configs before import; import the original export.
- Surface the inner error — the fixed message hides the real cause.
When it happens
Trigger: Requesting an MCP import preview (handle_mcp_ui_action ImportPreview path) where the awaited preview returns Err — e.g. unreadable or malformed source config, invalid JSON/YAML in the imported file, or an IO error reading the file.
Common situations: Importing an MCP config exported from another tool with a schema the parser rejects; pointing the import at a nonexistent path; permission errors reading the source file; newer/older config format version mismatch.
Related errors
- A managed, project or plugin connector already uses this…
- bundle carries [global] entries; importing them into a…
- {error}
- Failed to parse MCP config
- Failed to parse MCP config
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/6b8f0891cd8d0363.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tui/ui/handlers.rs:806
}
crate::tui::app::McpUiAction::ImportList => {
let path = path.clone();
let workspace = app.workspace.clone();
let plugins = app.plugin_registry.clone();
#[cfg(test)]
let ticket = crate::test_support::env_scope_ticket();
match tokio::task::spawn_blocking(move || {
#[cfg(test)]
let _membership = crate::test_support::join_env_scope(ticket);
mcp_external_import_status_text(&workspace, &path, plugins.as_ref())
})
.await
{
Ok(text) => {
message = Some(text);
Ok(())
}
Err(_) => Err(anyhow::anyhow!("MCP import preview failed")),
}
}
crate::tui::app::McpUiAction::ImportApprove { name }
| crate::tui::app::McpUiAction::ImportDecline { name } => {
let approve = approve_import;
let path = path.clone();
let workspace = app.workspace.clone();
let plugins = app.plugin_registry.clone();
#[cfg(test)]
let ticket = crate::test_support::env_scope_ticket();
match tokio::task::spawn_blocking(move || {
#[cfg(test)]
let _membership = crate::test_support::join_env_scope(ticket);
mcp_import_apply(&workspace, &path, plugins.as_ref(), &name, approve)
})
.await
{
Ok(Ok(msg)) => {View on GitHub (pinned to 73e0f67d83)