{"record":{"id":"37306c2fa5083ee2","repo":"Hmbown/CodeWhale","slug":"mcp-server-name-connection-to-host-blocked","errorCode":null,"errorMessage":"MCP server '{name}' connection to '{host}' blocked by network policy","messagePattern":"MCP server '(.+?)' connection to '(.+?)' blocked by network policy","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp.rs","lineNumber":1495,"sourceCode":"        // return; a successful connection transfers the task into `Self`.\n        let authority_watch = config.reviewed_plugin.clone().map(|source| {\n            PendingAuthorityWatch::start(\n                source,\n                cancel_token.clone(),\n                Arc::clone(&authority_revocation_reason),\n            )\n        });\n        let transport: Box<dyn McpTransport> = if let Some(url) = &config.url {\n            // Per-domain network policy gate (#135). Only the HTTP/SSE transport\n            // is gated; STDIO MCP servers run as local subprocesses and never\n            // touch the network from this code path.\n            if let Some(decider) = network_policy\n                && let Some(host) = host_from_url(url)\n            {\n                match decider.evaluate(&host, \"mcp\") {\n                    Decision::Allow => {}\n                    Decision::Deny => {\n                        anyhow::bail!(\n                            \"MCP server '{name}' connection to '{host}' blocked by network policy\"\n                        );\n                    }\n                    Decision::Prompt => {\n                        anyhow::bail!(\n                            \"MCP server '{name}' connection to '{host}' requires approval; \\\n                             re-run after `/network allow {host}` or set network.default = \\\"allow\\\" in config\"\n                        );\n                    }\n                }\n            }\n            // Honor the standard `HTTP_PROXY` / `HTTPS_PROXY` (and their\n            // lowercase equivalents) plus `NO_PROXY` env vars when\n            // reaching MCP HTTP servers (#1408). Reqwest 0.13 does not\n            // auto-detect these by default, so users behind corporate\n            // proxies, on China-mainland connections routing through a\n            // local Clash / Shadowsocks tunnel, etc. previously had MCP\n            // HTTP traffic bypass the proxy entirely while every other","sourceCodeStart":1477,"sourceCodeEnd":1513,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/tui/src/mcp.rs#L1477-L1513","documentation":"connect_with_policy consults the per-domain NetworkPolicyDecider for every HTTP/SSE MCP server before building the client; stdio subprocesses are not gated (crates/tui/src/mcp.rs:1485-1498). Decision::Deny - the host was explicitly denied via /network deny <host> or config policy - aborts the connection with this message before any network I/O happens.","triggerScenarios":"The config.url host matches a deny entry created earlier by /network deny, or a deny rule in the network policy configuration; decider.evaluate(host, \"mcp\") returns Deny.","commonSituations":"Policy-hardened machines; a host denied for a different tool earlier (the policy is per-host and cross-tool); explicit exfiltration controls in enterprise setups.","solutions":["If the host is actually trusted, remove the deny: /network remove <host> (or delete the deny rule in the network policy config).","Re-point the MCP server at an allowed host.","If the block is intentional, remove or disable this MCP server entry instead of the deny rule."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-flight the same gate connect_with_policy applies (mcp.rs:1489-1505).\nuse crate::network_policy::{host_from_url, Decision};\n\nfn mcp_host_allowed(policy: &NetworkPolicyDecider, url: &str) -> bool {\n    match host_from_url(url) {\n        Some(host) => policy.evaluate(&host, \"mcp\") == Decision::Allow,\n        None => false,\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Review /network entries before adding remote MCP servers.","Remember deny rules are per-host and apply across tools, not just MCP.","Keep an explicit list of sanctioned MCP hosts in team config."],"tags":["network","policy","mcp","security"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}