Skip to content

Chrome DevTools for coding agents

feat: support --proxy-server CLI (#230)

Alex Rudenkodfacc75ee9f4
diff --git a/README.md b/README.md
index 4916dbd7..433dcc41 100644
--- a/README.md
+++ b/README.md
@@ -276,6 +276,10 @@ The Chrome DevTools MCP server supports the following configuration option:
Initial viewport size for the Chromee instances started by the server. For example, `1280x720`
- **Type:** string
+- **`--proxyServer`**
+ Proxy server configuration for Chrome passed as --proxy-server when launching the browser. See https://www.chromium.org/developers/design-documents/network-settings/ for details.
+ - **Type:** string
+
<!-- END AUTO GENERATED OPTIONS -->
Pass them via the `args` property in the JSON configuration. For example:
diff --git a/src/browser.ts b/src/browser.ts
index 7f08e054..baa47e90 100644
--- a/src/browser.ts
+++ b/src/browser.ts
@@ -68,6 +68,7 @@ interface McpLaunchOptions {
width: number;
height: number;
};
+ args?: string[];
}
export async function launch(options: McpLaunchOptions): Promise<Browser> {
@@ -90,7 +91,10 @@ export async function launch(options: McpLaunchOptions): Promise<Browser> {
});
}
- const args: LaunchOptions['args'] = ['--hide-crash-restore-bubble'];
+ const args: LaunchOptions['args'] = [
+ ...(options.args ?? []),
+ '--hide-crash-restore-bubble',
+ ];
if (customDevTools) {
args.push(`--custom-devtools-frontend=file://${customDevTools}`);
}
diff --git a/src/cli.ts b/src/cli.ts
index 4a0c1571..5d0ad78c 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -72,6 +72,10 @@ export const cliOptions = {
};
},
},
+ proxyServer: {
+ type: 'string' as const,
+ description: `Proxy server configuration for Chrome passed as --proxy-server when launching the browser. See https://www.chromium.org/developers/design-documents/network-settings/ for details.`,
+ },
};
export function parseArguments(version: string, argv = process.argv) {
diff --git a/src/main.ts b/src/main.ts
index 91bd8c79..efc2008d 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -69,6 +69,10 @@ server.server.setRequestHandler(SetLevelRequestSchema, () => {
let context: McpContext;
async function getContext(): Promise<McpContext> {
+ const extraArgs: string[] = [];
+ if (args.proxyServer) {
+ extraArgs.push(`--proxy-server=${args.proxyServer}`);
+ }
const browser = args.browserUrl
? await ensureBrowserConnected(args.browserUrl)
: await ensureBrowserLaunched({
@@ -79,6 +83,7 @@ async function getContext(): Promise<McpContext> {
isolated: args.isolated,
logFile,
viewport: args.viewport,
+ args: extraArgs,
});
if (context?.browser !== browser) {