fix(proxy): omit bracketed [::1] from child process NO_PROXY#2186
fix(proxy): omit bracketed [::1] from child process NO_PROXY#2186panandicoding wants to merge 3 commits into
Conversation
The bracketed IPv6 loopback [::1] in NO_PROXY is only needed in-process for undici's EnvHttpProxyAgent. When propagated to child processes (stdio MCP servers), Python's httpx parses �ll://[::1] and treats :1] as the port, raising httpx.InvalidURL and crashing any Python-based MCP server when a proxy is configured. Introduce LOOPBACK_NO_PROXY_CHILD (without [::1]) and resolveNoProxyForChild() used by proxyEnvForChild() and reconcileChildNoProxy(). The in-process resolveNoProxy() is unchanged. Closes MoonshotAI#1931
🦋 Changeset detectedLatest commit: cc7deaa The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c51d246eae
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // proxy is configured. The bracketed form is only needed in-process for undici's | ||
| // EnvHttpProxyAgent; children rely on `NODE_USE_ENV_PROXY` (Node ≥ 22) which | ||
| // handles bare `::1` correctly. | ||
| const LOOPBACK_NO_PROXY_CHILD = ['localhost', '127.0.0.1', '::1'] as const; |
There was a problem hiding this comment.
Preserve the bracketed loopback for Node children
When a spawned stdio MCP server is Node and connects to an IPv6-loopback URL while HTTP_PROXY is set, this removes the only loopback entry Node recognizes. Using the repository-required Node 24.15.0 with NODE_USE_ENV_PROXY=1, NO_PROXY=::1 sent fetch('http://[::1]:...') through the proxy, while NO_PROXY=[::1] connected directly. JavaScript MCP children can therefore lose access to local IPv6 services or expose those requests to the proxy; select the value based on the child runtime rather than applying the Python workaround to every child.
AGENTS.md reference: AGENTS.md:L32-L36
Useful? React with 👍 / 👎.
|
|
||
| const LOOPBACK_NO_PROXY = ['localhost', '127.0.0.1', '::1', '[::1]'] as const; | ||
|
|
||
| // Child processes (e.g. stdio MCP servers) must NOT receive the bracketed `[::1]`: |
There was a problem hiding this comment.
Move the new v2 comments into the module header
The scoped guide requires comments in this package to live solely in the top-of-file header, but this change adds an implementation narrative beside the constant and another function-level JSDoc above resolveNoProxyForChild. Remove these mid-file comments or consolidate only the module's externally visible responsibility into the existing header.
AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L11-L14
Useful? React with 👍 / 👎.
Node children (undici via NODE_USE_ENV_PROXY) require the bracketed [::1] to bypass the proxy for IPv6 loopback; non-Node children (Python httpx) crash on it. Detect the command basename (node/npx/tsx/ts-node) and pass the appropriate loopback list. Also consolidates mid-file comments into the module header per agent-core-v2 comment conventions.
Related Issue
Closes #1931
Description
The bracketed IPv6 loopback
[::1]inNO_PROXYis only needed in-process for undici'sEnvHttpProxyAgent(which mis-parses a bare::1as host:port1). However,proxyEnvForChild()andreconcileChildNoProxy()were propagating the same value verbatim into child processes (stdio MCP servers).Python's httpx parses
all://[::1]and treats:1]as the port, raisinghttpx.InvalidURL— crashing any Python-based MCP server when a proxy is configured.Fix
LOOPBACK_NO_PROXY_CHILD(without[::1]) alongside the existingLOOPBACK_NO_PROXY.resolveNoProxyForChild()which uses the child-safe loopback list.proxyEnvForChild()andreconcileChildNoProxy()now callresolveNoProxyForChild()instead ofresolveNoProxy().resolveNoProxy()(used bycreateProxyDispatcherfor undici) is unchanged — it still includes[::1].Applied to both
packages/agent-coreandpackages/agent-core-v2(identical proxy utilities).Checklist
pnpm changesetto add a changeset.docs/.