Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ interface McpLaunchOptions {
width: number;
height: number;
};
args?: string[];
}

export async function launch(options: McpLaunchOptions): Promise<Browser> {
Expand All @@ -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}`);
}
Expand Down
4 changes: 4 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -79,6 +83,7 @@ async function getContext(): Promise<McpContext> {
isolated: args.isolated,
logFile,
viewport: args.viewport,
args: extraArgs,
});

if (context?.browser !== browser) {
Expand Down
Loading