Skip to content

Commit 2bd65cc

Browse files
Mossakaclaude
andauthored
fix: set NO_PROXY for host gateway to bypass Squid for MCP (#554)
The iptables NAT bypass from v0.13.10 prevents DNAT redirection, but HTTP_PROXY env var still causes HTTP clients (like Codex's reqwest) to send MCP traffic through Squid as a forward proxy. Concurrent SSE connections through Squid crash it (comm.cc:1583). Set NO_PROXY with host.docker.internal and the network gateway IP when --enable-host-access is enabled, so MCP gateway traffic bypasses both DNAT and the forward proxy. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e7645f9 commit 2bd65cc

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/docker-manager.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,18 @@ export function generateDockerCompose(
332332
PATH: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
333333
};
334334

335+
// When host access is enabled, bypass the proxy for the host gateway IPs.
336+
// MCP Streamable HTTP (SSE) traffic through Squid crashes it (comm.cc:1583),
337+
// so MCP gateway traffic must go directly to the host, not through Squid.
338+
if (config.enableHostAccess) {
339+
// Compute the network gateway IP (first usable IP in the subnet)
340+
const subnetBase = networkConfig.subnet.split('/')[0]; // e.g. "172.30.0.0"
341+
const parts = subnetBase.split('.');
342+
const networkGatewayIp = `${parts[0]}.${parts[1]}.${parts[2]}.1`;
343+
environment.NO_PROXY = `localhost,127.0.0.1,${networkConfig.squidIp},host.docker.internal,${networkGatewayIp}`;
344+
environment.no_proxy = environment.NO_PROXY;
345+
}
346+
335347
// For chroot mode, pass the host's actual PATH and tool directories so the entrypoint can use them
336348
// This ensures toolcache paths (Python, Node, Go, Rust, Java) are correctly resolved
337349
if (config.enableChroot) {

0 commit comments

Comments
 (0)