proxy_set_host_upstream
Override the global upstream proxy for a specific hostname. Traffic to that host will be routed through the assigned proxy instead.
Instructions
Set a per-host upstream proxy override. Traffic to this hostname will use the specified proxy instead of the global one.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hostname | Yes | Hostname to override (e.g., api.example.com) | |
| proxy_url | Yes | Upstream proxy URL for this host | |
| no_proxy | No | Hostnames to bypass this proxy |
Implementation Reference
- src/state.ts:530-533 (handler)setHostUpstream method in ProxyManager — stores per-host proxy config and triggers mockttp rule rebuild if running.
async setHostUpstream(hostname: string, config: UpstreamProxyConfig): Promise<void> { this.hostUpstreams.set(hostname, config); if (this._running) await this.rebuildMockttpRules(); } - src/tools/upstream.ts:55-62 (schema)Tool registration for 'proxy_set_host_upstream' with Zod schema for hostname, proxy_url, and optional no_proxy.
server.tool( "proxy_set_host_upstream", "Set a per-host upstream proxy override. Traffic to this hostname will use the specified proxy instead of the global one.", { hostname: z.string().describe("Hostname to override (e.g., api.example.com)"), proxy_url: z.string().describe("Upstream proxy URL for this host"), no_proxy: z.array(z.string()).optional().describe("Hostnames to bypass this proxy"), }, - src/tools/upstream.ts:55-79 (registration)server.tool('proxy_set_host_upstream', ...) registers the tool on the MCP server, defining name, description, input schema, and handler.
server.tool( "proxy_set_host_upstream", "Set a per-host upstream proxy override. Traffic to this hostname will use the specified proxy instead of the global one.", { hostname: z.string().describe("Hostname to override (e.g., api.example.com)"), proxy_url: z.string().describe("Upstream proxy URL for this host"), no_proxy: z.array(z.string()).optional().describe("Hostnames to bypass this proxy"), }, async ({ hostname, proxy_url, no_proxy }) => { try { await proxyManager.setHostUpstream(hostname, { proxyUrl: proxy_url, noProxy: no_proxy }); return { content: [{ type: "text", text: JSON.stringify({ status: "success", message: `Upstream for '${hostname}' set to ${proxy_url}`, }), }], }; } catch (e) { return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: String(e) }) }] }; } }, ); - src/index.ts:63-63 (registration)registerUpstreamTools(server) is called from the main entry point to register all upstream proxy tools including proxy_set_host_upstream.
registerUpstreamTools(server); - src/state.ts:1499-1512 (helper)resolveProxyConfig uses hostUpstreams map to match per-host proxy configs by hostname, falling back to global upstream.
private resolveProxyConfig(): ProxyConfig { if (!this.globalUpstream && this.hostUpstreams.size === 0) return undefined; return ({ hostname }: { hostname: string }) => { const hostConfig = this.hostUpstreams.get(hostname); if (hostConfig) { return { proxyUrl: hostConfig.proxyUrl, noProxy: hostConfig.noProxy }; } if (this.globalUpstream) { return { proxyUrl: this.globalUpstream.proxyUrl, noProxy: this.globalUpstream.noProxy }; } return undefined; }; }