Skip to content

Commit dfacc75

Browse files
authored
feat: support --proxy-server CLI (#230)
Closes #155
1 parent ef61a08 commit dfacc75

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ The Chrome DevTools MCP server supports the following configuration option:
276276
Initial viewport size for the Chromee instances started by the server. For example, `1280x720`
277277
- **Type:** string
278278

279+
- **`--proxyServer`**
280+
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.
281+
- **Type:** string
282+
279283
<!-- END AUTO GENERATED OPTIONS -->
280284

281285
Pass them via the `args` property in the JSON configuration. For example:

src/browser.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ interface McpLaunchOptions {
6868
width: number;
6969
height: number;
7070
};
71+
args?: string[];
7172
}
7273

7374
export async function launch(options: McpLaunchOptions): Promise<Browser> {
@@ -90,7 +91,10 @@ export async function launch(options: McpLaunchOptions): Promise<Browser> {
9091
});
9192
}
9293

93-
const args: LaunchOptions['args'] = ['--hide-crash-restore-bubble'];
94+
const args: LaunchOptions['args'] = [
95+
...(options.args ?? []),
96+
'--hide-crash-restore-bubble',
97+
];
9498
if (customDevTools) {
9599
args.push(`--custom-devtools-frontend=file://${customDevTools}`);
96100
}

src/cli.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ export const cliOptions = {
7272
};
7373
},
7474
},
75+
proxyServer: {
76+
type: 'string' as const,
77+
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.`,
78+
},
7579
};
7680

7781
export function parseArguments(version: string, argv = process.argv) {

src/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ server.server.setRequestHandler(SetLevelRequestSchema, () => {
6969

7070
let context: McpContext;
7171
async function getContext(): Promise<McpContext> {
72+
const extraArgs: string[] = [];
73+
if (args.proxyServer) {
74+
extraArgs.push(`--proxy-server=${args.proxyServer}`);
75+
}
7276
const browser = args.browserUrl
7377
? await ensureBrowserConnected(args.browserUrl)
7478
: await ensureBrowserLaunched({
@@ -79,6 +83,7 @@ async function getContext(): Promise<McpContext> {
7983
isolated: args.isolated,
8084
logFile,
8185
viewport: args.viewport,
86+
args: extraArgs,
8287
});
8388

8489
if (context?.browser !== browser) {

0 commit comments

Comments
 (0)