Hmbown/CodeWhale · error
MCP config path cannot be empty
Error message
MCP config path cannot be empty
What it means
validate_mcp_config_path rejects MCP config paths whose OsStr is empty before any filesystem access. It exists so downstream code never attempts directory creation or writes against an empty path; the companion check in the same validator rejects '..' components.
Source
Thrown at crates/tui/src/mcp.rs:48
mod wire;
use self::http::{HttpTransport, McpHttpAuth};
use self::sse::SseTransport;
use self::stdio::StdioTransport;
#[cfg(all(test, unix))]
use self::stdio::{STDIO_SHUTDOWN_GRACE, StderrTail};
use self::wire::{is_mcp_stale_session_body, is_mcp_stale_session_error};
use crate::network_policy::{Decision, NetworkPolicyDecider, host_from_url};
use crate::utils::write_atomic;
// === Error diagnostics helpers (#71) ===
/// Bytes of a non-2xx response body to surface in connection errors.
const ERROR_BODY_PREVIEW_BYTES: usize = 200;
fn validate_mcp_config_path(path: &Path) -> Result<()> {
if path.as_os_str().is_empty() {
anyhow::bail!("MCP config path cannot be empty");
}
if path
.components()
.any(|component| matches!(component, Component::ParentDir))
{
anyhow::bail!("MCP config path cannot contain '..' components");
}
Ok(())
}
/// Expand `${NAME}` placeholders in an MCP config value from the process
/// environment. This lets secrets (API keys, bearer tokens, …) be supplied
/// through environment variables instead of being written in cleartext into
/// the MCP config file on disk.
///
/// On a missing or malformed placeholder the error names only the offending
/// variable, never the surrounding value, so a secret-bearing string is never
/// echoed into logs or error output.View on GitHub (pinned to 8880682c63)
Solutions
- Supply a real, preferably absolute, path for the MCP config file
- If the path comes from an environment variable, ensure it is set and non-empty before invoking the command
- Fall back to the documented default config location instead of forwarding an empty override
Example fix
# before MCP_CONFIG= codewhale mcp list # error: MCP config path cannot be empty # after MCP_CONFIG="$HOME/.config/codewhale/mcp.json" codewhale mcp list
Defensive patterns
Strategy: validation
Validate before calling
// Resolve an override that may be unset or empty into a concrete path
fn resolve_config_path(raw: Option<&str>) -> std::path::PathBuf {
raw.map(str::trim)
.filter(|s| !s.is_empty())
.map(std::path::PathBuf::from)
.unwrap_or_else(default_mcp_config_path)
} Prevention
- Validate CLI and env path overrides for non-empty before use
- Always have a documented default config path
- Fail fast in wrappers when required variables expand to empty
When it happens
Trigger: Passing an empty config path: an empty --mcp-config style flag value, or an environment variable or config field that expands to the empty string when the MCP config is loaded or saved.
Common situations: Unset environment variables used for the config path, empty strings forwarded by wrapper scripts, misconfigured CI variables, programmatic callers passing user input unchecked.
Related errors
- MCP config path cannot contain '..' components
- invalid environment placeholder in MCP config value
- Unsupported MCP transport '{transport}'. Supported values: s
- MCP server '{name}' config must have either 'command' or 'ur
- Provide either a command or URL for MCP server '{name}'.
AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16).
Data as JSON: /api/errors/c48ccdd89f94e732.
Report an issue: GitHub.