chrome-devtools-mcp 1.8.0 → 1.10.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 (72) hide show
  1. package/README.md +20 -908
  2. package/build/src/BrowserManager.js +401 -0
  3. package/build/src/McpContext.js +43 -26
  4. package/build/src/McpPage.js +112 -4
  5. package/build/src/McpResponse.js +68 -3
  6. package/build/src/ToolHandler.js +184 -160
  7. package/build/src/bin/chrome-devtools-mcp-main.js +12 -7
  8. package/build/src/bin/chrome-devtools.js +6 -12
  9. package/build/src/collectors/PageCollector.js +66 -3
  10. package/build/src/config/browser-options.js +125 -0
  11. package/build/src/config/category-options.js +89 -0
  12. package/build/src/config/cli-commands.js +26 -0
  13. package/build/src/config/cli-options.js +34 -2
  14. package/build/src/config/mcp-options.js +86 -147
  15. package/build/src/daemon/utils.js +6 -0
  16. package/build/src/devtools/DevToolsCommentBridge.js +91 -0
  17. package/build/src/devtools/DevtoolsUtils.js +27 -21
  18. package/build/src/formatters/CommentFormatter.js +82 -0
  19. package/build/src/formatters/CssFormatter.js +812 -0
  20. package/build/src/formatters/NetworkFormatter.js +5 -2
  21. package/build/src/index.js +175 -128
  22. package/build/src/processors/ChunkedTraceParser.js +361 -0
  23. package/build/src/processors/PerformanceTrace.js +60 -13
  24. package/build/src/telemetry/ClearcutLogger.js +95 -37
  25. package/build/src/telemetry/metricsRegistry.js +3 -0
  26. package/build/src/telemetry/persistence.js +17 -7
  27. package/build/src/telemetry/transformation.js +53 -4
  28. package/build/src/telemetry/types.js +1 -0
  29. package/build/src/third_party/THIRD_PARTY_NOTICES +687 -133
  30. package/build/src/third_party/bundled-packages.json +6 -3
  31. package/build/src/third_party/devtools-formatter-worker.js +158 -5
  32. package/build/src/third_party/devtools-heap-snapshot-worker.js +589 -6
  33. package/build/src/third_party/index.js +59173 -38013
  34. package/build/src/third_party/issue-descriptions/webInstallManifestMissingId.md +3 -0
  35. package/build/src/third_party/issue-descriptions/webInstallManifestMissingNameOrShortName.md +3 -0
  36. package/build/src/third_party/issue-descriptions/webInstallManifestParsingOrNetworkError.md +3 -0
  37. package/build/src/third_party/issue-descriptions/webInstallNoManifest.md +3 -0
  38. package/build/src/third_party/issue-descriptions/webInstallStartUrlInvalid.md +3 -0
  39. package/build/src/tools/ToolDefinition.js +28 -21
  40. package/build/src/tools/categories.js +0 -6
  41. package/build/src/tools/comments.js +169 -0
  42. package/build/src/tools/console.js +3 -3
  43. package/build/src/tools/css.js +45 -0
  44. package/build/src/tools/emulation.js +5 -5
  45. package/build/src/tools/extensions.js +10 -10
  46. package/build/src/tools/input.js +159 -87
  47. package/build/src/tools/lighthouse.js +18 -7
  48. package/build/src/tools/memory.js +26 -26
  49. package/build/src/tools/network.js +5 -5
  50. package/build/src/tools/pages.js +34 -19
  51. package/build/src/tools/performance.js +7 -6
  52. package/build/src/tools/pwa.js +8 -8
  53. package/build/src/tools/screencast.js +5 -4
  54. package/build/src/tools/screenshot.js +2 -2
  55. package/build/src/tools/script.js +8 -7
  56. package/build/src/tools/slim/tools.js +45 -37
  57. package/build/src/tools/snapshot.js +4 -4
  58. package/build/src/tools/thirdPartyDeveloper.js +4 -4
  59. package/build/src/tools/tools.js +6 -9
  60. package/build/src/tools/webmcp.js +4 -4
  61. package/build/src/types.js +4 -1
  62. package/build/src/utils/WaitForHelper.js +26 -9
  63. package/build/src/utils/logger.js +7 -6
  64. package/build/src/utils/url.js +73 -0
  65. package/build/src/version.js +1 -1
  66. package/package.json +9 -6
  67. package/skills/chrome-devtools/SKILL.md +2 -1
  68. package/skills/chrome-devtools-cli/SKILL.md +3 -7
  69. package/skills/cookie-debugging/SKILL.md +149 -0
  70. package/skills/memory-leak-debugging/SKILL.md +4 -0
  71. package/build/src/browser.js +0 -244
  72. package/build/src/third_party/issue-descriptions/cookieExcludeBlockedWithinRelatedWebsiteSet.md +0 -4
@@ -0,0 +1,125 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export const browserOptions = {
7
+ autoConnect: {
8
+ type: 'boolean',
9
+ description: 'If specified, automatically connects to a browser (Chrome 144+) running locally from the user data directory identified by the channel param (default channel is stable). Requires the remote debugging server to be started in the Chrome instance via chrome://inspect/#remote-debugging.',
10
+ conflicts: ['isolated', 'executablePath'],
11
+ default: false,
12
+ coerce: (value) => {
13
+ if (!value) {
14
+ return;
15
+ }
16
+ return value;
17
+ },
18
+ },
19
+ browserUrl: {
20
+ type: 'string',
21
+ description: 'Connect to a running, debuggable Chrome instance (e.g. `http://127.0.0.1:9222`). For more details see: https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/main/docs/advanced-usage.md#connecting-to-a-running-chrome-instance.',
22
+ alias: 'u',
23
+ conflicts: ['wsEndpoint'],
24
+ coerce: (url) => {
25
+ if (!url) {
26
+ return;
27
+ }
28
+ try {
29
+ new URL(url);
30
+ }
31
+ catch {
32
+ throw new Error(`Provided browserUrl ${url} is not valid URL.`);
33
+ }
34
+ return url;
35
+ },
36
+ },
37
+ wsEndpoint: {
38
+ type: 'string',
39
+ description: 'WebSocket endpoint to connect to a running Chrome instance (e.g., ws://127.0.0.1:9222/devtools/browser/<id>). Alternative to --browserUrl.',
40
+ alias: 'w',
41
+ conflicts: ['browserUrl'],
42
+ coerce: (url) => {
43
+ if (!url) {
44
+ return;
45
+ }
46
+ try {
47
+ const parsed = new URL(url);
48
+ if (parsed.protocol !== 'ws:' && parsed.protocol !== 'wss:') {
49
+ throw new Error(`Provided wsEndpoint ${url} must use ws:// or wss:// protocol.`);
50
+ }
51
+ return url;
52
+ }
53
+ catch (error) {
54
+ if (error.message.includes('ws://')) {
55
+ throw error;
56
+ }
57
+ throw new Error(`Provided wsEndpoint ${url} is not valid URL.`);
58
+ }
59
+ },
60
+ },
61
+ wsHeaders: {
62
+ type: 'string',
63
+ description: 'Custom headers for WebSocket connection in JSON format (e.g., \'{"Authorization":"Bearer token"}\'). Only works with --wsEndpoint.',
64
+ implies: 'wsEndpoint',
65
+ coerce: (val) => {
66
+ if (!val) {
67
+ return;
68
+ }
69
+ try {
70
+ const parsed = JSON.parse(val);
71
+ if (typeof parsed !== 'object' || Array.isArray(parsed)) {
72
+ throw new Error('Headers must be a JSON object');
73
+ }
74
+ return parsed;
75
+ }
76
+ catch (error) {
77
+ throw new Error(`Invalid JSON for wsHeaders: ${error.message}`);
78
+ }
79
+ },
80
+ },
81
+ headless: {
82
+ type: 'boolean',
83
+ description: 'Whether to run in headless (no UI) mode.',
84
+ default: false,
85
+ },
86
+ executablePath: {
87
+ type: 'string',
88
+ description: 'Path to custom Chrome executable.',
89
+ conflicts: ['browserUrl', 'wsEndpoint'],
90
+ alias: 'e',
91
+ },
92
+ isolated: {
93
+ type: 'boolean',
94
+ description: 'If specified, creates a temporary user-data-dir that is automatically cleaned up after the browser is closed. Defaults to false.',
95
+ },
96
+ userDataDir: {
97
+ type: 'string',
98
+ description: 'Path to the user data directory for Chrome. Default is $HOME/.cache/chrome-devtools-mcp/chrome-profile$CHANNEL_SUFFIX_IF_NON_STABLE',
99
+ conflicts: ['browserUrl', 'wsEndpoint', 'isolated'],
100
+ },
101
+ channel: {
102
+ type: 'string',
103
+ description: 'Specify a different Chrome channel that should be used. The default is the stable channel version.',
104
+ choices: ['canary', 'dev', 'beta', 'stable'],
105
+ conflicts: ['browserUrl', 'wsEndpoint', 'executablePath'],
106
+ },
107
+ proxyServer: {
108
+ type: 'string',
109
+ 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.`,
110
+ },
111
+ chromeArg: {
112
+ type: 'array',
113
+ string: true,
114
+ describe: 'Additional arguments for Chrome. Only applies when Chrome is launched by chrome-devtools-mcp.',
115
+ },
116
+ ignoreDefaultChromeArg: {
117
+ type: 'array',
118
+ string: true,
119
+ describe: 'Explicitly disable default arguments for Chrome. Only applies when Chrome is launched by chrome-devtools-mcp.',
120
+ },
121
+ };
122
+ export function getBrowserOptions() {
123
+ return browserOptions;
124
+ }
125
+ //# sourceMappingURL=browser-options.js.map
@@ -0,0 +1,89 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { ToolCategory } from '../tools/categories.js';
7
+ const categoryOverrides = {
8
+ [ToolCategory.INPUT]: {
9
+ hidden: false,
10
+ },
11
+ [ToolCategory.NAVIGATION]: {
12
+ hidden: false,
13
+ },
14
+ [ToolCategory.EMULATION]: {
15
+ hidden: false,
16
+ },
17
+ [ToolCategory.PERFORMANCE]: {
18
+ hidden: false,
19
+ },
20
+ [ToolCategory.NETWORK]: {
21
+ hidden: false,
22
+ },
23
+ [ToolCategory.DEBUGGING]: {
24
+ hidden: false,
25
+ },
26
+ [ToolCategory.MEMORY]: {
27
+ hidden: false,
28
+ },
29
+ [ToolCategory.WEBMCP]: {
30
+ describe: 'Set to true to enable debugging WebMCP tools. Requires Chrome 150+ with the following flag: `--enable-features=WebMCP`',
31
+ offByDefault: true,
32
+ hidden: false,
33
+ },
34
+ [ToolCategory.EXTENSIONS]: {
35
+ describe: 'Set to true to include tools related to extensions. Note: This feature is currently only supported with a pipe connection. autoConnect, browserUrl, and wsEndpoint are not supported with this feature until 149 will be released.',
36
+ hidden: false,
37
+ offByDefault: true,
38
+ },
39
+ [ToolCategory.THIRD_PARTY]: {
40
+ describe: 'Set to true to enable third-party developer tools exposed by the inspected page itself',
41
+ hidden: false,
42
+ offByDefault: true,
43
+ },
44
+ [ToolCategory.PWA]: {
45
+ describe: 'Set to true to include tools for automating Progressive Web Apps (install, launch, uninstall, and OS state). This feature is only supported with a pipe connection; autoConnect, browserUrl, and wsEndpoint are not supported.',
46
+ conflicts: ['autoConnect', 'browserUrl', 'wsEndpoint'],
47
+ hidden: false,
48
+ offByDefault: true,
49
+ },
50
+ };
51
+ function createOption(category) {
52
+ const overrides = categoryOverrides[category];
53
+ const describe = overrides.offByDefault
54
+ ? `Set to true to include tools related to ${category}.`
55
+ : `Set to false to exclude tools related to ${category}.`;
56
+ return {
57
+ type: 'boolean',
58
+ describe,
59
+ hidden: true,
60
+ ...overrides,
61
+ ...(overrides.offByDefault ? {} : { default: true }),
62
+ };
63
+ }
64
+ export function categoryToFlagName(category) {
65
+ return `category${category.charAt(0).toUpperCase()}${category.slice(1)}`;
66
+ }
67
+ export function getCategoryOptions() {
68
+ const options = {};
69
+ for (const category of Object.values(ToolCategory)) {
70
+ const flagName = categoryToFlagName(category);
71
+ options[flagName] = createOption(category);
72
+ }
73
+ return options;
74
+ }
75
+ export function isCategoryOffByDefault(category) {
76
+ const flagName = categoryToFlagName(category);
77
+ const option = getCategoryOptions()[flagName];
78
+ return !('default' in option) || option.default !== true;
79
+ }
80
+ export function getOffByDefaultCategories() {
81
+ const result = [];
82
+ for (const category of Object.values(ToolCategory)) {
83
+ if (isCategoryOffByDefault(category)) {
84
+ result.push(category);
85
+ }
86
+ }
87
+ return result;
88
+ }
89
+ //# sourceMappingURL=category-options.js.map
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Builds the yargs command string and usage line for a CLI command.
8
+ *
9
+ * Optional args are rendered as `[--flag]` in the usage line only: as part of
10
+ * the command string yargs parses each one as a trailing positional, and a
11
+ * variadic positional has to be the last one.
12
+ */
13
+ export function buildCommand(commandName, args) {
14
+ let command = commandName;
15
+ let flags = '';
16
+ for (const [name, arg] of Object.entries(args)) {
17
+ if (arg.required) {
18
+ command += arg.type === 'array' ? ` <${name}..>` : ` <${name}>`;
19
+ }
20
+ else {
21
+ flags += ` [--${name}]`;
22
+ }
23
+ }
24
+ return { command, usage: `$0 ${command}${flags}` };
25
+ }
26
+ //# sourceMappingURL=cli-commands.js.map
@@ -348,6 +348,38 @@ export const commands = {
348
348
  },
349
349
  },
350
350
  },
351
+ get_css_styles: {
352
+ description: 'Retrieve matched CSS rules, inline styles, inherited styles, and cascade information for an element identified by its UID.\nUse this tool to debug why specific CSS properties are applied, overridden, or conflicting. Results are paginated and return 10 rules per page by default; use pageIdx to page through the remaining rules. Requires a UID from take_snapshot.',
353
+ category: 'Debugging',
354
+ args: {
355
+ pageId: {
356
+ name: 'pageId',
357
+ type: 'number',
358
+ description: 'Targets a specific page by ID.',
359
+ required: true,
360
+ },
361
+ uid: {
362
+ name: 'uid',
363
+ type: 'string',
364
+ description: 'The uid of the element on the page from the page content snapshot to inspect CSS styles for',
365
+ required: true,
366
+ },
367
+ pageSize: {
368
+ name: 'pageSize',
369
+ type: 'integer',
370
+ description: 'Maximum number of CSS rules to return per page. Defaults to 10.',
371
+ required: false,
372
+ default: 10,
373
+ },
374
+ pageIdx: {
375
+ name: 'pageIdx',
376
+ type: 'integer',
377
+ description: 'Page number to return (0-based). Defaults to 0 (the first page).',
378
+ required: false,
379
+ default: 0,
380
+ },
381
+ },
382
+ },
351
383
  get_heapsnapshot_class_nodes: {
352
384
  description: 'Loads a memory heapsnapshot and returns instances of a specific class with their IDs. (requires flag: --memoryDebugging=true)',
353
385
  category: 'Memory',
@@ -632,7 +664,7 @@ export const commands = {
632
664
  },
633
665
  },
634
666
  get_network_request: {
635
- description: 'Gets a network request by an optional reqid, if omitted returns the currently selected request in the DevTools Network panel.',
667
+ description: "Gets a network request by an optional reqid, if omitted returns the currently selected request in the DevTools Network panel. Useful for inspecting request headers (including 'Cookie') and response headers (including 'Set-Cookie' and directives).",
636
668
  category: 'Network',
637
669
  args: {
638
670
  pageId: {
@@ -1001,7 +1033,7 @@ export const commands = {
1001
1033
  isolatedContext: {
1002
1034
  name: 'isolatedContext',
1003
1035
  type: 'string',
1004
- description: 'If specified, the page is created in an isolated browser context with the given name. Pages in the same browser context share cookies and storage. Pages in different browser contexts are fully isolated.',
1036
+ description: 'If specified, the page is created in an isolated browser context with the given name. Pages in the same browser context share cookies and storage. Pages in different browser contexts are fully isolated (useful for clean-slate testing of cookies and authentication).',
1005
1037
  required: false,
1006
1038
  },
1007
1039
  timeout: {
@@ -4,110 +4,17 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { yargs, hideBin } from '../third_party/index.js';
7
+ import os from 'node:os';
8
+ import { readFileSync } from 'node:fs';
9
+ export const DEFAULT_FILESYSTEM_ROOT = [os.tmpdir()];
10
+ import { getCategoryOptions } from './category-options.js';
11
+ import { getBrowserOptions } from './browser-options.js';
7
12
  export const mcpOptions = {
8
- autoConnect: {
9
- type: 'boolean',
10
- description: 'If specified, automatically connects to a browser (Chrome 144+) running locally from the user data directory identified by the channel param (default channel is stable). Requires the remote debugging server to be started in the Chrome instance via chrome://inspect/#remote-debugging.',
11
- conflicts: ['isolated', 'executablePath'],
12
- default: false,
13
- coerce: (value) => {
14
- if (!value) {
15
- return;
16
- }
17
- return value;
18
- },
19
- },
20
- browserUrl: {
21
- type: 'string',
22
- description: 'Connect to a running, debuggable Chrome instance (e.g. `http://127.0.0.1:9222`). For more details see: https://github.com/ChromeDevTools/chrome-devtools-mcp#connecting-to-a-running-chrome-instance.',
23
- alias: 'u',
24
- conflicts: ['wsEndpoint'],
25
- coerce: (url) => {
26
- if (!url) {
27
- return;
28
- }
29
- try {
30
- new URL(url);
31
- }
32
- catch {
33
- throw new Error(`Provided browserUrl ${url} is not valid URL.`);
34
- }
35
- return url;
36
- },
37
- },
38
- wsEndpoint: {
39
- type: 'string',
40
- description: 'WebSocket endpoint to connect to a running Chrome instance (e.g., ws://127.0.0.1:9222/devtools/browser/<id>). Alternative to --browserUrl.',
41
- alias: 'w',
42
- conflicts: ['browserUrl'],
43
- coerce: (url) => {
44
- if (!url) {
45
- return;
46
- }
47
- try {
48
- const parsed = new URL(url);
49
- if (parsed.protocol !== 'ws:' && parsed.protocol !== 'wss:') {
50
- throw new Error(`Provided wsEndpoint ${url} must use ws:// or wss:// protocol.`);
51
- }
52
- return url;
53
- }
54
- catch (error) {
55
- if (error.message.includes('ws://')) {
56
- throw error;
57
- }
58
- throw new Error(`Provided wsEndpoint ${url} is not valid URL.`);
59
- }
60
- },
61
- },
62
- wsHeaders: {
63
- type: 'string',
64
- description: 'Custom headers for WebSocket connection in JSON format (e.g., \'{"Authorization":"Bearer token"}\'). Only works with --wsEndpoint.',
65
- implies: 'wsEndpoint',
66
- coerce: (val) => {
67
- if (!val) {
68
- return;
69
- }
70
- try {
71
- const parsed = JSON.parse(val);
72
- if (typeof parsed !== 'object' || Array.isArray(parsed)) {
73
- throw new Error('Headers must be a JSON object');
74
- }
75
- return parsed;
76
- }
77
- catch (error) {
78
- throw new Error(`Invalid JSON for wsHeaders: ${error.message}`);
79
- }
80
- },
81
- },
82
- headless: {
83
- type: 'boolean',
84
- description: 'Whether to run in headless (no UI) mode.',
85
- default: false,
86
- },
87
- executablePath: {
88
- type: 'string',
89
- description: 'Path to custom Chrome executable.',
90
- conflicts: ['browserUrl', 'wsEndpoint'],
91
- alias: 'e',
92
- },
93
- isolated: {
94
- type: 'boolean',
95
- description: 'If specified, creates a temporary user-data-dir that is automatically cleaned up after the browser is closed. Defaults to false.',
96
- },
97
- userDataDir: {
98
- type: 'string',
99
- description: 'Path to the user data directory for Chrome. Default is $HOME/.cache/chrome-devtools-mcp/chrome-profile$CHANNEL_SUFFIX_IF_NON_STABLE',
100
- conflicts: ['browserUrl', 'wsEndpoint', 'isolated'],
101
- },
102
- channel: {
103
- type: 'string',
104
- description: 'Specify a different Chrome channel that should be used. The default is the stable channel version.',
105
- choices: ['canary', 'dev', 'beta', 'stable'],
106
- conflicts: ['browserUrl', 'wsEndpoint', 'executablePath'],
107
- },
13
+ ...getCategoryOptions(),
14
+ ...getBrowserOptions(),
108
15
  logFile: {
109
16
  type: 'string',
110
- describe: 'Path to a file to write debug logs to. Set the env variable `DEBUG` to `*` to enable verbose logs. Useful for submitting bug reports.',
17
+ 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.',
111
18
  },
112
19
  viewport: {
113
20
  type: 'string',
@@ -126,10 +33,6 @@ export const mcpOptions = {
126
33
  };
127
34
  },
128
35
  },
129
- proxyServer: {
130
- type: 'string',
131
- 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.`,
132
- },
133
36
  acceptInsecureCerts: {
134
37
  type: 'boolean',
135
38
  description: `If enabled, ignores errors relative to self-signed and expired certificates. Use with caution.`,
@@ -139,6 +42,12 @@ export const mcpOptions = {
139
42
  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.',
140
43
  default: true,
141
44
  },
45
+ devtoolsComments: {
46
+ type: 'boolean',
47
+ describe: 'Whether to enable DevTools comments tools. Internal WIP feature.',
48
+ hidden: true,
49
+ default: false,
50
+ },
142
51
  experimentalDevtools: {
143
52
  type: 'boolean',
144
53
  describe: 'Whether to enable automation over DevTools targets',
@@ -187,69 +96,51 @@ export const mcpOptions = {
187
96
  describe: 'Path to ffmpeg executable for screencast recording.',
188
97
  implies: 'experimentalScreencast',
189
98
  },
190
- categoryExperimentalWebmcp: {
191
- type: 'boolean',
192
- describe: 'Set to true to enable debugging WebMCP tools. Requires Chrome 150+ with the following flag: `--enable-features=WebMCP`',
193
- },
194
- chromeArg: {
195
- type: 'array',
196
- describe: 'Additional arguments for Chrome. Only applies when Chrome is launched by chrome-devtools-mcp.',
99
+ experimentalScreencastFps: {
100
+ 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',
103
+ coerce: (value) => {
104
+ if (value === undefined) {
105
+ return;
106
+ }
107
+ if (!Number.isInteger(value) || value <= 0) {
108
+ throw new Error(`Invalid experimentalScreencastFps ${value}. Expected a positive integer.`);
109
+ }
110
+ return value;
111
+ },
197
112
  },
198
113
  blockedUrlPattern: {
199
114
  type: 'array',
115
+ string: true,
200
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.",
201
117
  conflicts: ['allowedUrlPattern'],
202
118
  },
203
119
  allowedUrlPattern: {
204
120
  type: 'array',
121
+ string: true,
205
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.",
206
123
  conflicts: ['blockedUrlPattern'],
207
124
  },
208
- ignoreDefaultChromeArg: {
209
- type: 'array',
210
- describe: 'Explicitly disable default arguments for Chrome. Only applies when Chrome is launched by chrome-devtools-mcp.',
211
- },
212
- categoryEmulation: {
213
- type: 'boolean',
214
- default: true,
215
- describe: 'Set to false to exclude tools related to emulation.',
216
- },
217
- categoryPerformance: {
125
+ performanceCrux: {
218
126
  type: 'boolean',
219
127
  default: true,
220
- describe: 'Set to false to exclude tools related to performance.',
128
+ describe: 'Set to false to disable sending URLs from performance traces to CrUX API to get field performance data.',
221
129
  },
222
- categoryNetwork: {
130
+ usageStatistics: {
223
131
  type: 'boolean',
224
132
  default: true,
225
- describe: 'Set to false to exclude tools related to network.',
226
- },
227
- categoryExtensions: {
228
- type: 'boolean',
229
- hidden: false,
230
- default: false,
231
- describe: 'Set to true to include tools related to extensions. Note: This feature is currently only supported with a pipe connection. autoConnect, browserUrl, and wsEndpoint are not supported with this feature until 149 will be released.',
232
- },
233
- categoryExperimentalThirdParty: {
234
- type: 'boolean',
235
- default: false,
236
- describe: 'Set to true to enable third-party developer tools exposed by the inspected page itself',
237
- },
238
- categoryPwa: {
239
- type: 'boolean',
240
- hidden: false,
241
- conflicts: ['autoConnect', 'browserUrl', 'wsEndpoint'],
242
- describe: 'Set to true to include tools for automating Progressive Web Apps (install, launch, uninstall, and OS state). This feature is only supported with a pipe connection; autoConnect, browserUrl, and wsEndpoint are not supported.',
133
+ describe: 'Set to false to opt-out of usage statistics collection. Google collects usage data to improve the tool, handled under the Google Privacy Policy (https://policies.google.com/privacy). This is independent from Chrome browser metrics. Disabled if `CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS` or `CI` env variables are set.',
243
134
  },
244
- performanceCrux: {
135
+ javascriptEvaluation: {
245
136
  type: 'boolean',
246
137
  default: true,
247
- describe: 'Set to false to disable sending URLs from performance traces to CrUX API to get field performance data.',
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.',
248
139
  },
249
- usageStatistics: {
140
+ sourceMaps: {
250
141
  type: 'boolean',
251
142
  default: true,
252
- describe: 'Set to false to opt-out of usage statistics collection. Google collects usage data to improve the tool, handled under the Google Privacy Policy (https://policies.google.com/privacy). This is independent from Chrome browser metrics. Disabled if `CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS` or `CI` env variables are set.',
143
+ describe: 'Whether to enable source maps in DevTools. Use --no-source-maps to disable.',
253
144
  },
254
145
  clearcutEndpoint: {
255
146
  type: 'string',
@@ -268,7 +159,7 @@ export const mcpOptions = {
268
159
  },
269
160
  screenshotFormat: {
270
161
  type: 'string',
271
- 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 helps reduce context size in AI conversations. Unset preserves the existing default ("png").',
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").',
272
163
  choices: ['jpeg', 'png', 'webp'],
273
164
  },
274
165
  screenshotQuality: {
@@ -327,11 +218,24 @@ export const mcpOptions = {
327
218
  allowUnrestrictedPaths: {
328
219
  type: 'boolean',
329
220
  default: false,
221
+ deprecated: 'Use --workspace=/ instead.',
330
222
  describe: 'If set, disables the default path restriction that applies when the MCP client does not negotiate ' +
331
223
  'the roots capability. By default, file-writing tools are restricted to the OS temp directory when ' +
332
224
  'no roots are configured. Use this only when connecting a trusted local client that does not implement ' +
333
225
  'MCP roots and requires access to paths outside the temp directory.',
334
226
  },
227
+ filesystemRoot: {
228
+ type: 'array',
229
+ string: true,
230
+ alias: 'workspace',
231
+ default: DEFAULT_FILESYSTEM_ROOT,
232
+ defaultDescription: 'OS temp directory',
233
+ describe: 'A directory that filesystem tools are allowed to access. May be specified more than once.',
234
+ },
235
+ config: {
236
+ type: 'string',
237
+ describe: 'Path to JSON configuration file.',
238
+ },
335
239
  };
336
240
  export function getMcpOptionsForViaCli() {
337
241
  if (!('default' in mcpOptions.headless)) {
@@ -382,6 +286,11 @@ export function parser(version, argv = process.argv, env = process.env) {
382
286
  .options(options)
383
287
  .showHelpOnFail(false, 'Specify --help for available options')
384
288
  .middleware(args => {
289
+ if (isViaCli && args.filesystemRoot === DEFAULT_FILESYSTEM_ROOT) {
290
+ const cliFilesystemArgs = args;
291
+ cliFilesystemArgs.allowUnrestrictedPaths = true;
292
+ cliFilesystemArgs.filesystemRoot = undefined;
293
+ }
385
294
  // We can't set default in the options else
386
295
  // Yargs will complain
387
296
  if (!args.channel &&
@@ -462,12 +371,42 @@ export function parser(version, argv = process.argv, env = process.env) {
462
371
  '$0 --no-performance-crux',
463
372
  'Disable CrUX (field data) integration in performance tools.',
464
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
+ ],
465
379
  [
466
380
  '$0 --slim',
467
381
  'Only 3 tools: navigation, JavaScript execution and screenshot',
468
382
  ],
469
383
  ]);
470
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}`);
408
+ }
409
+ })
471
410
  .wrap(Math.min(120, yargsInstance.terminalWidth()))
472
411
  .help()
473
412
  .version(version);
@@ -107,6 +107,12 @@ export function serializeArgs(options, argv) {
107
107
  continue;
108
108
  }
109
109
  const value = argv[key];
110
+ const option = options[key];
111
+ // Yargs reuses the option `default` object; skip it so the daemon parser
112
+ // still sees the original default (needed for filesystemRoot identity).
113
+ if (option !== undefined && value === option.default) {
114
+ continue;
115
+ }
110
116
  const kebabKey = key.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`);
111
117
  if (typeof value === 'boolean') {
112
118
  if (value) {