Files
magpie/internal/claudebridge
yetone 641f00e4c5 claudebridge: the MCP helper calls magpie back past the agent's proxy (#2440)
ump45nose's TestClaudeToolCallbackOnANonLoopbackAddress was red on their
macOS with "curl: (56) Recv failure: Connection reset by peer". The run
hands Claude Code the proxy magpie gives it for Anthropic (by default the
system's: netproxy.EnvWith), with NO_PROXY of localhost, 127.0.0.1, ::1
and the system's exceptions. A gateway on a LAN or Tailscale address
(MAGPIE_ADDR, #1546) isn't in it, so the helper Claude Code starts, which
inherits that environment, sent its tool callback to the proxy. A proxy
that resets it or can't reach back left the call short of the run, and the
turn with the tool's results found no run waiting. The same path is real,
not only the test's: Go's http client takes *_PROXY for every host but
loopback, and the helper serves Claude, Cursor and Grok runs alike.

The helper's callback is always magpie on this computer, so its client
now uses no proxy at all. The test stand-ins of the helper (the takeback
and fork scripts' curl) call back with --noproxy '*' as it does.

Run:
- Reproduced the report: settings.Proxy on a local listener that resets
  every connection, TestClaudeToolCallbackOnANonLoopbackAddress red with
  the reporter's exact curl (56) reset; green after (temporary edit, not
  kept).
- New TestCallbackGoesPastTheAgentsProxy runs the helper as its own
  process with every *_PROXY on a resetting proxy, calling back to this
  computer's non-loopback address. Red on the old helper ("read: connection
  reset by peer"), green now.
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows on
  internal/claudebridge and internal/gateway.
- Full suite: go test -timeout 45m ./... at a61a6f954 + this change: 65
  ok, internal/provider red in TestSecurityKeychainAnswers only (10.03s,
  the 10s keychainWait on a fake `security` written with os.WriteFile;
  fixed at its cause in the next commit). internal/claudebridge and
  internal/gateway ok.
2026-10-16 02:51:37 +08:00
..