Skip to content

[FEATURE]: Add HTTP/SOCKS5 proxy support for outbound requests #37036

Description

@0x80x

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem

OpenCode doesn't support HTTP/HTTPS or SOCKS5 proxies. Users behind corporate firewalls can't use it with LLM providers, the webfetch tool, or any other outbound feature. The existing proxy-env.ts reads HTTP_PROXY but only applies it to WebSocket connections.

Solution

Add proxy support to opencode.json (fallback to env vars):

{
  "proxy": {
    "url": "http://proxy:8080",
    // or "socks5://proxy:1080"
    "noProxy": ["localhost", "*.internal.com"]
  }
}

Wire it into all outbound paths via a single proxy-aware fetch wrapper:

  • LLM API calls (both AI SDK and native runtime) — via options.fetch / FetchHttpClient
  • webfetch tool, config fetching, session instructions — via HttpClient
  • WebSocket connections — extend existing proxy-env.ts with SOCKS5
  • Direct fetch() calls (LSP downloads, auth, CLI) — via global fetch wrapper
  • MCP servers — pass proxy env vars to child processes

Implementation

  1. proxy-fetch.ts — proxy-aware fetch wrapper (HTTP via undici, SOCKS5 via socks-proxy-agent)
  2. Add proxy field to config schema
  3. Inject proxy fetch into provider options and FetchHttpClient service
  4. Extend proxy-env.ts with SOCKS5 parsing
  5. Pass proxy env to MCP child processes
    No new deps for HTTP proxy. SOCKS5 is optional.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions