Bug: HTTP MCP client ignores no_proxy environment variable
Description
Claude Code's HTTP MCP client does not respect the no_proxy / NO_PROXY environment variable when connecting to MCP servers. Requests to localhost are routed through the corporate proxy instead of connecting directly.
Environment
- Claude Code version: 2.1.31
- OS: Linux (WSL2)
- Node.js HTTP client creates
HttpsProxyAgentfor all requests
Reproduction Steps
- Set proxy environment variables:
``bash``
export HTTP_PROXY=http://corporate-proxy:8080
export HTTPS_PROXY=http://corporate-proxy:8080
export no_proxy=localhost,127.0.0.1
- Configure an HTTP MCP server pointing to localhost:
``bash``
claude mcp add --transport http myserver http://localhost:8080/mcp
- Attempt to connect:
``bash``
DEBUG=* claude mcp get myserver
- Observe debug output shows proxy being used:
````
https-proxy-agent Creating new HttpsProxyAgent instance: 'http://corporate-proxy:8080/'
- Connection fails because proxy cannot reach localhost on the user's machine
Expected Behavior
Claude Code should respect no_proxy / NO_PROXY and connect directly to localhost/127.0.0.1 without using the proxy.
Actual Behavior
All HTTP MCP connections go through the proxy, ignoring no_proxy. This makes it impossible to use local MCP servers in corporate environments that require proxy for internet access.
Workaround
Currently none that preserves both proxy for internet and direct access for localhost.
Additional Context
curlrespectsno_proxycorrectly in the same environment- The issue is in the Node.js HTTP client used for MCP connections
- Libraries like
proxy-agentorglobal-agentcan properly handleno_proxy
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗