Launch a browser instance without a global proxy using playwright.chromium.launch() (or firefox/webkit) so the proxy is scoped only to specific contexts.
When creating a browser context, pass a 'proxy' object in the context options; set the 'server' field to your proxy URL including scheme and port (e.g., 'http://proxyhost:port').
If the proxy requires authentication, supply the proxy username and the proxy password parameter in the proxy config object within the same context options.
Create pages within that context — all traffic from those pages will route through the specified proxy, while other contexts on the same browser instance remain unaffected.
After your test or task completes, close the context explicitly to release the proxy connection and avoid resource leaks.
Known gotchas
Proxy configuration set at the browser context level overrides any proxy set at the browser launch level for that context, but does not affect other contexts.
Some proxies require HTTPS interception certificates; if you see TLS errors, you may need to install a custom CA or configure the proxy's certificate in the context options.
SOCKS5 proxies are supported but the scheme in the server URL must match the proxy type (e.g., 'socks5://host:port'); using the wrong scheme will cause silent connection failures.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp