Skip to content

Add proxy support #124

@rohanpower

Description

@rohanpower

Is support for proxy servers possible?

We are behind a corporate proxy, and it appears as though the proxy environment variables (http_proxy/https_proxy) and npm config settings (https-proxy / proxy) are not being used.

Environment

  • OS: Linux (WSL2 - Ubuntu on Windows)
  • Node.js version: v24.4.0
  • npm version: 11.4.2
  • mcp-remote version: latest (via npx - [email protected])

Expected Behavior

The mcp-remote tool should respect proxy settings and successfully connect through corporate proxies when standard proxy environment variables or npm proxy configurations are set.

Actual Behavior

Connection fails with ECONNRESET errors, completely ignoring proxy configuration. The tool attempts direct connections that are blocked by corporate firewalls.

Steps to Reproduce

  1. Set proxy environment variables: export https_proxy=http://proxy.company.com:8080
  2. Configure npm proxy: npm config set https-proxy http://proxy.company.com:8080
  3. Run: npx -y mcp-remote@latest https://mcp.company.com/ --debug
  4. Observe connection failure with ECONNRESET

Proxy Configuration Attempted

  • Environment variables: http_proxy, https_proxy, HTTP_PROXY, HTTPS_PROXY
  • npm config: proxy and https-proxy settings
  • Proxy format: http://proxy-server:8080 (corporate proxy server)
  • No-proxy exclusions: 127.0.0.1,localhost,localhost.localdomain

Debug Log

npx -y mcp-remote@latest https://mcp.company.com/ --debug

[39488] Debug mode enabled - detailed logs will be written to ~/.mcp-auth/
[2025-07-15T05:31:18.992Z][39488] Starting mcp-remote with server URL: https://mcp.company.com/
[39488] Using automatically selected callback port: 5598
[2025-07-15T05:31:19.000Z][39488] Using automatically selected callback port: 5598
[39488] [39488] Connecting to remote server: https://mcp.company.com/
[2025-07-15T05:31:19.002Z][39488] [39488] Connecting to remote server: https://mcp.company.com/
[39488] Using transport strategy: http-first
[2025-07-15T05:31:19.002Z][39488] Using transport strategy: http-first
[2025-07-15T05:31:19.002Z][39488] Attempting to connect to remote server { sseTransport: false }
[2025-07-15T05:31:19.002Z][39488] Starting transport directly
[2025-07-15T05:31:19.003Z][39488] Creating test transport for HTTP-only connection test
[2025-07-15T05:31:19.018Z][39488] Reading OAuth tokens
[2025-07-15T05:31:19.018Z][39488] Token request stack trace: Error
    at NodeOAuthClientProvider.tokens (file:///home/<username>/.npm/_npx/1a3c4333f3a90708/node_modules/mcp-remote/dist/chunk-OXNXVROF.js:14016:46)
    at StreamableHTTPClientTransport._commonHeaders (file:///home/<username>/.npm/_npx/1a3c4333f3a90708/node_modules/mcp-remote/dist/chunk-OXNXVROF.js:13066:47)
    at StreamableHTTPClientTransport.send (file:///home/<username>/.npm/_npx/1a3c4333f3a90708/node_modules/mcp-remote/dist/chunk-OXNXVROF.js:13241:34)
    at file:///home/<username>/.npm/_npx/1a3c4333f3a90708/node_modules/mcp-remote/dist/chunk-OXNXVROF.js:11529:23
    at new Promise (<anonymous>)
    at Client.request (file:///home/<username>/.npm/_npx/1a3c4333f3a90708/node_modules/mcp-remote/dist/chunk-OXNXVROF.js:11466:12)
    at Client.connect (file:///home/<username>/.npm/_npx/1a3c4333f3a90708/node_modules/mcp-remote/dist/chunk-OXNXVROF.js:11638:33)
    at async connectToRemoteServer (file:///home/<username>/.npm/_npx/1a3c4333f3a90708/node_modules/mcp-remote/dist/chunk-OXNXVROF.js:13591:9)
    at async runProxy (file:///home/<username>/.npm/_npx/1a3c4333f3a90708/node_modules/mcp-remote/dist/proxy.js:141:29)
[2025-07-15T05:31:19.021Z][39488] Token result: {
  found: true,
  hasAccessToken: true,
  hasRefreshToken: true,
  expiresIn: '3300 seconds',
  isExpired: false,
  expiresInValue: 3300
}

[39488] Connection error: TypeError: fetch failed
    at node:internal/deps/undici/undici:15422:13
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async StreamableHTTPClientTransport.send (...) {
  [cause]: Error: read ECONNRESET
      at TLSWrap.onStreamRead (node:internal/stream_base_commons:216:20) {
    errno: -104,
    code: 'ECONNRESET',
    syscall: 'read'
  }
}

[39488] Fatal error: TypeError: fetch failed
    [cause]: Error: read ECONNRESET
      at TLSWrap.onStreamRead (node:internal/stream_base_commons:216:20) {
    errno: -104,
    code: 'ECONNRESET',
    syscall: 'read'
  }

Minimum Viable Solution

Could mcp-remote support:

  • Respect npm's existing proxy configuration
  • Standard proxy environment variables (http_proxy/https_proxy)
  • Command-line proxy options (--proxy http://proxy.company.com:8080)\

System Information

# Proxy environment variables
$ env | grep -i proxy
no_proxy=127.0.0.1,localhost,localhost.localdomain
https_proxy=http://proxy.company.com:8080
http_proxy=http://proxy.company.com:8080

# npm proxy configuration  
$ npm config get proxy
http://proxy.company.com:8080

$ npm config get https-proxy
http://proxy.company.com:8080

# Network connectivity test (shows proxy is working for curl)
$ curl -I https://mcp.company.com/
HTTP/1.1 200 Connection established

HTTP/2 401 
date: Tue, 15 Jul 2025 05:40:42 GMT
content-type: application/json
www-authenticate: Bearer realm="OAuth", error="invalid_token", error_description="Missing or invalid access token"
server: CompanyEdge
# ... (connection successful through proxy, authentication required as expected)

Impact

This affects all users in corporate environments with mandatory proxy servers, making mcp-remote unusable in many enterprise settings where MCP could provide significant value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions