MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / getProxyFetchOptions

Function getProxyFetchOptions

src/utils/proxy.ts:288–319  ·  view source on GitHub ↗
(opts?: { forAnthropicAPI?: boolean })

Source from the content-addressed store, hash-verified

286 * should pass `true` here.
287 */
288export function getProxyFetchOptions(opts?: { forAnthropicAPI?: boolean }): {
289 tls?: TLSConfig
290 dispatcher?: undici.Dispatcher
291 proxy?: string
292 unix?: string
293 keepalive?: false
294} {
295 const base = keepAliveDisabled ? ({ keepalive: false } as const) : {}
296
297 // ANTHROPIC_UNIX_SOCKET tunnels through the `claude ssh` auth proxy, which
298 // hardcodes the upstream to the Anthropic API. Scope to the Anthropic API
299 // client so MCP/SSE/other callers don't get their requests misrouted.
300 if (opts?.forAnthropicAPI) {
301 const unixSocket = process.env.ANTHROPIC_UNIX_SOCKET
302 if (unixSocket && typeof Bun !== 'undefined') {
303 return { ...base, unix: unixSocket }
304 }
305 }
306
307 const proxyUrl = getProxyUrl()
308
309 // If we have a proxy, use the proxy agent (which includes mTLS config)
310 if (proxyUrl) {
311 if (typeof Bun !== 'undefined') {
312 return { ...base, proxy: proxyUrl, ...getTLSFetchOptions() }
313 }
314 return { ...base, dispatcher: getProxyAgent(proxyUrl) }
315 }
316
317 // Otherwise, use TLS options directly if available
318 return { ...base, ...getTLSFetchOptions() }
319}
320
321/**
322 * Configure global HTTP agents for both axios and undici

Callers 5

client.tsFile · 0.85
getAnthropicClientFunction · 0.85
getGrokClientFunction · 0.85
getOpenAIClientFunction · 0.85

Calls 2

getProxyUrlFunction · 0.85
getTLSFetchOptionsFunction · 0.85

Tested by

no test coverage detected