chrome-devtools-mcp 1.10.1 → 1.12.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.
- package/README.md +72 -20
- package/build/src/BrowserManager.js +155 -27
- package/build/src/McpContext.js +598 -200
- package/build/src/McpPage.js +513 -131
- package/build/src/McpResponse.js +291 -116
- package/build/src/McpWorker.js +66 -0
- package/build/src/SlimMcpResponse.js +5 -1
- package/build/src/TextSnapshot.js +40 -20
- package/build/src/ToolHandler.js +306 -147
- package/build/src/bin/chrome-devtools-mcp-main.js +13 -10
- package/build/src/bin/chrome-devtools-mcp.js +1 -1
- package/build/src/bin/chrome-devtools.js +34 -44
- package/build/src/collectors/PageCollector.js +13 -9
- package/build/src/collectors/ServiceWorkerCollector.js +20 -13
- package/build/src/collectors/constants.js +7 -0
- package/build/src/config/ConfigLocator.js +70 -0
- package/build/src/config/ConfigParser.js +159 -0
- package/build/src/config/ConfigWatcher.js +94 -0
- package/build/src/config/ServerConfig.js +251 -0
- package/build/src/config/browser-options.js +15 -17
- package/build/src/config/category-options.js +15 -30
- package/build/src/config/cli-commands.js +165 -5
- package/build/src/config/cli-options.js +441 -58
- package/build/src/config/mcp-options.js +212 -264
- package/build/src/config/puppeteer-options.js +67 -0
- package/build/src/config/tool-options.js +60 -0
- package/build/src/daemon/client.js +84 -44
- package/build/src/daemon/daemon.js +59 -45
- package/build/src/daemon/utils.js +46 -12
- package/build/src/devtools/DevToolsCommentBridge.js +71 -11
- package/build/src/devtools/DevtoolsUtils.js +52 -15
- package/build/src/devtools/McpHostBindingAdapter.js +0 -1
- package/build/src/formatters/CommentFormatter.js +4 -13
- package/build/src/formatters/ConsoleFormatter.js +29 -2
- package/build/src/formatters/CssFormatter.js +3 -2
- package/build/src/formatters/HeapSnapshotFormatter.js +111 -57
- package/build/src/formatters/IssueFormatter.js +33 -32
- package/build/src/formatters/NetworkFormatter.js +62 -22
- package/build/src/formatters/RemoteObjectFormatter.js +231 -0
- package/build/src/formatters/SnapshotFormatter.js +44 -7
- package/build/src/index.js +285 -88
- package/build/src/processors/ChunkedTraceParser.js +11 -11
- package/build/src/processors/HeapSnapshotManager.js +455 -156
- package/build/src/processors/PerformanceTrace.js +9 -9
- package/build/src/telemetry/ClearcutLogger.js +1 -1
- package/build/src/telemetry/transformation.js +7 -11
- package/build/src/telemetry/watchdog/main.js +1 -1
- package/build/src/third_party/THIRD_PARTY_NOTICES +399 -689
- package/build/src/third_party/bundled-packages.json +7 -8
- package/build/src/third_party/cli.js +9239 -0
- package/build/src/third_party/devtools-formatter-worker.js +4299 -2517
- package/build/src/third_party/devtools-heap-snapshot-worker.js +1298 -22
- package/build/src/third_party/index.js +132003 -146852
- package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantRead.md +0 -1
- package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantReadOptOut.md +5 -0
- package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantSet.md +0 -1
- package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantSetOptOut.md +5 -0
- package/build/src/third_party/issue-descriptions/deprecation.md +1 -1
- package/build/src/third_party/issue-descriptions/genericGeolocationPromptWithoutUserGesture.md +5 -0
- package/build/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +2 -0
- package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +54576 -52174
- package/build/src/tools/ToolDefinition.js +102 -12
- package/build/src/tools/comments.js +62 -4
- package/build/src/tools/console.js +6 -4
- package/build/src/tools/css.js +5 -2
- package/build/src/tools/emulation.js +22 -8
- package/build/src/tools/extensions.js +5 -0
- package/build/src/tools/input.js +29 -9
- package/build/src/tools/lighthouse.js +136 -12
- package/build/src/tools/memory.js +166 -59
- package/build/src/tools/network.js +5 -4
- package/build/src/tools/pages.js +52 -7
- package/build/src/tools/performance.js +28 -7
- package/build/src/tools/pwa.js +7 -0
- package/build/src/tools/screencast.js +74 -33
- package/build/src/tools/screenshot.js +52 -21
- package/build/src/tools/script.js +125 -40
- package/build/src/tools/slim/tools.js +27 -13
- package/build/src/tools/snapshot.js +13 -3
- package/build/src/tools/thirdPartyDeveloper.js +9 -5
- package/build/src/tools/tools.js +35 -22
- package/build/src/tools/webmcp.js +11 -6
- package/build/src/types.js +11 -0
- package/build/src/utils/TaskRunner.js +136 -0
- package/build/src/utils/WaitForHelper.js +15 -2
- package/build/src/utils/bytes.js +2 -12
- package/build/src/utils/check-for-updates.js +2 -2
- package/build/src/utils/disclaimers.js +27 -0
- package/build/src/utils/errorHandling.js +20 -0
- package/build/src/utils/keyboard.js +14 -2
- package/build/src/utils/logger.js +84 -5
- package/build/src/utils/resourceType.js +27 -0
- package/build/src/utils/text.js +44 -0
- package/build/src/utils/timeout.js +14 -0
- package/build/src/utils/url.js +140 -3
- package/build/src/version.js +1 -1
- package/package.json +16 -11
- package/skills/a11y-debugging/SKILL.md +7 -12
- package/skills/chrome-devtools/SKILL.md +2 -2
- package/skills/chrome-devtools-cli/SKILL.md +18 -15
- package/skills/cookie-debugging/SKILL.md +8 -5
- package/skills/debug-optimize-lcp/SKILL.md +1 -1
- package/skills/troubleshooting/SKILL.md +5 -6
|
@@ -3,129 +3,122 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { DEFAULT_MAX_NAVIGATION_SAVED } from '../collectors/constants.js';
|
|
7
7
|
import os from 'node:os';
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
import { getCategoryOptions } from './category-options.js';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { getCategoryOptions, } from './category-options.js';
|
|
11
10
|
import { getBrowserOptions } from './browser-options.js';
|
|
11
|
+
import { puppeteerOptions, } from './puppeteer-options.js';
|
|
12
|
+
import { toolOptions } from './tool-options.js';
|
|
13
|
+
export const DEFAULT_FILESYSTEM_ROOT = [os.tmpdir()];
|
|
14
|
+
// Each retained navigation can hold up to 1,000 network requests and 10,000
|
|
15
|
+
// console messages, so the history is capped to avoid running out of memory.
|
|
16
|
+
export const MAX_NAVIGATION_SAVED_LIMIT = 25;
|
|
12
17
|
export const mcpOptions = {
|
|
13
18
|
...getCategoryOptions(),
|
|
14
19
|
...getBrowserOptions(),
|
|
20
|
+
...puppeteerOptions,
|
|
21
|
+
...toolOptions,
|
|
15
22
|
logFile: {
|
|
16
23
|
type: 'string',
|
|
17
24
|
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
25
|
},
|
|
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
26
|
pageIdRouting: {
|
|
41
27
|
type: 'boolean',
|
|
42
28
|
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
29
|
default: true,
|
|
30
|
+
reloadable: true,
|
|
44
31
|
},
|
|
45
32
|
devtoolsComments: {
|
|
46
33
|
type: 'boolean',
|
|
47
34
|
describe: 'Whether to enable DevTools comments tools. Internal WIP feature.',
|
|
48
35
|
hidden: true,
|
|
49
36
|
default: false,
|
|
37
|
+
reloadable: true,
|
|
50
38
|
},
|
|
51
39
|
experimentalDevtools: {
|
|
52
40
|
type: 'boolean',
|
|
53
|
-
|
|
41
|
+
default: false,
|
|
42
|
+
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
43
|
},
|
|
55
44
|
experimentalVision: {
|
|
56
45
|
type: 'boolean',
|
|
46
|
+
default: false,
|
|
57
47
|
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.',
|
|
48
|
+
reloadable: true,
|
|
58
49
|
},
|
|
59
50
|
memoryDebugging: {
|
|
60
51
|
type: 'boolean',
|
|
61
52
|
default: false,
|
|
62
53
|
describe: 'Whether to enable memory debugging tools.',
|
|
63
54
|
alias: 'experimentalMemory',
|
|
55
|
+
reloadable: true,
|
|
64
56
|
},
|
|
65
57
|
experimentalStructuredContent: {
|
|
66
58
|
type: 'boolean',
|
|
67
59
|
default: false,
|
|
68
60
|
describe: 'Whether to output structured formatted content.',
|
|
61
|
+
reloadable: true,
|
|
69
62
|
},
|
|
70
63
|
experimentalToonFormat: {
|
|
71
64
|
type: 'boolean',
|
|
65
|
+
default: false,
|
|
72
66
|
describe: 'Deprecated: use --experimentalDataFormat=toon instead. Whether to format structured data using TOON (requires @toon-format/toon).',
|
|
73
67
|
hidden: true,
|
|
68
|
+
reloadable: true,
|
|
74
69
|
},
|
|
75
70
|
experimentalDataFormat: {
|
|
76
71
|
type: 'string',
|
|
72
|
+
defaultDescription: 'default',
|
|
77
73
|
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
74
|
choices: ['default', 'toon', 'gcf'],
|
|
79
75
|
hidden: true,
|
|
76
|
+
reloadable: true,
|
|
80
77
|
},
|
|
81
78
|
experimentalIncludeAllPages: {
|
|
82
79
|
type: 'boolean',
|
|
80
|
+
default: false,
|
|
83
81
|
describe: 'Whether to include all kinds of pages such as webviews or background pages as pages.',
|
|
82
|
+
reloadable: true,
|
|
84
83
|
},
|
|
85
84
|
experimentalInteropTools: {
|
|
86
85
|
type: 'boolean',
|
|
86
|
+
default: false,
|
|
87
87
|
describe: 'Whether to enable interoperability tools',
|
|
88
88
|
hidden: true,
|
|
89
|
+
reloadable: true,
|
|
89
90
|
},
|
|
90
91
|
experimentalScreencast: {
|
|
91
92
|
type: 'boolean',
|
|
92
|
-
|
|
93
|
+
default: false,
|
|
94
|
+
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.',
|
|
95
|
+
reloadable: true,
|
|
93
96
|
},
|
|
94
97
|
experimentalFfmpegPath: {
|
|
95
98
|
type: 'string',
|
|
96
|
-
describe: 'Path to ffmpeg executable for screencast recording.',
|
|
97
|
-
|
|
99
|
+
describe: 'Path to ffmpeg executable for legacy screencast recording (requires --experimentalScreencast).',
|
|
100
|
+
reloadable: true,
|
|
98
101
|
},
|
|
99
|
-
|
|
102
|
+
screencastFps: {
|
|
100
103
|
type: 'number',
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
alias: 'experimentalScreencastFps',
|
|
105
|
+
describe: 'Frames per second to use for screencast recording. Lower values reduce file size and encoding load.',
|
|
106
|
+
reloadable: true,
|
|
103
107
|
coerce: (value) => {
|
|
104
108
|
if (value === undefined) {
|
|
105
109
|
return;
|
|
106
110
|
}
|
|
107
111
|
if (!Number.isInteger(value) || value <= 0) {
|
|
108
|
-
throw new Error(`Invalid
|
|
112
|
+
throw new Error(`Invalid screencastFps ${value}. Expected a positive integer.`);
|
|
109
113
|
}
|
|
110
114
|
return value;
|
|
111
115
|
},
|
|
112
116
|
},
|
|
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
117
|
performanceCrux: {
|
|
126
118
|
type: 'boolean',
|
|
127
119
|
default: true,
|
|
128
120
|
describe: 'Set to false to disable sending URLs from performance traces to CrUX API to get field performance data.',
|
|
121
|
+
reloadable: true,
|
|
129
122
|
},
|
|
130
123
|
usageStatistics: {
|
|
131
124
|
type: 'boolean',
|
|
@@ -135,12 +128,36 @@ export const mcpOptions = {
|
|
|
135
128
|
javascriptEvaluation: {
|
|
136
129
|
type: 'boolean',
|
|
137
130
|
default: true,
|
|
138
|
-
describe: 'Set to false to disable
|
|
131
|
+
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.',
|
|
132
|
+
reloadable: true,
|
|
133
|
+
},
|
|
134
|
+
fileNavigations: {
|
|
135
|
+
type: 'boolean',
|
|
136
|
+
default: true,
|
|
137
|
+
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.',
|
|
138
|
+
reloadable: true,
|
|
139
139
|
},
|
|
140
140
|
sourceMaps: {
|
|
141
141
|
type: 'boolean',
|
|
142
142
|
default: true,
|
|
143
143
|
describe: 'Whether to enable source maps in DevTools. Use --no-source-maps to disable.',
|
|
144
|
+
reloadable: true,
|
|
145
|
+
},
|
|
146
|
+
maxNavigationSaved: {
|
|
147
|
+
type: 'number',
|
|
148
|
+
default: DEFAULT_MAX_NAVIGATION_SAVED,
|
|
149
|
+
describe: `Number of navigations (including the current one) for which network requests and console messages are retained per page. Must be between 1 and ${MAX_NAVIGATION_SAVED_LIMIT}. For earlier navigations, request URLs, status codes, and request and response headers are retained, which is sufficient to trace redirect hops, but response bodies are generally no longer available.`,
|
|
150
|
+
coerce: (value) => {
|
|
151
|
+
if (value === undefined) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (!Number.isInteger(value) ||
|
|
155
|
+
value <= 0 ||
|
|
156
|
+
value > MAX_NAVIGATION_SAVED_LIMIT) {
|
|
157
|
+
throw new Error(`Invalid maxNavigationSaved ${value}. Expected an integer between 1 and ${MAX_NAVIGATION_SAVED_LIMIT}.`);
|
|
158
|
+
}
|
|
159
|
+
return value;
|
|
160
|
+
},
|
|
144
161
|
},
|
|
145
162
|
clearcutEndpoint: {
|
|
146
163
|
type: 'string',
|
|
@@ -154,59 +171,19 @@ export const mcpOptions = {
|
|
|
154
171
|
},
|
|
155
172
|
clearcutIncludePidHeader: {
|
|
156
173
|
type: 'boolean',
|
|
174
|
+
default: false,
|
|
157
175
|
hidden: true,
|
|
158
176
|
describe: 'Include watchdog PID in Clearcut request headers (for testing).',
|
|
159
177
|
},
|
|
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
178
|
slim: {
|
|
205
179
|
type: 'boolean',
|
|
180
|
+
default: false,
|
|
206
181
|
describe: 'Exposes a "slim" set of 3 tools covering navigation, script execution and screenshots only. Useful for basic browser tasks.',
|
|
182
|
+
reloadable: true,
|
|
207
183
|
},
|
|
208
184
|
viaCli: {
|
|
209
185
|
type: 'boolean',
|
|
186
|
+
default: false,
|
|
210
187
|
describe: 'Set by Chrome DevTools CLI if the MCP server is started via the CLI client (this arg exists for usage stats)',
|
|
211
188
|
hidden: true,
|
|
212
189
|
},
|
|
@@ -214,15 +191,17 @@ export const mcpOptions = {
|
|
|
214
191
|
type: 'boolean',
|
|
215
192
|
describe: 'If true, redacts some of the network headers considered sensitive before returning to the client.',
|
|
216
193
|
default: false,
|
|
194
|
+
reloadable: true,
|
|
217
195
|
},
|
|
218
196
|
allowUnrestrictedPaths: {
|
|
219
197
|
type: 'boolean',
|
|
220
198
|
default: false,
|
|
221
199
|
deprecated: 'Use --workspace=/ instead.',
|
|
222
200
|
describe: 'If set, disables the default path restriction that applies when the MCP client does not negotiate ' +
|
|
223
|
-
'the roots capability. By default,
|
|
201
|
+
'the roots capability. By default, tools that read or write local files are restricted to the OS temp directory when ' +
|
|
224
202
|
'no roots are configured. Use this only when connecting a trusted local client that does not implement ' +
|
|
225
203
|
'MCP roots and requires access to paths outside the temp directory.',
|
|
204
|
+
reloadable: true,
|
|
226
205
|
},
|
|
227
206
|
filesystemRoot: {
|
|
228
207
|
type: 'array',
|
|
@@ -231,187 +210,156 @@ export const mcpOptions = {
|
|
|
231
210
|
default: DEFAULT_FILESYSTEM_ROOT,
|
|
232
211
|
defaultDescription: 'OS temp directory',
|
|
233
212
|
describe: 'A directory that filesystem tools are allowed to access. May be specified more than once.',
|
|
213
|
+
reloadable: true,
|
|
234
214
|
},
|
|
235
215
|
config: {
|
|
236
216
|
type: 'string',
|
|
237
217
|
describe: 'Path to JSON configuration file.',
|
|
218
|
+
coerce: (configPath) => {
|
|
219
|
+
if (!configPath) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
return path.resolve(configPath);
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
watchConfig: {
|
|
226
|
+
type: 'boolean',
|
|
227
|
+
default: false,
|
|
228
|
+
describe: 'Watch the config file for changes and apply them without restarting. Tools (except --categoryExtensions) are enabled, disabled and updated on the fly; options used to launch or connect to the browser still require a restart.',
|
|
238
229
|
},
|
|
239
230
|
};
|
|
240
|
-
export
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
...mcpOptions,
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
231
|
+
export const mcpOptionsForViaCli = {
|
|
232
|
+
...mcpOptions,
|
|
233
|
+
headless: {
|
|
234
|
+
...mcpOptions.headless,
|
|
235
|
+
default: true,
|
|
236
|
+
},
|
|
237
|
+
memoryDebugging: {
|
|
238
|
+
...mcpOptions.memoryDebugging,
|
|
239
|
+
default: true,
|
|
240
|
+
},
|
|
241
|
+
categoryExtensions: {
|
|
242
|
+
...mcpOptions.categoryExtensions,
|
|
243
|
+
defaultDescription: 'true unless autoConnect, browserUrl or wsEndpoint is set',
|
|
244
|
+
},
|
|
245
|
+
experimentalStructuredContent: {
|
|
246
|
+
...mcpOptions.experimentalStructuredContent,
|
|
247
|
+
default: true,
|
|
248
|
+
},
|
|
249
|
+
isolated: {
|
|
250
|
+
...mcpOptions.isolated,
|
|
251
|
+
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.',
|
|
252
|
+
defaultDescription: 'true unless userDataDir, autoConnect, browserUrl or wsEndpoint is set',
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
export function getCliOptions() {
|
|
256
|
+
const options = withoutDefaults(mcpOptionsForViaCli);
|
|
257
|
+
// Missing CLI serialization.
|
|
258
|
+
delete options.viewport;
|
|
259
|
+
// The CLI is generated for the full mode with pageId routing, not slim mode.
|
|
260
|
+
delete options.slim;
|
|
261
|
+
delete options.pageIdRouting;
|
|
262
|
+
// Change the defaults for the CLI.
|
|
263
|
+
delete options.experimentalStructuredContent;
|
|
264
|
+
delete options.experimentalInteropTools;
|
|
265
|
+
return options;
|
|
273
266
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
'
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
267
|
+
export const CLI_EXAMPLES = [
|
|
268
|
+
[
|
|
269
|
+
'$0 --browserUrl http://127.0.0.1:9222',
|
|
270
|
+
'Connect to an existing browser instance via HTTP',
|
|
271
|
+
],
|
|
272
|
+
[
|
|
273
|
+
'$0 --wsEndpoint ws://127.0.0.1:9222/devtools/browser/abc123',
|
|
274
|
+
'Connect to an existing browser instance via WebSocket',
|
|
275
|
+
],
|
|
276
|
+
[
|
|
277
|
+
`$0 --wsEndpoint ws://127.0.0.1:9222/devtools/browser/abc123 --wsHeaders '{"Authorization":"Bearer token"}'`,
|
|
278
|
+
'Connect via WebSocket with custom headers',
|
|
279
|
+
],
|
|
280
|
+
['$0 --channel beta', 'Use Chrome Beta installed on this system'],
|
|
281
|
+
['$0 --channel canary', 'Use Chrome Canary installed on this system'],
|
|
282
|
+
['$0 --channel dev', 'Use Chrome Dev installed on this system'],
|
|
283
|
+
['$0 --channel stable', 'Use stable Chrome installed on this system'],
|
|
284
|
+
['$0 --logFile /tmp/log.txt', 'Save logs to a file'],
|
|
285
|
+
['$0 --help', 'Print CLI options'],
|
|
286
|
+
[
|
|
287
|
+
'$0 --viewport 1280x720',
|
|
288
|
+
'Launch Chrome with the initial viewport size of 1280x720px',
|
|
289
|
+
],
|
|
290
|
+
[
|
|
291
|
+
`$0 --chrome-arg='--no-sandbox' --chrome-arg='--disable-setuid-sandbox'`,
|
|
292
|
+
'Launch Chrome without sandboxes. Use with caution.',
|
|
293
|
+
],
|
|
294
|
+
[
|
|
295
|
+
`$0 --ignore-default-chrome-arg='--disable-extensions'`,
|
|
296
|
+
'Disable the default arguments provided by Puppeteer. Use with caution.',
|
|
297
|
+
],
|
|
298
|
+
['$0 --no-category-emulation', 'Disable tools in the emulation category'],
|
|
299
|
+
['$0 --no-category-performance', 'Disable tools in the performance category'],
|
|
300
|
+
['$0 --no-category-network', 'Disable tools in the network category'],
|
|
301
|
+
['$0 --user-data-dir=/tmp/user-data-dir', 'Use a custom user data directory'],
|
|
302
|
+
[
|
|
303
|
+
'$0 --auto-connect',
|
|
304
|
+
'Connect to a stable Chrome instance (Chrome 144+) running instead of launching a new instance',
|
|
305
|
+
],
|
|
306
|
+
[
|
|
307
|
+
'$0 --auto-connect --channel=canary',
|
|
308
|
+
'Connect to a canary Chrome instance (Chrome 144+) running instead of launching a new instance',
|
|
309
|
+
],
|
|
310
|
+
[
|
|
311
|
+
'$0 --no-usage-statistics',
|
|
312
|
+
'Do not send usage statistics https://github.com/ChromeDevTools/chrome-devtools-mcp#usage-statistics.',
|
|
313
|
+
],
|
|
314
|
+
[
|
|
315
|
+
'$0 --no-performance-crux',
|
|
316
|
+
'Disable CrUX (field data) integration in performance tools.',
|
|
317
|
+
],
|
|
318
|
+
['$0 --no-source-maps', 'Disable source maps in DevTools.'],
|
|
319
|
+
[
|
|
320
|
+
'$0 --no-javascript-evaluation',
|
|
321
|
+
'Disable server JavaScript evaluation entry points (evaluation tools, initScript in navigate_page, and navigating to javascript:, data:, or vbscript: URLs). Page scripts still run.',
|
|
322
|
+
],
|
|
323
|
+
[
|
|
324
|
+
'$0 --slim',
|
|
325
|
+
'Only 3 tools: navigation, JavaScript execution and screenshot',
|
|
326
|
+
],
|
|
327
|
+
];
|
|
328
|
+
export const CONFLICTING_ARGS = [
|
|
329
|
+
['channel', 'executablePath', 'browserUrl', 'wsEndpoint'],
|
|
330
|
+
['userDataDir', 'browserUrl', 'wsEndpoint'],
|
|
331
|
+
['userDataDir', 'isolated'],
|
|
332
|
+
['autoConnect', 'isolated'],
|
|
333
|
+
['autoConnect', 'executablePath'],
|
|
334
|
+
['blockedUrlPattern', 'allowedUrlPattern'],
|
|
335
|
+
['allowUnrestrictedPaths', 'filesystemRoot'],
|
|
336
|
+
['categoryPwa', 'autoConnect'],
|
|
337
|
+
['categoryPwa', 'browserUrl', 'wsEndpoint'],
|
|
338
|
+
];
|
|
339
|
+
export const IMPLICATIONS = [
|
|
340
|
+
['wsHeaders', 'wsEndpoint'],
|
|
341
|
+
['experimentalFfmpegPath', 'experimentalScreencast'],
|
|
342
|
+
];
|
|
343
|
+
export function withoutDefaults(options) {
|
|
344
|
+
const result = {};
|
|
345
|
+
for (const [key, option] of Object.entries(options)) {
|
|
346
|
+
const copy = { ...option };
|
|
347
|
+
if (copy.default !== undefined) {
|
|
348
|
+
copy.defaultDescription ??= JSON.stringify(copy.default);
|
|
349
|
+
delete copy.default;
|
|
305
350
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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}`);
|
|
408
|
-
}
|
|
409
|
-
})
|
|
410
|
-
.wrap(Math.min(120, yargsInstance.terminalWidth()))
|
|
411
|
-
.help()
|
|
412
|
-
.version(version);
|
|
351
|
+
result[key] = copy;
|
|
352
|
+
}
|
|
353
|
+
return result;
|
|
354
|
+
}
|
|
355
|
+
export function stripYargsPositionalArgs(parsed) {
|
|
356
|
+
const copy = { ...parsed };
|
|
357
|
+
delete copy._;
|
|
358
|
+
delete copy.$0;
|
|
359
|
+
return copy;
|
|
413
360
|
}
|
|
414
|
-
export function
|
|
415
|
-
|
|
361
|
+
export function isReloadableOption(name) {
|
|
362
|
+
const option = mcpOptions[name];
|
|
363
|
+
return option.reloadable === true;
|
|
416
364
|
}
|
|
417
365
|
//# sourceMappingURL=mcp-options.js.map
|