Hmbown/CodeWhale · warning
MCP HTTP destination requires network approval
Error message
MCP HTTP destination requires network approval
What it means
Network policy evaluation can return Decision::Prompt, meaning the destination requires interactive user approval before connecting. In this synchronous validation path no prompt can be shown, so validate_network_policy throws this error to indicate approval must be obtained beforehand.
Solutions
- Pre-approve the host in the network policy (add to allowlist) so evaluate returns Allow
- Trigger the approval flow for this host in the UI, then retry the connection
- Use a decider implementation that auto-allows known-good hosts for automated environments
Example fix
// before
// policy.evaluate("new-host.example.com", "mcp") == Prompt -> error
// after
policy.approve_host("new-host.example.com", "mcp"); // user consented earlier
// evaluate now returns Allow and the request proceeds Defensive patterns
Strategy: fallback
Validate before calling
let host = Url::parse(endpoint)?.host_str().unwrap_or_default().to_string();
if let Decision::Prompt = policy.evaluate(&host, "mcp") {
// trigger interactive approval flow before constructing the client
approval_ui.request_host_approval(&host, "mcp").await?;
} Try / catch
match connect(...).await {
Err(e) if e.to_string().contains("requires network approval") => {
// surface approval prompt to user, then retry after consent
approval_ui.request_host_approval(&host, "mcp").await?;
connect(...).await?
}
other => other?,
} Prevention
- Pre-approve known MCP hosts so evaluate() never returns Prompt in automation
- Run headless workloads with an explicit allowlist policy, not a prompt policy
- Catch Decision::Prompt before constructing the HTTP client
When it happens
Trigger: validate_network_policy gets Decision::Prompt from policy.evaluate(host, "mcp") — the host is neither allow-listed nor denied, so policy demands user consent, from either new (initial URL) or client_for_target (redirect target).
Common situations: First-time connection to a new MCP host under an approval-based policy; a redirect to a host the user has not yet approved; running headless/automated where the approval UI never runs.
Understand the failure class
Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.
Related errors
- MCP HTTP destination blocked by network policy
- MCP server ' ' connection to ' ' requires approval; re-run…
- MCP HTTP discovered URL must not contain credentials
- MCP HTTP redirect limit exceeded
- MCP HTTP redirect must not contain credentials
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/e8654cf8f06948ec.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/mcp/http_client.rs:227
.context("building guarded MCP HTTP client")?;
let mut clients = self
.clients
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner);
if !proxied && clients.len() < 32 {
clients.insert(key, client.clone());
}
Ok(client)
}
}
fn validate_network_policy(url: &Url, network_policy: Option<&NetworkPolicyDecider>) -> Result<()> {
let host = url.host_str().context("MCP URL has no host")?;
if let Some(policy) = network_policy {
match policy.evaluate(host, "mcp") {
Decision::Allow => {}
Decision::Deny => bail!("MCP HTTP destination blocked by network policy"),
Decision::Prompt => bail!("MCP HTTP destination requires network approval"),
}
}
Ok(())
}
fn validate_url(url: &Url) -> Result<()> {
if !matches!(url.scheme(), "http" | "https") || url.host_str().is_none() {
bail!("MCP HTTP requires an http:// or https:// URL with a host");
}
Ok(())
}
fn url_has_credentials(url: &Url) -> bool {
!url.username().is_empty() || url.password().is_some()
}
impl McpHttpClient {
async fn public_dns_pin(&self, url: &Url) -> Result<Option<(String, SocketAddr)>> {View on GitHub (pinned to 73e0f67d83)