Skip to content

Commit b15b446

Browse files
author
Clawdbot
committed
feat: add protocolTimeout option
1 parent 0a7c0a7 commit b15b446

4 files changed

Lines changed: 24 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,10 @@ The Chrome DevTools MCP server supports the following configuration option:
501501
Custom headers for WebSocket connection in JSON format (e.g., '{"Authorization":"Bearer token"}'). Only works with --wsEndpoint.
502502
- **Type:** string
503503

504+
- **`--protocolTimeout`/ `--protocol-timeout`**
505+
Timeout in milliseconds for Chrome DevTools Protocol commands. Passed to Puppeteer as protocolTimeout.
506+
- **Type:** number
507+
504508
- **`--headless`**
505509
Whether to run in headless (no UI) mode.
506510
- **Type:** boolean

src/bin/chrome-devtools-mcp-cli-options.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,20 @@ export const cliOptions = {
8787
}
8888
},
8989
},
90+
protocolTimeout: {
91+
type: 'number',
92+
description:
93+
'Timeout in milliseconds for Chrome DevTools Protocol commands. Passed to Puppeteer as protocolTimeout.',
94+
coerce: (value: number | undefined) => {
95+
if (value === undefined) {
96+
return;
97+
}
98+
if (!Number.isFinite(value) || value <= 0) {
99+
throw new Error('protocolTimeout must be a positive number of ms.');
100+
}
101+
return value;
102+
},
103+
},
90104
headless: {
91105
type: 'boolean',
92106
description: 'Whether to run in headless (no UI) mode.',

src/browser.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export async function ensureBrowserConnected(options: {
4747
browserURL?: string;
4848
wsEndpoint?: string;
4949
wsHeaders?: Record<string, string>;
50+
protocolTimeout?: number;
5051
devtools: boolean;
5152
channel?: Channel;
5253
userDataDir?: string;
@@ -61,6 +62,7 @@ export async function ensureBrowserConnected(options: {
6162
targetFilter: makeTargetFilter(enableExtensions),
6263
defaultViewport: null,
6364
handleDevToolsAsPage: true,
65+
protocolTimeout: options.protocolTimeout,
6466
};
6567

6668
let autoConnect = false;
@@ -138,6 +140,7 @@ interface McpLaunchOptions {
138140
executablePath?: string;
139141
channel?: Channel;
140142
userDataDir?: string;
143+
protocolTimeout?: number;
141144
headless: boolean;
142145
isolated: boolean;
143146
logFile?: fs.WriteStream;
@@ -229,6 +232,7 @@ export async function launch(options: McpLaunchOptions): Promise<Browser> {
229232
acceptInsecureCerts: options.acceptInsecureCerts,
230233
handleDevToolsAsPage: true,
231234
enableExtensions: options.enableExtensions,
235+
protocolTimeout: options.protocolTimeout,
232236
});
233237
if (options.logFile) {
234238
// FIXME: we are probably subscribing too late to catch startup logs. We

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export async function createMcpServer(
8080
browserURL: serverArgs.browserUrl,
8181
wsEndpoint: serverArgs.wsEndpoint,
8282
wsHeaders: serverArgs.wsHeaders,
83+
protocolTimeout: serverArgs.protocolTimeout,
8384
// Important: only pass channel, if autoConnect is true.
8485
channel: serverArgs.autoConnect
8586
? (serverArgs.channel as Channel)
@@ -93,6 +94,7 @@ export async function createMcpServer(
9394
channel: serverArgs.channel as Channel,
9495
isolated: serverArgs.isolated ?? false,
9596
userDataDir: serverArgs.userDataDir,
97+
protocolTimeout: serverArgs.protocolTimeout,
9698
logFile: options.logFile,
9799
viewport: serverArgs.viewport,
98100
chromeArgs,

0 commit comments

Comments
 (0)