Skip to content

fix(agent-core): drop the bracketed [::1] from child-process NO_PROXY - #2481

Closed
xy200303 wants to merge 2 commits into
MoonshotAI:mainfrom
xy200303:fix/mcp-child-noproxy-ipv6
Closed

fix(agent-core): drop the bracketed [::1] from child-process NO_PROXY#2481
xy200303 wants to merge 2 commits into
MoonshotAI:mainfrom
xy200303:fix/mcp-child-noproxy-ipv6

Conversation

@xy200303

Copy link
Copy Markdown

Related Issue

Resolve #1931

Problem

See linked issue. In short: with an HTTP(S) proxy configured, every spawned stdio MCP server inherits NO_PROXY=localhost,127.0.0.1,::1,[::1]. Python's httpx (used by fastmcp and many other MCP servers) crashes while parsing the bracketed [::1] entry (httpx.InvalidURL: Invalid port: ':1]'), so every Python-based MCP server fails at startup with Connection closed for proxy users. Reproduced locally with httpx 0.28.1.

What changed

  • The bracketed [::1] entry only exists for undici 7.x's NO_PROXY parser (it mis-parses a bare ::1 as host : port 1), which matters for the in-process dispatcher — not for child processes. proxyEnvForChild() and reconcileChildNoProxy() now pass a reduced loopback list (localhost,127.0.0.1,::1) that both httpx and undici handle.
  • resolveNoProxy() keeps its previous default (bracketed list) for the in-process dispatcher and gains an optional loopbackHosts parameter; existing callers are unaffected.
  • Trade-off: Node children lose the proxy bypass for literal http://[::1] URLs — a rare edge compared to every Python child crashing at startup.
  • Also includes a test-only fix (test/mcpCore/stubs.ts): resolve fixture paths with fileURLToPath so the mcpCore suites run on Windows (new URL(...).pathname yields /C:/... there).

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my fix works.
  • Ran gen-changesets skill, or this PR needs no changeset. (changeset added)
  • Ran gen-docs skill, or this PR needs no doc update. (no doc update needed)

xy200303 added 2 commits July 31, 2026 23:18
new URL(...).pathname yields /C:/... on Windows, which produced bogus
C:\C:\... fixture paths and made every mcpCore test spawning a fixture
fail with 'Cannot find module'. Match the v1 tests and convert via
fileURLToPath so the suites run on Windows.
When an HTTP(S) proxy is configured, proxyEnvForChild/reconcileChildNoProxy
injected NO_PROXY=localhost,127.0.0.1,::1,[::1] into every spawned stdio
MCP server. Python's httpx (the HTTP client behind fastmcp and many other
MCP servers) crashes while parsing the bracketed [::1] entry
(InvalidURL: Invalid port: ':1]'), so every Python-based MCP server failed
at startup with 'Connection closed' for all proxy users.

The bracketed form only exists for undici 7.x's own NO_PROXY parser, which
mis-parses a bare ::1 as host ':' port '1'. That concern applies to our
in-process dispatcher, not to child env: children get the unbracketed
loopback list (localhost,127.0.0.1,::1), which both httpx and undici
handle. Losing the proxy bypass for literal http://[::1] URLs in Node
children is a far smaller risk than breaking every Python child outright.

resolveNoProxy keeps its previous default (bracketed list) for the
in-process dispatcher; only the child-env builders pass the reduced list.

Refs MoonshotAI#1931
@changeset-bot

changeset-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8de4b45

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8de4b45511

ℹ️ 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".


const LOOPBACK_NO_PROXY = ['localhost', '127.0.0.1', '::1', '[::1]'] as const;

// Spawned child processes get the loopback list WITHOUT the bracketed

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Move v2 explanatory comment into the module header

In packages/agent-core-v2, the scoped comment convention allows explanatory comments only in the top-of-file /** */ block and explicitly forbids comments beside statements; this new inline block above CHILD_LOOPBACK_NO_PROXY violates that convention, so please move the child-process rationale into the module header or otherwise avoid a statement-adjacent comment.

AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L15-L19

Useful? React with 👍 / 👎.

@xy200303

Copy link
Copy Markdown
Author

Closing as duplicate — #2186 and #2081 already address this. Thanks!

@xy200303 xy200303 closed this Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stdio MCP child env injects bracketed [::1] into NO_PROXY, crashing Python httpx-based MCP servers

1 participant