diff --git a/README.md b/README.md index 4916dbd..433dcc4 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 + Pass them via the `args` property in the JSON configuration. For example: diff --git a/src/browser.ts b/src/browser.ts index 7f08e05..baa47e9 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 { @@ -90,7 +91,10 @@ export async function launch(options: McpLaunchOptions): Promise { }); } - 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 4a0c157..5d0ad78 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 91bd8c7..efc2008 100644 --- a/src/main.ts +++ b/src/main.ts @@ -69,6 +69,10 @@ server.server.setRequestHandler(SetLevelRequestSchema, () => { let context: McpContext; async function getContext(): Promise { + 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 { isolated: args.isolated, logFile, viewport: args.viewport, + args: extraArgs, }); if (context?.browser !== browser) {