chrome-devtools-mcp 1.10.1 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/build/src/BrowserManager.js +132 -13
  2. package/build/src/McpContext.js +188 -138
  3. package/build/src/McpPage.js +348 -96
  4. package/build/src/McpResponse.js +234 -76
  5. package/build/src/McpWorker.js +66 -0
  6. package/build/src/SlimMcpResponse.js +5 -1
  7. package/build/src/TextSnapshot.js +3 -2
  8. package/build/src/ToolHandler.js +80 -42
  9. package/build/src/bin/chrome-devtools-mcp-main.js +8 -7
  10. package/build/src/bin/chrome-devtools-mcp.js +1 -1
  11. package/build/src/bin/chrome-devtools.js +31 -41
  12. package/build/src/collectors/ServiceWorkerCollector.js +18 -11
  13. package/build/src/config/ConfigLocator.js +70 -0
  14. package/build/src/config/ConfigParser.js +264 -0
  15. package/build/src/config/ConfigWatcher.js +93 -0
  16. package/build/src/config/browser-options.js +2 -13
  17. package/build/src/config/category-options.js +15 -30
  18. package/build/src/config/cli-commands.js +165 -5
  19. package/build/src/config/cli-options.js +410 -43
  20. package/build/src/config/mcp-options.js +156 -234
  21. package/build/src/config/puppeteer-options.js +65 -0
  22. package/build/src/config/tool-options.js +60 -0
  23. package/build/src/daemon/client.js +81 -41
  24. package/build/src/daemon/daemon.js +55 -45
  25. package/build/src/daemon/utils.js +44 -11
  26. package/build/src/devtools/DevToolsCommentBridge.js +43 -6
  27. package/build/src/devtools/DevtoolsUtils.js +3 -3
  28. package/build/src/devtools/McpHostBindingAdapter.js +0 -1
  29. package/build/src/formatters/CommentFormatter.js +4 -13
  30. package/build/src/formatters/ConsoleFormatter.js +1 -1
  31. package/build/src/formatters/CssFormatter.js +3 -2
  32. package/build/src/formatters/HeapSnapshotFormatter.js +104 -46
  33. package/build/src/formatters/IssueFormatter.js +33 -32
  34. package/build/src/formatters/NetworkFormatter.js +12 -11
  35. package/build/src/formatters/SnapshotFormatter.js +31 -4
  36. package/build/src/index.js +54 -9
  37. package/build/src/processors/ChunkedTraceParser.js +11 -11
  38. package/build/src/processors/HeapSnapshotManager.js +121 -84
  39. package/build/src/processors/PerformanceTrace.js +9 -9
  40. package/build/src/telemetry/ClearcutLogger.js +1 -1
  41. package/build/src/telemetry/transformation.js +7 -11
  42. package/build/src/telemetry/watchdog/main.js +1 -1
  43. package/build/src/third_party/THIRD_PARTY_NOTICES +10 -397
  44. package/build/src/third_party/bundled-packages.json +7 -8
  45. package/build/src/third_party/devtools-formatter-worker.js +1193 -62
  46. package/build/src/third_party/devtools-heap-snapshot-worker.js +1126 -21
  47. package/build/src/third_party/index.js +8087 -19419
  48. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantRead.md +0 -1
  49. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantReadOptOut.md +5 -0
  50. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantSet.md +0 -1
  51. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantSetOptOut.md +5 -0
  52. package/build/src/third_party/issue-descriptions/deprecation.md +1 -1
  53. package/build/src/third_party/issue-descriptions/genericGeolocationPromptWithoutUserGesture.md +5 -0
  54. package/build/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +2 -0
  55. package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +3 -3
  56. package/build/src/tools/ToolDefinition.js +16 -4
  57. package/build/src/tools/comments.js +20 -1
  58. package/build/src/tools/css.js +4 -2
  59. package/build/src/tools/emulation.js +17 -4
  60. package/build/src/tools/input.js +8 -3
  61. package/build/src/tools/lighthouse.js +112 -4
  62. package/build/src/tools/memory.js +129 -28
  63. package/build/src/tools/pages.js +5 -2
  64. package/build/src/tools/performance.js +21 -3
  65. package/build/src/tools/screencast.js +71 -32
  66. package/build/src/tools/screenshot.js +29 -14
  67. package/build/src/tools/script.js +90 -37
  68. package/build/src/tools/slim/tools.js +6 -8
  69. package/build/src/tools/thirdPartyDeveloper.js +6 -4
  70. package/build/src/tools/tools.js +35 -22
  71. package/build/src/tools/webmcp.js +9 -6
  72. package/build/src/types.js +11 -0
  73. package/build/src/utils/WaitForHelper.js +14 -1
  74. package/build/src/utils/check-for-updates.js +1 -1
  75. package/build/src/utils/errorHandling.js +20 -0
  76. package/build/src/utils/logger.js +15 -5
  77. package/build/src/utils/text.js +15 -0
  78. package/build/src/utils/url.js +99 -3
  79. package/build/src/version.js +1 -1
  80. package/package.json +14 -10
  81. package/skills/a11y-debugging/SKILL.md +4 -4
  82. package/skills/chrome-devtools/SKILL.md +2 -2
  83. package/skills/chrome-devtools-cli/SKILL.md +18 -15
  84. package/skills/cookie-debugging/SKILL.md +8 -5
  85. package/skills/debug-optimize-lcp/SKILL.md +1 -1
  86. package/skills/troubleshooting/SKILL.md +5 -6
@@ -3,129 +3,118 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { yargs, hideBin } from '../third_party/index.js';
7
6
  import os from 'node:os';
8
- import { readFileSync } from 'node:fs';
9
- export const DEFAULT_FILESYSTEM_ROOT = [os.tmpdir()];
7
+ import path from 'node:path';
10
8
  import { getCategoryOptions } from './category-options.js';
11
9
  import { getBrowserOptions } from './browser-options.js';
10
+ import { puppeteerOptions } from './puppeteer-options.js';
11
+ import { toolOptions } from './tool-options.js';
12
+ export const DEFAULT_FILESYSTEM_ROOT = [os.tmpdir()];
12
13
  export const mcpOptions = {
13
14
  ...getCategoryOptions(),
14
15
  ...getBrowserOptions(),
16
+ ...puppeteerOptions,
17
+ ...toolOptions,
15
18
  logFile: {
16
19
  type: 'string',
17
20
  describe: 'Path to a file to write debug logs to. Set the env variable `NODE_DEBUG` to `*` to enable verbose logs. Useful for submitting bug reports.',
18
21
  },
19
- viewport: {
20
- type: 'string',
21
- describe: 'Initial viewport size for the Chrome instances started by the server. For example, `1280x720`. In headless mode, max size is 3840x2160px.',
22
- coerce: (arg) => {
23
- if (arg === undefined) {
24
- return;
25
- }
26
- const [width, height] = arg.split('x').map(Number);
27
- if (!width || !height || Number.isNaN(width) || Number.isNaN(height)) {
28
- throw new Error('Invalid viewport. Expected format is `1280x720`.');
29
- }
30
- return {
31
- width,
32
- height,
33
- };
34
- },
35
- },
36
- acceptInsecureCerts: {
37
- type: 'boolean',
38
- description: `If enabled, ignores errors relative to self-signed and expired certificates. Use with caution.`,
39
- },
40
22
  pageIdRouting: {
41
23
  type: 'boolean',
42
24
  describe: 'Require pageId on page-scoped tools and route requests by page ID (useful for concurrent agent sessions). Use --no-page-id-routing to disable.',
43
25
  default: true,
26
+ reloadable: true,
44
27
  },
45
28
  devtoolsComments: {
46
29
  type: 'boolean',
47
30
  describe: 'Whether to enable DevTools comments tools. Internal WIP feature.',
48
31
  hidden: true,
49
32
  default: false,
33
+ reloadable: true,
50
34
  },
51
35
  experimentalDevtools: {
52
36
  type: 'boolean',
53
- describe: 'Whether to enable automation over DevTools targets',
37
+ default: false,
38
+ describe: 'Whether to enable automation over DevTools targets. This exposes the DevTools UI to input tools, including the Console, which can evaluate JavaScript in the inspected page. --no-javascript-evaluation does not restrict this path.',
54
39
  },
55
40
  experimentalVision: {
56
41
  type: 'boolean',
42
+ default: false,
57
43
  describe: 'Whether to enable coordinate-based tools such as click_at(x,y). Usually requires a computer-use model able to produce accurate coordinates by looking at screenshots.',
44
+ reloadable: true,
58
45
  },
59
46
  memoryDebugging: {
60
47
  type: 'boolean',
61
48
  default: false,
62
49
  describe: 'Whether to enable memory debugging tools.',
63
50
  alias: 'experimentalMemory',
51
+ reloadable: true,
64
52
  },
65
53
  experimentalStructuredContent: {
66
54
  type: 'boolean',
67
55
  default: false,
68
56
  describe: 'Whether to output structured formatted content.',
57
+ reloadable: true,
69
58
  },
70
59
  experimentalToonFormat: {
71
60
  type: 'boolean',
61
+ default: false,
72
62
  describe: 'Deprecated: use --experimentalDataFormat=toon instead. Whether to format structured data using TOON (requires @toon-format/toon).',
73
63
  hidden: true,
64
+ reloadable: true,
74
65
  },
75
66
  experimentalDataFormat: {
76
67
  type: 'string',
68
+ defaultDescription: 'default',
77
69
  describe: 'Override format for structured data in text responses. Default uses built-in formatters. "toon" (requires @toon-format/toon) or "gcf" (requires @blackwell-systems/gcf) replace structured content with the specified encoding.',
78
70
  choices: ['default', 'toon', 'gcf'],
79
71
  hidden: true,
72
+ reloadable: true,
80
73
  },
81
74
  experimentalIncludeAllPages: {
82
75
  type: 'boolean',
76
+ default: false,
83
77
  describe: 'Whether to include all kinds of pages such as webviews or background pages as pages.',
78
+ reloadable: true,
84
79
  },
85
80
  experimentalInteropTools: {
86
81
  type: 'boolean',
82
+ default: false,
87
83
  describe: 'Whether to enable interoperability tools',
88
84
  hidden: true,
85
+ reloadable: true,
89
86
  },
90
87
  experimentalScreencast: {
91
88
  type: 'boolean',
92
- describe: 'Exposes experimental screencast tools (requires ffmpeg). Install ffmpeg https://www.ffmpeg.org/download.html and ensure it is available in the MCP server PATH.',
89
+ default: false,
90
+ describe: 'Use the legacy ffmpeg-based screencast implementation instead of the built-in Chrome recorder. Install ffmpeg https://www.ffmpeg.org/download.html and ensure it is available in the MCP server PATH. This option is deprecated and will be removed in favour of dependency-free screencast commands that are available by default.',
91
+ reloadable: true,
93
92
  },
94
93
  experimentalFfmpegPath: {
95
94
  type: 'string',
96
- describe: 'Path to ffmpeg executable for screencast recording.',
97
- implies: 'experimentalScreencast',
95
+ describe: 'Path to ffmpeg executable for legacy screencast recording (requires --experimentalScreencast).',
96
+ reloadable: true,
98
97
  },
99
- experimentalScreencastFps: {
98
+ screencastFps: {
100
99
  type: 'number',
101
- describe: 'Frames per second to use for screencast recording. Lower values can reduce memory pressure on pages that produce frames faster than ffmpeg can encode them.',
102
- implies: 'experimentalScreencast',
100
+ alias: 'experimentalScreencastFps',
101
+ describe: 'Frames per second to use for screencast recording. Lower values reduce file size and encoding load.',
102
+ reloadable: true,
103
103
  coerce: (value) => {
104
104
  if (value === undefined) {
105
105
  return;
106
106
  }
107
107
  if (!Number.isInteger(value) || value <= 0) {
108
- throw new Error(`Invalid experimentalScreencastFps ${value}. Expected a positive integer.`);
108
+ throw new Error(`Invalid screencastFps ${value}. Expected a positive integer.`);
109
109
  }
110
110
  return value;
111
111
  },
112
112
  },
113
- blockedUrlPattern: {
114
- type: 'array',
115
- string: true,
116
- describe: "Restricts browser's network access by blocking specified URL patterns (uses https://urlpattern.spec.whatwg.org/). Silently detaches from targets with blocked URLs upon connection, and blocks runtime requests (including navigations and subresources). Accepts an array of patterns.",
117
- conflicts: ['allowedUrlPattern'],
118
- },
119
- allowedUrlPattern: {
120
- type: 'array',
121
- string: true,
122
- describe: "Restricts browser's network access by allowing only specified URL patterns (uses https://urlpattern.spec.whatwg.org/). Requires Chrome 149+. Silently detaches from targets with unallowed URLs upon connection, and blocks runtime requests (including navigations and subresources). Accepts an array of patterns.",
123
- conflicts: ['blockedUrlPattern'],
124
- },
125
113
  performanceCrux: {
126
114
  type: 'boolean',
127
115
  default: true,
128
116
  describe: 'Set to false to disable sending URLs from performance traces to CrUX API to get field performance data.',
117
+ reloadable: true,
129
118
  },
130
119
  usageStatistics: {
131
120
  type: 'boolean',
@@ -135,12 +124,20 @@ export const mcpOptions = {
135
124
  javascriptEvaluation: {
136
125
  type: 'boolean',
137
126
  default: true,
138
- describe: 'Set to false to disable JavaScript execution. When disabled, evaluation tools (evaluate_script and slim evaluate) are disabled, the initScript parameter in navigate_page is turned off, and navigating to javascript:, data:, or vbscript: URLs is disallowed.',
127
+ describe: 'Set to false to disable the server entry points for evaluating caller-provided JavaScript: evaluation tools (evaluate_script and slim evaluate) are disabled, the initScript parameter in navigate_page is turned off, and navigating to javascript:, data:, or vbscript: URLs is disallowed. This is not a JavaScript sandbox: page scripts and JavaScript triggered through other permitted browser interactions (e.g. clicks or typing) still run. If --experimentalDevtools is also enabled, the DevTools UI, including the Console that evaluates code in the inspected page, can be automated and is not restricted by this option. The client remains responsible for validating tool calls and parameters.',
128
+ reloadable: true,
129
+ },
130
+ fileNavigations: {
131
+ type: 'boolean',
132
+ default: true,
133
+ describe: 'Set to false to disallow navigating to file: URLs. When disabled, new_page, navigate_page and the slim navigate tool reject file: URLs, including view-source: URLs that target them. This restricts navigations the server performs. It is not a filesystem sandbox: it does not affect pages the browser already had open when the server connected, and the browser can reach the filesystem by other means. Use OS sandboxing for full filesystem confinement.',
134
+ reloadable: true,
139
135
  },
140
136
  sourceMaps: {
141
137
  type: 'boolean',
142
138
  default: true,
143
139
  describe: 'Whether to enable source maps in DevTools. Use --no-source-maps to disable.',
140
+ reloadable: true,
144
141
  },
145
142
  clearcutEndpoint: {
146
143
  type: 'string',
@@ -154,59 +151,19 @@ export const mcpOptions = {
154
151
  },
155
152
  clearcutIncludePidHeader: {
156
153
  type: 'boolean',
154
+ default: false,
157
155
  hidden: true,
158
156
  describe: 'Include watchdog PID in Clearcut request headers (for testing).',
159
157
  },
160
- screenshotFormat: {
161
- type: 'string',
162
- description: 'Override the default output format used by take_screenshot when the caller does not specify one. JPEG and WebP are ~3-5x smaller than PNG, which reduces transfer and storage size. To reduce context size use --screenshotMaxWidth / --screenshotMaxHeight, since image tokens scale with dimensions rather than encoded bytes. Unset preserves the existing default ("png").',
163
- choices: ['jpeg', 'png', 'webp'],
164
- },
165
- screenshotQuality: {
166
- type: 'number',
167
- description: 'Override the default compression quality (0-100) used by take_screenshot for JPEG and WebP when the caller does not specify one. Lower values mean smaller files. Ignored for PNG. Unset preserves the Puppeteer default.',
168
- coerce: (value) => {
169
- if (value === undefined) {
170
- return;
171
- }
172
- if (!Number.isInteger(value) || value < 0 || value > 100) {
173
- throw new Error(`Invalid screenshotQuality ${value}. Expected an integer between 0 and 100.`);
174
- }
175
- return value;
176
- },
177
- },
178
- screenshotMaxWidth: {
179
- type: 'number',
180
- description: 'Maximum width in pixels for screenshots. If the captured image is wider, it is downscaled (preserving aspect ratio) before being returned. Reduces context size in AI conversations. Unset means no resize.',
181
- coerce: (value) => {
182
- if (value === undefined) {
183
- return;
184
- }
185
- if (!Number.isInteger(value) || value <= 0) {
186
- throw new Error(`Invalid screenshotMaxWidth ${value}. Expected a positive integer.`);
187
- }
188
- return value;
189
- },
190
- },
191
- screenshotMaxHeight: {
192
- type: 'number',
193
- description: 'Maximum height in pixels for screenshots. If the captured image is taller, it is downscaled (preserving aspect ratio) before being returned. Can be combined with --screenshot-max-width; the smaller scale factor wins. Unset means no resize.',
194
- coerce: (value) => {
195
- if (value === undefined) {
196
- return;
197
- }
198
- if (!Number.isInteger(value) || value <= 0) {
199
- throw new Error(`Invalid screenshotMaxHeight ${value}. Expected a positive integer.`);
200
- }
201
- return value;
202
- },
203
- },
204
158
  slim: {
205
159
  type: 'boolean',
160
+ default: false,
206
161
  describe: 'Exposes a "slim" set of 3 tools covering navigation, script execution and screenshots only. Useful for basic browser tasks.',
162
+ reloadable: true,
207
163
  },
208
164
  viaCli: {
209
165
  type: 'boolean',
166
+ default: false,
210
167
  describe: 'Set by Chrome DevTools CLI if the MCP server is started via the CLI client (this arg exists for usage stats)',
211
168
  hidden: true,
212
169
  },
@@ -214,15 +171,17 @@ export const mcpOptions = {
214
171
  type: 'boolean',
215
172
  describe: 'If true, redacts some of the network headers considered sensitive before returning to the client.',
216
173
  default: false,
174
+ reloadable: true,
217
175
  },
218
176
  allowUnrestrictedPaths: {
219
177
  type: 'boolean',
220
178
  default: false,
221
179
  deprecated: 'Use --workspace=/ instead.',
222
180
  describe: 'If set, disables the default path restriction that applies when the MCP client does not negotiate ' +
223
- 'the roots capability. By default, file-writing tools are restricted to the OS temp directory when ' +
181
+ 'the roots capability. By default, tools that read or write local files are restricted to the OS temp directory when ' +
224
182
  'no roots are configured. Use this only when connecting a trusted local client that does not implement ' +
225
183
  'MCP roots and requires access to paths outside the temp directory.',
184
+ reloadable: true,
226
185
  },
227
186
  filesystemRoot: {
228
187
  type: 'array',
@@ -231,10 +190,17 @@ export const mcpOptions = {
231
190
  default: DEFAULT_FILESYSTEM_ROOT,
232
191
  defaultDescription: 'OS temp directory',
233
192
  describe: 'A directory that filesystem tools are allowed to access. May be specified more than once.',
193
+ reloadable: true,
234
194
  },
235
195
  config: {
236
196
  type: 'string',
237
197
  describe: 'Path to JSON configuration file.',
198
+ coerce: (configPath) => {
199
+ if (!configPath) {
200
+ return;
201
+ }
202
+ return path.resolve(configPath);
203
+ },
238
204
  },
239
205
  };
240
206
  export function getMcpOptionsForViaCli() {
@@ -244,9 +210,6 @@ export function getMcpOptionsForViaCli() {
244
210
  if (!('default' in mcpOptions.experimentalStructuredContent)) {
245
211
  throw new Error('experimentalStructuredContent cli option unexpectedly does not have a default');
246
212
  }
247
- if ('default' in mcpOptions.isolated) {
248
- throw new Error('isolated cli option unexpectedly has a default');
249
- }
250
213
  return {
251
214
  ...mcpOptions,
252
215
  headless: {
@@ -259,7 +222,7 @@ export function getMcpOptionsForViaCli() {
259
222
  },
260
223
  categoryExtensions: {
261
224
  ...mcpOptions.categoryExtensions,
262
- default: true,
225
+ defaultDescription: 'true unless autoConnect, browserUrl or wsEndpoint is set',
263
226
  },
264
227
  experimentalStructuredContent: {
265
228
  ...mcpOptions.experimentalStructuredContent,
@@ -268,150 +231,109 @@ export function getMcpOptionsForViaCli() {
268
231
  isolated: {
269
232
  ...mcpOptions.isolated,
270
233
  description: 'If specified, creates a temporary user-data-dir that is automatically cleaned up after the browser is closed. Defaults to true unless userDataDir is provided.',
234
+ defaultDescription: 'true unless userDataDir, autoConnect, browserUrl or wsEndpoint is set',
271
235
  },
272
236
  };
273
237
  }
274
- /**
275
- * Exported only for testing to not trigger process exit.
276
- */
277
- export function parser(version, argv = process.argv, env = process.env) {
278
- const isViaCli = argv.includes('--viaCli') || argv.includes('--via-cli');
279
- const options = isViaCli ? getMcpOptionsForViaCli() : mcpOptions;
280
- const yargsInstance = yargs(hideBin(argv))
281
- .scriptName('npx chrome-devtools-mcp@latest')
282
- .parserConfiguration({
283
- 'strip-aliased': true,
284
- 'strip-dashed': true,
285
- })
286
- .options(options)
287
- .showHelpOnFail(false, 'Specify --help for available options')
288
- .middleware(args => {
289
- if (isViaCli && args.filesystemRoot === DEFAULT_FILESYSTEM_ROOT) {
290
- const cliFilesystemArgs = args;
291
- cliFilesystemArgs.allowUnrestrictedPaths = true;
292
- cliFilesystemArgs.filesystemRoot = undefined;
293
- }
294
- // We can't set default in the options else
295
- // Yargs will complain
296
- if (!args.channel &&
297
- !args.browserUrl &&
298
- !args.wsEndpoint &&
299
- !args.executablePath) {
300
- args.channel = 'stable';
301
- }
302
- if (env['CI'] || env['CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS']) {
303
- console.error("turning off usage statistics. process.env['CI'] || process.env['CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS'] is set.");
304
- args.usageStatistics = false;
305
- }
306
- const cliOptionsAllowedArgs = [
307
- ...Object.keys(options),
308
- // Yargs populated with positional args
309
- '_',
310
- '$0',
311
- ];
312
- const unknownArgs = Object.keys(args).filter(arg => !cliOptionsAllowedArgs.includes(arg));
313
- if (unknownArgs.length > 0) {
314
- console.error(`Unknown arguments: ${unknownArgs.map(arg => `--${arg}`)}`);
315
- }
316
- })
317
- .example([
318
- [
319
- '$0 --browserUrl http://127.0.0.1:9222',
320
- 'Connect to an existing browser instance via HTTP',
321
- ],
322
- [
323
- '$0 --wsEndpoint ws://127.0.0.1:9222/devtools/browser/abc123',
324
- 'Connect to an existing browser instance via WebSocket',
325
- ],
326
- [
327
- `$0 --wsEndpoint ws://127.0.0.1:9222/devtools/browser/abc123 --wsHeaders '{"Authorization":"Bearer token"}'`,
328
- 'Connect via WebSocket with custom headers',
329
- ],
330
- ['$0 --channel beta', 'Use Chrome Beta installed on this system'],
331
- ['$0 --channel canary', 'Use Chrome Canary installed on this system'],
332
- ['$0 --channel dev', 'Use Chrome Dev installed on this system'],
333
- ['$0 --channel stable', 'Use stable Chrome installed on this system'],
334
- ['$0 --logFile /tmp/log.txt', 'Save logs to a file'],
335
- ['$0 --help', 'Print CLI options'],
336
- [
337
- '$0 --viewport 1280x720',
338
- 'Launch Chrome with the initial viewport size of 1280x720px',
339
- ],
340
- [
341
- `$0 --chrome-arg='--no-sandbox' --chrome-arg='--disable-setuid-sandbox'`,
342
- 'Launch Chrome without sandboxes. Use with caution.',
343
- ],
344
- [
345
- `$0 --ignore-default-chrome-arg='--disable-extensions'`,
346
- 'Disable the default arguments provided by Puppeteer. Use with caution.',
347
- ],
348
- ['$0 --no-category-emulation', 'Disable tools in the emulation category'],
349
- [
350
- '$0 --no-category-performance',
351
- 'Disable tools in the performance category',
352
- ],
353
- ['$0 --no-category-network', 'Disable tools in the network category'],
354
- [
355
- '$0 --user-data-dir=/tmp/user-data-dir',
356
- 'Use a custom user data directory',
357
- ],
358
- [
359
- '$0 --auto-connect',
360
- 'Connect to a stable Chrome instance (Chrome 144+) running instead of launching a new instance',
361
- ],
362
- [
363
- '$0 --auto-connect --channel=canary',
364
- 'Connect to a canary Chrome instance (Chrome 144+) running instead of launching a new instance',
365
- ],
366
- [
367
- '$0 --no-usage-statistics',
368
- 'Do not send usage statistics https://github.com/ChromeDevTools/chrome-devtools-mcp#usage-statistics.',
369
- ],
370
- [
371
- '$0 --no-performance-crux',
372
- 'Disable CrUX (field data) integration in performance tools.',
373
- ],
374
- ['$0 --no-source-maps', 'Disable source maps in DevTools.'],
375
- [
376
- '$0 --no-javascript-evaluation',
377
- 'Disable JavaScript execution (disables evaluation tools, initScript in navigate_page, and navigating to javascript:, data:, or vbscript: URLs).',
378
- ],
379
- [
380
- '$0 --slim',
381
- 'Only 3 tools: navigation, JavaScript execution and screenshot',
382
- ],
383
- ]);
384
- return yargsInstance
385
- .config('config', 'Path to JSON configuration file', configPath => {
386
- try {
387
- const parsed = JSON.parse(readFileSync(configPath, 'utf-8'));
388
- if (typeof parsed !== 'object' ||
389
- parsed === null ||
390
- Array.isArray(parsed)) {
391
- throw new Error('Config must be a JSON object');
392
- }
393
- yargs()
394
- .parserConfiguration({
395
- 'strip-aliased': true,
396
- 'camel-case-expansion': false,
397
- })
398
- .options(options)
399
- .config(parsed)
400
- .strict()
401
- .fail(false)
402
- .exitProcess(false)
403
- .parseSync([]);
404
- return parsed;
405
- }
406
- catch (err) {
407
- throw new Error(`Invalid JSON config file: ${err.message}`);
238
+ export function getCliOptions() {
239
+ const options = withoutDefaults(getMcpOptionsForViaCli());
240
+ // Missing CLI serialization.
241
+ delete options.viewport;
242
+ // Change the defaults for the CLI.
243
+ delete options.experimentalStructuredContent;
244
+ delete options.experimentalInteropTools;
245
+ return options;
246
+ }
247
+ export const CLI_EXAMPLES = [
248
+ [
249
+ '$0 --browserUrl http://127.0.0.1:9222',
250
+ 'Connect to an existing browser instance via HTTP',
251
+ ],
252
+ [
253
+ '$0 --wsEndpoint ws://127.0.0.1:9222/devtools/browser/abc123',
254
+ 'Connect to an existing browser instance via WebSocket',
255
+ ],
256
+ [
257
+ `$0 --wsEndpoint ws://127.0.0.1:9222/devtools/browser/abc123 --wsHeaders '{"Authorization":"Bearer token"}'`,
258
+ 'Connect via WebSocket with custom headers',
259
+ ],
260
+ ['$0 --channel beta', 'Use Chrome Beta installed on this system'],
261
+ ['$0 --channel canary', 'Use Chrome Canary installed on this system'],
262
+ ['$0 --channel dev', 'Use Chrome Dev installed on this system'],
263
+ ['$0 --channel stable', 'Use stable Chrome installed on this system'],
264
+ ['$0 --logFile /tmp/log.txt', 'Save logs to a file'],
265
+ ['$0 --help', 'Print CLI options'],
266
+ [
267
+ '$0 --viewport 1280x720',
268
+ 'Launch Chrome with the initial viewport size of 1280x720px',
269
+ ],
270
+ [
271
+ `$0 --chrome-arg='--no-sandbox' --chrome-arg='--disable-setuid-sandbox'`,
272
+ 'Launch Chrome without sandboxes. Use with caution.',
273
+ ],
274
+ [
275
+ `$0 --ignore-default-chrome-arg='--disable-extensions'`,
276
+ 'Disable the default arguments provided by Puppeteer. Use with caution.',
277
+ ],
278
+ ['$0 --no-category-emulation', 'Disable tools in the emulation category'],
279
+ ['$0 --no-category-performance', 'Disable tools in the performance category'],
280
+ ['$0 --no-category-network', 'Disable tools in the network category'],
281
+ ['$0 --user-data-dir=/tmp/user-data-dir', 'Use a custom user data directory'],
282
+ [
283
+ '$0 --auto-connect',
284
+ 'Connect to a stable Chrome instance (Chrome 144+) running instead of launching a new instance',
285
+ ],
286
+ [
287
+ '$0 --auto-connect --channel=canary',
288
+ 'Connect to a canary Chrome instance (Chrome 144+) running instead of launching a new instance',
289
+ ],
290
+ [
291
+ '$0 --no-usage-statistics',
292
+ 'Do not send usage statistics https://github.com/ChromeDevTools/chrome-devtools-mcp#usage-statistics.',
293
+ ],
294
+ [
295
+ '$0 --no-performance-crux',
296
+ 'Disable CrUX (field data) integration in performance tools.',
297
+ ],
298
+ ['$0 --no-source-maps', 'Disable source maps in DevTools.'],
299
+ [
300
+ '$0 --no-javascript-evaluation',
301
+ 'Disable server JavaScript evaluation entry points (evaluation tools, initScript in navigate_page, and navigating to javascript:, data:, or vbscript: URLs). Page scripts still run.',
302
+ ],
303
+ [
304
+ '$0 --slim',
305
+ 'Only 3 tools: navigation, JavaScript execution and screenshot',
306
+ ],
307
+ ];
308
+ export const CONFLICTING_ARGS = [
309
+ ['channel', 'executablePath', 'browserUrl', 'wsEndpoint'],
310
+ ['userDataDir', 'browserUrl', 'wsEndpoint'],
311
+ ['userDataDir', 'isolated'],
312
+ ['autoConnect', 'isolated'],
313
+ ['autoConnect', 'executablePath'],
314
+ ['blockedUrlPattern', 'allowedUrlPattern'],
315
+ ['allowUnrestrictedPaths', 'filesystemRoot'],
316
+ ['categoryPwa', 'autoConnect'],
317
+ ['categoryPwa', 'browserUrl', 'wsEndpoint'],
318
+ ];
319
+ export const IMPLICATIONS = [
320
+ ['wsHeaders', 'wsEndpoint'],
321
+ ['experimentalFfmpegPath', 'experimentalScreencast'],
322
+ ];
323
+ export function withoutDefaults(options) {
324
+ const result = {};
325
+ for (const [key, option] of Object.entries(options)) {
326
+ const copy = { ...option };
327
+ if (copy.default !== undefined) {
328
+ copy.defaultDescription ??= JSON.stringify(copy.default);
329
+ delete copy.default;
408
330
  }
409
- })
410
- .wrap(Math.min(120, yargsInstance.terminalWidth()))
411
- .help()
412
- .version(version);
331
+ result[key] = copy;
332
+ }
333
+ return result;
413
334
  }
414
- export function parseArguments(version, argv = process.argv, env = process.env) {
415
- return parser(version, argv, env).parseSync();
335
+ export function isReloadableOption(name) {
336
+ const option = mcpOptions[name];
337
+ return option.reloadable === true;
416
338
  }
417
339
  //# sourceMappingURL=mcp-options.js.map
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { validateUrlPatterns } from '../utils/url.js';
7
+ /**
8
+ * Options that are applied through Puppeteer when launching or connecting to
9
+ * the browser.
10
+ */
11
+ export const puppeteerOptions = {
12
+ viewport: {
13
+ type: 'string',
14
+ describe: 'Initial viewport size for the Chrome instances started by the server. For example, `1280x720`. In headless mode, max size is 3840x2160px.',
15
+ coerce: (arg) => {
16
+ if (arg === undefined) {
17
+ return;
18
+ }
19
+ const [width, height] = arg.split('x').map(Number);
20
+ if (!Number.isInteger(width) ||
21
+ !Number.isInteger(height) ||
22
+ width <= 0 ||
23
+ height <= 0) {
24
+ throw new Error('Invalid viewport. Expected format is `1280x720` with positive integer width and height.');
25
+ }
26
+ return {
27
+ width,
28
+ height,
29
+ };
30
+ },
31
+ },
32
+ acceptInsecureCerts: {
33
+ type: 'boolean',
34
+ default: false,
35
+ description: `If enabled, ignores errors relative to self-signed and expired certificates. Use with caution.`,
36
+ },
37
+ blockedUrlPattern: {
38
+ type: 'array',
39
+ string: true,
40
+ describe: "Restricts browser's network access by blocking specified URL patterns (uses https://urlpattern.spec.whatwg.org/). Silently detaches from targets with blocked URLs upon connection, and blocks runtime requests (including navigations and subresources). Accepts an array of patterns. A pattern that uses a regexp group, a named group (`:name`), or a partial IPv4 wildcard (for example `(127\\.\\d+\\.\\d+\\.\\d+)`, `*://127.0.0.1::port/*`, or `*://127.0.0.*/*`) is rejected, because it is not enforced on redirects or subresources; use an exact value or a `*` wildcard instead.",
41
+ coerce: (arg) => {
42
+ if (arg === undefined || arg.length === 0) {
43
+ return undefined;
44
+ }
45
+ validateUrlPatterns(arg, '--blockedUrlPattern');
46
+ return arg;
47
+ },
48
+ },
49
+ allowedUrlPattern: {
50
+ type: 'array',
51
+ string: true,
52
+ describe: "Restricts browser's network access by allowing only specified URL patterns (uses https://urlpattern.spec.whatwg.org/). Requires Chrome 149+. Silently detaches from targets with unallowed URLs upon connection, and blocks runtime requests (including navigations and subresources). Accepts an array of patterns. A pattern that uses a regexp group, a named group (`:name`), or a partial IPv4 wildcard (for example `(127\\.\\d+\\.\\d+\\.\\d+)`, `*://127.0.0.1::port/*`, or `*://127.0.0.*/*`) is rejected, because it is not enforced on redirects or subresources; use an exact value or a `*` wildcard instead.",
53
+ coerce: (arg) => {
54
+ if (arg === undefined) {
55
+ return undefined;
56
+ }
57
+ if (arg.length === 0) {
58
+ throw new Error('Invalid --allowedUrlPattern: at least one pattern is required.');
59
+ }
60
+ validateUrlPatterns(arg, '--allowedUrlPattern');
61
+ return arg;
62
+ },
63
+ },
64
+ };
65
+ //# sourceMappingURL=puppeteer-options.js.map