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.
- package/build/src/BrowserManager.js +132 -13
- package/build/src/McpContext.js +188 -138
- package/build/src/McpPage.js +348 -96
- package/build/src/McpResponse.js +234 -76
- package/build/src/McpWorker.js +66 -0
- package/build/src/SlimMcpResponse.js +5 -1
- package/build/src/TextSnapshot.js +3 -2
- package/build/src/ToolHandler.js +80 -42
- package/build/src/bin/chrome-devtools-mcp-main.js +8 -7
- package/build/src/bin/chrome-devtools-mcp.js +1 -1
- package/build/src/bin/chrome-devtools.js +31 -41
- package/build/src/collectors/ServiceWorkerCollector.js +18 -11
- package/build/src/config/ConfigLocator.js +70 -0
- package/build/src/config/ConfigParser.js +264 -0
- package/build/src/config/ConfigWatcher.js +93 -0
- package/build/src/config/browser-options.js +2 -13
- 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 +410 -43
- package/build/src/config/mcp-options.js +156 -234
- package/build/src/config/puppeteer-options.js +65 -0
- package/build/src/config/tool-options.js +60 -0
- package/build/src/daemon/client.js +81 -41
- package/build/src/daemon/daemon.js +55 -45
- package/build/src/daemon/utils.js +44 -11
- package/build/src/devtools/DevToolsCommentBridge.js +43 -6
- package/build/src/devtools/DevtoolsUtils.js +3 -3
- package/build/src/devtools/McpHostBindingAdapter.js +0 -1
- package/build/src/formatters/CommentFormatter.js +4 -13
- package/build/src/formatters/ConsoleFormatter.js +1 -1
- package/build/src/formatters/CssFormatter.js +3 -2
- package/build/src/formatters/HeapSnapshotFormatter.js +104 -46
- package/build/src/formatters/IssueFormatter.js +33 -32
- package/build/src/formatters/NetworkFormatter.js +12 -11
- package/build/src/formatters/SnapshotFormatter.js +31 -4
- package/build/src/index.js +54 -9
- package/build/src/processors/ChunkedTraceParser.js +11 -11
- package/build/src/processors/HeapSnapshotManager.js +121 -84
- 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 +10 -397
- package/build/src/third_party/bundled-packages.json +7 -8
- package/build/src/third_party/devtools-formatter-worker.js +1193 -62
- package/build/src/third_party/devtools-heap-snapshot-worker.js +1126 -21
- package/build/src/third_party/index.js +8087 -19419
- 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 +3 -3
- package/build/src/tools/ToolDefinition.js +16 -4
- package/build/src/tools/comments.js +20 -1
- package/build/src/tools/css.js +4 -2
- package/build/src/tools/emulation.js +17 -4
- package/build/src/tools/input.js +8 -3
- package/build/src/tools/lighthouse.js +112 -4
- package/build/src/tools/memory.js +129 -28
- package/build/src/tools/pages.js +5 -2
- package/build/src/tools/performance.js +21 -3
- package/build/src/tools/screencast.js +71 -32
- package/build/src/tools/screenshot.js +29 -14
- package/build/src/tools/script.js +90 -37
- package/build/src/tools/slim/tools.js +6 -8
- package/build/src/tools/thirdPartyDeveloper.js +6 -4
- package/build/src/tools/tools.js +35 -22
- package/build/src/tools/webmcp.js +9 -6
- package/build/src/types.js +11 -0
- package/build/src/utils/WaitForHelper.js +14 -1
- package/build/src/utils/check-for-updates.js +1 -1
- package/build/src/utils/errorHandling.js +20 -0
- package/build/src/utils/logger.js +15 -5
- package/build/src/utils/text.js +15 -0
- package/build/src/utils/url.js +99 -3
- package/build/src/version.js +1 -1
- package/package.json +14 -10
- package/skills/a11y-debugging/SKILL.md +4 -4
- 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
package/build/src/utils/url.js
CHANGED
|
@@ -83,17 +83,110 @@ export function isAllowedUrl(url, options) {
|
|
|
83
83
|
return true;
|
|
84
84
|
}
|
|
85
85
|
const DISALLOWED_PROTOCOLS = new Set(['javascript:', 'data:', 'vbscript:']);
|
|
86
|
+
/**
|
|
87
|
+
* Checks whether a compiled URLPattern component contains an unescaped `:`
|
|
88
|
+
* (which always represents a `:name` group in URLPattern syntax).
|
|
89
|
+
*/
|
|
90
|
+
function hasNamedGroup(component) {
|
|
91
|
+
return component.replaceAll('\\\\', '').replaceAll('\\:', '').includes(':');
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Checks whether a URLPattern string has a partial IPv4 wildcard in the
|
|
95
|
+
* hostname (for example `127.0.0.*`, `*.0.0.1`, `*1*`, or `{127.0.0.*}`),
|
|
96
|
+
* which Chrome cannot enforce on redirects or subresources.
|
|
97
|
+
*/
|
|
98
|
+
function hasPartialIpv4Hostname(pattern) {
|
|
99
|
+
const authority = /:\/\/([^/?#]+)/.exec(pattern)?.[1] ?? '';
|
|
100
|
+
const hostPort = authority.slice(authority.lastIndexOf('@') + 1);
|
|
101
|
+
if (hostPort.startsWith('[')) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
const hostname = hostPort.replace(/:.*$/, '');
|
|
105
|
+
if (!hostname.includes('*')) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
const stripped = hostname.replaceAll(/[{}*\\]/g, '').replace(/\.+$/, '');
|
|
109
|
+
const lastLabel = stripped.split('.').at(-1) ?? '';
|
|
110
|
+
return /^(?:\d+|0[xX][0-9a-fA-F]*)$/.test(lastLabel);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Validates that every pattern can be enforced by Chrome on redirects and subresources:
|
|
114
|
+
* - Rejects patterns with a partial IPv4 wildcard in the hostname (for example `127.0.0.*`).
|
|
115
|
+
* - Rejects patterns containing a regexp group (for example `(foo|bar)`).
|
|
116
|
+
* - Rejects patterns containing a named group (`:name`, for example `*://127.0.0.1::port/path`).
|
|
117
|
+
*
|
|
118
|
+
* @param patterns The `--blockedUrlPattern`/`--allowedUrlPattern` values to check.
|
|
119
|
+
* @param flagName The CLI flag name used in error messages.
|
|
120
|
+
* @throws Error if a pattern's syntax is invalid (via `new URLPattern`) or uses an unenforceable construct.
|
|
121
|
+
*/
|
|
122
|
+
export function validateUrlPatterns(patterns, flagName) {
|
|
123
|
+
for (const raw of patterns) {
|
|
124
|
+
if (hasPartialIpv4Hostname(raw)) {
|
|
125
|
+
throw new Error(`Invalid ${flagName} "${raw}": a partial IPv4 wildcard is not enforced on redirects or subresources. Use an exact IPv4 address or a "*" wildcard instead.`);
|
|
126
|
+
}
|
|
127
|
+
let parsed;
|
|
128
|
+
try {
|
|
129
|
+
parsed = new URLPattern(raw);
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
133
|
+
throw new Error(`Invalid ${flagName} "${raw}": ${message}`, {
|
|
134
|
+
cause: error,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if (parsed.hasRegExpGroups) {
|
|
138
|
+
throw new Error(`Invalid ${flagName} "${raw}": a regexp group is not enforced on redirects or subresources. Use an exact value or a "*" wildcard instead.`);
|
|
139
|
+
}
|
|
140
|
+
const components = [
|
|
141
|
+
parsed.protocol,
|
|
142
|
+
parsed.username,
|
|
143
|
+
parsed.password,
|
|
144
|
+
parsed.hostname,
|
|
145
|
+
parsed.port,
|
|
146
|
+
parsed.pathname,
|
|
147
|
+
parsed.search,
|
|
148
|
+
parsed.hash,
|
|
149
|
+
];
|
|
150
|
+
if (components.some(hasNamedGroup)) {
|
|
151
|
+
throw new Error(`Invalid ${flagName} "${raw}": a ":name" named group is not enforced on redirects or subresources. Use an exact value or a "*" wildcard instead.`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Reports whether a URL ultimately targets the `file:` scheme.
|
|
157
|
+
*
|
|
158
|
+
* `view-source:` wraps another URL and Chrome resolves the inner target, so
|
|
159
|
+
* `view-source:file:///etc/passwd` reads the file just as `file:///etc/passwd`
|
|
160
|
+
* does. The inner URL is re-parsed rather than string-matched so that an
|
|
161
|
+
* uppercase inner scheme (`view-source:FILE:///etc/passwd`) is normalised.
|
|
162
|
+
*
|
|
163
|
+
* @param url The already-parsed URL to inspect.
|
|
164
|
+
* @returns true if the URL, after unwrapping any `view-source:` prefixes, uses `file:`.
|
|
165
|
+
*/
|
|
166
|
+
function targetsFileScheme(url) {
|
|
167
|
+
let current = url;
|
|
168
|
+
// Bounded in case of a pathologically nested `view-source:` chain.
|
|
169
|
+
for (let i = 0; i < 5 && current.protocol === 'view-source:'; i++) {
|
|
170
|
+
try {
|
|
171
|
+
current = new URL(current.pathname);
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return current.protocol === 'file:';
|
|
178
|
+
}
|
|
86
179
|
/**
|
|
87
180
|
* Validates a URL string by parsing it with `new URL` and checking for disallowed protocols and restricted schemes.
|
|
88
181
|
*
|
|
89
182
|
* @param url The URL string to validate.
|
|
90
|
-
* @param options Options object containing javascriptEvaluation and
|
|
183
|
+
* @param options Options object containing javascriptEvaluation, categoryExtensions and fileNavigations.
|
|
91
184
|
* @returns The parsed URL.
|
|
92
185
|
* @throws Error if the URL does not parse with `new URL`, or if JavaScript evaluation is disabled and a disallowed URL is passed,
|
|
93
|
-
* or if navigating to a restricted scheme.
|
|
186
|
+
* or if file navigations are disabled and a `file:` URL is passed, or if navigating to a restricted scheme.
|
|
94
187
|
*/
|
|
95
188
|
export function validateUrl(url, options) {
|
|
96
|
-
const { javascriptEvaluation, categoryExtensions } = options;
|
|
189
|
+
const { javascriptEvaluation, categoryExtensions, fileNavigations } = options;
|
|
97
190
|
let parsed;
|
|
98
191
|
try {
|
|
99
192
|
parsed = new URL(url);
|
|
@@ -105,6 +198,9 @@ export function validateUrl(url, options) {
|
|
|
105
198
|
DISALLOWED_PROTOCOLS.has(parsed.protocol)) {
|
|
106
199
|
throw new Error(`Navigating to ${parsed.protocol} URLs is not allowed when JavaScript evaluation is disabled.`);
|
|
107
200
|
}
|
|
201
|
+
if (fileNavigations === false && targetsFileScheme(parsed)) {
|
|
202
|
+
throw new Error(`Navigating to file: URLs is not allowed when --file-navigations is disabled.`);
|
|
203
|
+
}
|
|
108
204
|
if (!isAllowedUrl(url, { categoryExtensions })) {
|
|
109
205
|
if (parsed.protocol === 'chrome-extension:') {
|
|
110
206
|
throw new Error(`Navigating to chrome-extension: URLs is not allowed without --categoryExtensions.`);
|
package/build/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chrome-devtools-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "MCP server for Chrome DevTools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"cli:generate": "node scripts/generate-cli.ts",
|
|
13
13
|
"clean": "node -e \"require('fs').rmSync('build', {recursive: true, force: true})\"",
|
|
14
|
+
"clean:submodules": "node scripts/clean-submodules.ts",
|
|
14
15
|
"bundle": "npm run clean && npm run build && rollup -c rollup.config.js && node -e \"require('fs').rmSync('build/node_modules', {recursive: true, force: true})\" && node scripts/append-lighthouse-notices.ts",
|
|
15
16
|
"build": "tsc && node scripts/post-build.ts",
|
|
16
17
|
"typecheck": "tsc --noEmit",
|
|
@@ -54,11 +55,10 @@
|
|
|
54
55
|
"mcpName": "io.github.ChromeDevTools/chrome-devtools-mcp",
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@blackwell-systems/gcf": "^2.2.2",
|
|
57
|
-
"@eslint/js": "^10.0.1",
|
|
58
58
|
"@google/genai": "^2.0.1",
|
|
59
|
-
"@modelcontextprotocol/client": "2.
|
|
60
|
-
"@modelcontextprotocol/core": "2.
|
|
61
|
-
"@modelcontextprotocol/server": "2.
|
|
59
|
+
"@modelcontextprotocol/client": "2.3.1",
|
|
60
|
+
"@modelcontextprotocol/core": "2.3.1",
|
|
61
|
+
"@modelcontextprotocol/server": "2.3.1",
|
|
62
62
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
63
63
|
"@rollup/plugin-json": "^6.1.0",
|
|
64
64
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
@@ -71,22 +71,26 @@
|
|
|
71
71
|
"@types/yargs": "^17.0.33",
|
|
72
72
|
"@typescript-eslint/eslint-plugin": "^8.43.0",
|
|
73
73
|
"@typescript-eslint/parser": "^8.43.0",
|
|
74
|
+
"@typescript/native": "npm:typescript@^7.0.2",
|
|
74
75
|
"core-js": "3.50.0",
|
|
75
76
|
"eslint": "^10.7.0",
|
|
76
77
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
78
|
+
"eslint-plugin-eslint-plugin": "^7.6.2",
|
|
77
79
|
"eslint-plugin-import": "^2.32.0",
|
|
80
|
+
"eslint-plugin-jsdoc": "^65.2.0",
|
|
81
|
+
"eslint-plugin-mocha": "^12.0.2",
|
|
78
82
|
"globals": "^17.0.0",
|
|
79
|
-
"lighthouse": "13.
|
|
83
|
+
"lighthouse": "13.5.0",
|
|
80
84
|
"prettier": "^3.6.2",
|
|
81
|
-
"puppeteer": "25.
|
|
82
|
-
"rollup": "4.
|
|
85
|
+
"puppeteer": "25.14.0",
|
|
86
|
+
"rollup": "4.64.2",
|
|
83
87
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
84
88
|
"rollup-plugin-license": "^3.6.0",
|
|
85
89
|
"semver": "^7.7.4",
|
|
86
90
|
"sinon": "^22.0.0",
|
|
87
|
-
"typescript": "
|
|
91
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
88
92
|
"typescript-eslint": "^8.43.0",
|
|
89
|
-
"yargs": "18.
|
|
93
|
+
"yargs": "18.2.0",
|
|
90
94
|
"zod": "^4.4.3"
|
|
91
95
|
},
|
|
92
96
|
"peerDependencies": {
|
|
@@ -19,15 +19,15 @@ Start by running a Lighthouse accessibility audit to get a comprehensive baselin
|
|
|
19
19
|
|
|
20
20
|
1. Run the audit:
|
|
21
21
|
- Set `mode` to `"navigation"` to refresh the page and capture load issues.
|
|
22
|
-
-
|
|
22
|
+
- Omit `outputDirPath` to save reports to the default temporary directory (the exact path to `report.json` is returned under `Reports`), or set `outputDirPath` to a directory within the workspace.
|
|
23
23
|
2. **Analyze the Summary**:
|
|
24
24
|
- Check `scores` (0-1 scale). A score < 1 indicates violations.
|
|
25
25
|
- Review `audits.failed` count.
|
|
26
26
|
3. **Review the Report (CRITICAL)**:
|
|
27
|
-
- **Parsing**: Do not read the entire file line-by-line. Use a CLI tool like `jq` or a Node.js one-liner to filter for failures
|
|
27
|
+
- **Parsing**: Do not read the entire file line-by-line. Use a CLI tool like `jq` or a Node.js one-liner to filter for failures from the report path returned by `lighthouse_audit`:
|
|
28
28
|
```bash
|
|
29
|
-
# Extract failing audits with their details
|
|
30
|
-
node -e "const r=require('
|
|
29
|
+
# Extract failing audits with their details (replace with report.json path from tool response)
|
|
30
|
+
node -e "const r=require('<path/to/report.json>'); Object.values(r.audits).filter(a=>a.score!==null && a.score<1).forEach(a=>console.log(JSON.stringify({id:a.id, title:a.title, items:a.details?.items})))"
|
|
31
31
|
```
|
|
32
32
|
- This efficiently extracts the `selector` and `snippet` of failing elements without loading the full report into context.
|
|
33
33
|
|
|
@@ -34,8 +34,8 @@ Note: For `evaluate_script`, `pageId` is required when targeting pages. However,
|
|
|
34
34
|
|
|
35
35
|
- **Automation/interaction**: `take_snapshot` (text-based, faster, better for automation)
|
|
36
36
|
- **Visual inspection**: `take_screenshot` (when user needs to see visual state)
|
|
37
|
-
- **CSS & Styling inspection**: Use `get_css_styles` to inspect matched rules, cascade, and CSS variables.
|
|
38
|
-
- **Additional details**: Use `evaluate_script` for
|
|
37
|
+
- **CSS & Styling inspection**: Use `get_css_styles` to inspect matched rules, cascade, and CSS variables. Treat the output as authoritative and complete.
|
|
38
|
+
- **Additional details**: Use `evaluate_script` for runtime DOM/JS data not available via `get_css_styles` or `take_snapshot`.
|
|
39
39
|
|
|
40
40
|
### Parallel execution
|
|
41
41
|
|
|
@@ -66,7 +66,7 @@ chrome-devtools list_pages # Get a list of pages open in the browser
|
|
|
66
66
|
chrome-devtools navigate_page 1 --url "https://example.com" # Navigates the currently selected page to a URL
|
|
67
67
|
chrome-devtools navigate_page 1 --type "reload" --ignoreCache true # Reload page ignoring cache
|
|
68
68
|
chrome-devtools navigate_page 1 --url "https://example.com" --timeout 5000 # Navigate with a timeout
|
|
69
|
-
chrome-devtools navigate_page 1 --handleBeforeUnload "accept" # Handle before unload dialog
|
|
69
|
+
chrome-devtools navigate_page 1 --type "reload" --handleBeforeUnload "accept" # Handle before unload dialog
|
|
70
70
|
chrome-devtools navigate_page 1 --type "back" --initScript "foo()" # Navigate back and run an init script
|
|
71
71
|
chrome-devtools new_page "https://example.com" # Creates a new page
|
|
72
72
|
chrome-devtools new_page "https://example.com" --background true --timeout 5000 # Create new page in background
|
|
@@ -77,18 +77,20 @@ chrome-devtools select_page 1 --bringToFront true # Select a page and bring it t
|
|
|
77
77
|
|
|
78
78
|
## Emulation
|
|
79
79
|
|
|
80
|
+
Each `emulate` call replaces all previously configured emulation settings (except `--extraHttpHeaders`), so pass all desired settings in a single call.
|
|
81
|
+
|
|
80
82
|
```bash
|
|
81
|
-
chrome-devtools emulate 1 --networkConditions "Offline" # Emulate network conditions
|
|
82
|
-
chrome-devtools emulate 1 --cpuThrottlingRate 4 --geolocation "
|
|
83
|
-
chrome-devtools emulate 1 --colorScheme "dark" --viewport "1920x1080" # Emulate color scheme and viewport
|
|
84
|
-
chrome-devtools emulate 1 --userAgent "Mozilla/5.0..." # Emulate user agent
|
|
83
|
+
chrome-devtools emulate 1 --networkConditions "Offline" # Emulate network conditions (resets other settings)
|
|
84
|
+
chrome-devtools emulate 1 --cpuThrottlingRate 4 --geolocation "0,0" # Emulate CPU throttling and geolocation (resets other settings)
|
|
85
|
+
chrome-devtools emulate 1 --colorScheme "dark" --viewport "1920x1080" # Emulate color scheme and viewport (resets other settings)
|
|
86
|
+
chrome-devtools emulate 1 --userAgent "Mozilla/5.0..." # Emulate user agent (resets other settings)
|
|
85
87
|
chrome-devtools resize_page 1 1920 1080 # Resizes the selected page's window
|
|
86
88
|
```
|
|
87
89
|
|
|
88
90
|
## Performance
|
|
89
91
|
|
|
90
92
|
```bash
|
|
91
|
-
chrome-devtools performance_analyze_insight 1 "
|
|
93
|
+
chrome-devtools performance_analyze_insight 1 "NAVIGATION_0" "LCPBreakdown" # Get more details on a specific Performance Insight (pageId, insightSetId, insightName)
|
|
92
94
|
chrome-devtools performance_start_trace 1 --reload true --autoStop false # Starts a performance trace recording (reload, autoStop)
|
|
93
95
|
chrome-devtools performance_start_trace 1 --reload true --autoStop true --filePath "t.json.gz" # Start trace and save to a file
|
|
94
96
|
chrome-devtools performance_stop_trace 1 # Stops the active performance trace
|
|
@@ -106,8 +108,8 @@ chrome-devtools take_heapsnapshot 1 "./snap.heapsnapshot" # Capture a memory hea
|
|
|
106
108
|
```bash
|
|
107
109
|
chrome-devtools get_heapsnapshot_summary "./snap.heapsnapshot" # Get snapshot summary stats
|
|
108
110
|
chrome-devtools compare_heapsnapshots "./base.heapsnapshot" "./target.heapsnapshot" # Compare two snapshots
|
|
109
|
-
chrome-devtools
|
|
110
|
-
chrome-devtools
|
|
111
|
+
chrome-devtools get_heapsnapshot_details "./snap.heapsnapshot" # Snapshot statistics and per-class aggregates (with class IDs)
|
|
112
|
+
chrome-devtools get_heapsnapshot_class_nodes "./snap.heapsnapshot" 18 # Inspect instances of a class (class ID from get_heapsnapshot_details)
|
|
111
113
|
chrome-devtools get_heapsnapshot_dominators "./snap.heapsnapshot" 123 # Dominator tree for node
|
|
112
114
|
chrome-devtools get_heapsnapshot_duplicate_strings "./snap.heapsnapshot" # Find duplicated strings
|
|
113
115
|
chrome-devtools get_heapsnapshot_edges "./snap.heapsnapshot" 123 # Node edges/references
|
|
@@ -122,10 +124,10 @@ chrome-devtools close_heapsnapshot "./snap.heapsnapshot" # Free memory from load
|
|
|
122
124
|
```bash
|
|
123
125
|
chrome-devtools get_network_request 1 # Get the currently selected network request for page 1
|
|
124
126
|
chrome-devtools get_network_request 1 --reqid 1 --requestFilePath "req.md" # Get request by id and save to file
|
|
125
|
-
chrome-devtools get_network_request 1 --responseFilePath "res.md" # Save response body to file
|
|
127
|
+
chrome-devtools get_network_request 1 --reqid 1 --responseFilePath "res.md" # Save response body to file
|
|
126
128
|
chrome-devtools list_network_requests 1 # List all network requests for page 1
|
|
127
129
|
chrome-devtools list_network_requests 1 --pageSize 50 --pageIdx 0 # List network requests with pagination
|
|
128
|
-
chrome-devtools list_network_requests 1 --resourceTypes
|
|
130
|
+
chrome-devtools list_network_requests 1 --resourceTypes fetch # Filter requests by resource type
|
|
129
131
|
chrome-devtools list_network_requests 1 --includePreservedRequests true # Include preserved requests
|
|
130
132
|
```
|
|
131
133
|
|
|
@@ -134,9 +136,10 @@ chrome-devtools list_network_requests 1 --includePreservedRequests true # Includ
|
|
|
134
136
|
```bash
|
|
135
137
|
chrome-devtools evaluate_script "() => document.title" --pageId 1 # Evaluate a JavaScript function on page 1
|
|
136
138
|
chrome-devtools evaluate_script "(a) => a.innerText" --pageId 1 --args 1_4 # Evaluate JS with UID arguments on page 1
|
|
139
|
+
chrome-devtools evaluate_script --pageId 1 --sourcePath /path/to/script.js --format script # Evaluate a local classic JavaScript file on page 1
|
|
137
140
|
chrome-devtools get_console_message 1 1 # Gets a console message by its ID
|
|
138
|
-
chrome-devtools get_css_styles 1 "1_4" #
|
|
139
|
-
chrome-devtools get_css_styles 1 "1_4" --pageSize 20 --pageIdx
|
|
141
|
+
chrome-devtools get_css_styles 1 "1_4" # Get CSS styles with pagination on page 1 (default: 10 rules, pageIdx 0)
|
|
142
|
+
chrome-devtools get_css_styles 1 "1_4" --pageSize 20 --pageIdx 1 # Paginate CSS rules with custom page size and custom 0-based page index
|
|
140
143
|
chrome-devtools lighthouse_audit 1 --mode "navigation" # Run Lighthouse audit for navigation
|
|
141
144
|
chrome-devtools lighthouse_audit 1 --mode "snapshot" --device "mobile" # Run Lighthouse audit for a snapshot on mobile
|
|
142
145
|
chrome-devtools lighthouse_audit 1 --outputDirPath ./out # Run Lighthouse audit and save reports
|
|
@@ -149,6 +152,8 @@ chrome-devtools take_screenshot 1 --fullPage true --format "jpeg" --quality 80 #
|
|
|
149
152
|
chrome-devtools take_screenshot 1 --uid "id" --filePath "s.png" # Take a screenshot of an element
|
|
150
153
|
chrome-devtools take_snapshot 1 # Take a text snapshot of the page from the a11y tree
|
|
151
154
|
chrome-devtools take_snapshot 1 --verbose true --filePath "s.txt" # Take a verbose snapshot and save to file
|
|
155
|
+
chrome-devtools screencast_start 1 --filePath "screen.mp4" # Starts an mp4 screencast recording on page 1
|
|
156
|
+
chrome-devtools screencast_stop 1 # Stops the active screencast on page 1
|
|
152
157
|
```
|
|
153
158
|
|
|
154
159
|
## Extensions
|
|
@@ -164,7 +169,7 @@ chrome-devtools trigger_extension_action "extension_id" # Triggers the default a
|
|
|
164
169
|
## Progressive Web Apps (requires `--categoryPwa=true`)
|
|
165
170
|
|
|
166
171
|
```bash
|
|
167
|
-
chrome-devtools install_pwa "https://example.com/" # Install PWA by manifest ID
|
|
172
|
+
chrome-devtools install_pwa "https://example.com/" "https://example.com/" # Install PWA by manifest ID and install URL
|
|
168
173
|
chrome-devtools launch_pwa "https://example.com/" # Launch installed PWA
|
|
169
174
|
chrome-devtools get_os_app_state "https://example.com/" # Get OS app installation state
|
|
170
175
|
chrome-devtools uninstall_pwa "https://example.com/" # Uninstall PWA and close windows
|
|
@@ -176,8 +181,6 @@ Experimental tools are disabled by default. Enable them with the corresponding f
|
|
|
176
181
|
|
|
177
182
|
```bash
|
|
178
183
|
chrome-devtools click_at 1 100 200 # Clicks at the provided coordinates on page 1 (requires --experimentalVision=true)
|
|
179
|
-
chrome-devtools screencast_start 1 --filePath "screen.mp4" # Starts a screencast recording on page 1 (requires --experimentalScreencast=true and ffmpeg)
|
|
180
|
-
chrome-devtools screencast_stop 1 # Stops the active screencast on page 1
|
|
181
184
|
chrome-devtools list_webmcp_tools 1 # List all WebMCP tools on page 1 (requires --categoryExperimentalWebmcp=true)
|
|
182
185
|
chrome-devtools execute_webmcp_tool 1 "tool_name" --input '{"arg":"val"}' # Execute a WebMCP tool on page 1 (requires --categoryExperimentalWebmcp=true)
|
|
183
186
|
chrome-devtools list_3p_developer_tools 1 # List third-party developer tools on page 1 (requires --categoryExperimentalThirdParty=true)
|
|
@@ -5,6 +5,8 @@ description: Uses Chrome DevTools MCP for inspecting, debugging, and testing coo
|
|
|
5
5
|
|
|
6
6
|
## Core Concepts
|
|
7
7
|
|
|
8
|
+
**Page Targeting**: Page-scoped tools (`list_network_requests`, `get_network_request`, `list_console_messages`, `evaluate_script`, `navigate_page`, `take_snapshot`, `click`, `lighthouse_audit`, `close_page`, etc.) require a `pageId` parameter. Retrieve available page IDs using `list_pages` or from `new_page`.
|
|
9
|
+
|
|
8
10
|
### HttpOnly vs Client-Side Storage
|
|
9
11
|
|
|
10
12
|
Cookies marked `HttpOnly` cannot be accessed or modified by client-side JavaScript (`cookieStore` or `document.cookie`). However, the browser **automatically attaches active HttpOnly cookies to outgoing HTTP request headers (`Cookie`)**.
|
|
@@ -19,7 +21,7 @@ Choose the right session environment to avoid state contamination (e.g., residua
|
|
|
19
21
|
|
|
20
22
|
| Strategy | When to Use | Setup / Teardown |
|
|
21
23
|
| :---------------------------------- | :---------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------ |
|
|
22
|
-
| **Live Tab (Active Page)** | Diagnosing an active user session, live 401/403 error, or current state. | Operates
|
|
24
|
+
| **Live Tab (Active Page)** | Diagnosing an active user session, live 401/403 error, or current state. | Operates on the user's existing page; get its `pageId` from `list_pages`. |
|
|
23
25
|
| **Clean-Slate (`isolatedContext`)** | Testing cookie consent banners, first-time visits, or zero-cookie guarantees. | Call `new_page` with a unique `isolatedContext` (e.g. `"consent-audit-1"`). When finished, call `close_page`. |
|
|
24
26
|
|
|
25
27
|
### Client-Side Capabilities & Limitations
|
|
@@ -49,7 +51,7 @@ When an authenticated page request fails, returns 401/403, or redirects to login
|
|
|
49
51
|
- Verify if the `Cookie` header was attached and whether required tokens (e.g. `SESSION_ID`, `auth_token`) were sent.
|
|
50
52
|
4. **Trigger Active Inspection (If no recent request exists)**:
|
|
51
53
|
- If the cookie was set in a previous session and no network call is listed, trigger a request:
|
|
52
|
-
- Use `navigate_page` with `
|
|
54
|
+
- Use `navigate_page` with `type: "reload"`, OR
|
|
53
55
|
- Call `evaluate_script` with `() => fetch(window.location.href)`
|
|
54
56
|
- Then call `get_network_request` on the new request to inspect the active `Cookie` header.
|
|
55
57
|
5. **Trace the Setting Request**: If the cookie is missing or rejected:
|
|
@@ -91,6 +93,7 @@ To verify that no non-essential or tracking cookies are set before consent or wh
|
|
|
91
93
|
- Call `list_console_messages` with:
|
|
92
94
|
```json
|
|
93
95
|
{
|
|
96
|
+
"pageId": 1,
|
|
94
97
|
"types": ["issue"],
|
|
95
98
|
"includePreservedMessages": true
|
|
96
99
|
}
|
|
@@ -101,10 +104,10 @@ To verify that no non-essential or tracking cookies are set before consent or wh
|
|
|
101
104
|
- `SchemefulSameSite`: Cross-scheme cookie issues.
|
|
102
105
|
- `PartitionedCookies`: Invalid CHIPS partitioning attributes.
|
|
103
106
|
2. **Deep Audit: Lighthouse Third-Party Cookies**:
|
|
104
|
-
- Run `lighthouse_audit` with `mode: "navigation"`
|
|
105
|
-
- **Extract the specific cookie audit** without loading the full report into context:
|
|
107
|
+
- Run `lighthouse_audit` with `mode: "navigation"` (omit `outputDirPath` to use the default temporary files, or specify a directory within the workspace).
|
|
108
|
+
- **Extract the specific cookie audit** from the returned `report.json` path without loading the full report into context:
|
|
106
109
|
```bash
|
|
107
|
-
node -e "const r=require('/
|
|
110
|
+
node -e "const r=require('<path/to/report.json>'); const a=r.audits['third-party-cookies']; console.log(JSON.stringify({score: a?.score, displayValue: a?.displayValue, items: a?.details?.items}))"
|
|
108
111
|
```
|
|
109
112
|
|
|
110
113
|
### 4. Client-Side Cookie Inspection & Manipulation
|
|
@@ -62,7 +62,7 @@ The `url` field tells you what resource to look for in the network waterfall. If
|
|
|
62
62
|
|
|
63
63
|
Use `list_network_requests` to see when the LCP resource loaded relative to other resources:
|
|
64
64
|
|
|
65
|
-
- Call `list_network_requests` with `pageId` filtered by `resourceTypes: ["
|
|
65
|
+
- Call `list_network_requests` with `pageId` filtered by `resourceTypes: ["image", "font"]` (adjust based on Step 3).
|
|
66
66
|
- Then use `get_network_request` with `pageId` and the LCP resource's request ID for full details.
|
|
67
67
|
|
|
68
68
|
**Key Checks:**
|
|
@@ -9,7 +9,7 @@ You are acting as a troubleshooting wizard to help the user configure and fix th
|
|
|
9
9
|
|
|
10
10
|
### Step 1: Find and Read Configuration
|
|
11
11
|
|
|
12
|
-
Your first action should be to locate and read the MCP configuration file. Search for the following files in the user's workspace: `.mcp.json`, `gemini-extension.json`, `.
|
|
12
|
+
Your first action should be to locate and read the MCP configuration file. Search for the following files in the user's workspace: `.mcp.json`, `.vscode/mcp.json`, `gemini-extension.json`, or `.gemini/settings.json` (or user-scoped files such as `~/.claude.json` if accessible).
|
|
13
13
|
|
|
14
14
|
If you find a configuration file, read and interpret it to identify potential issues such as:
|
|
15
15
|
|
|
@@ -41,9 +41,9 @@ If the server starts successfully but `list_pages` returns an empty list or crea
|
|
|
41
41
|
- **Check for flag typos:** For example, `--autoBronnect` instead of `--autoConnect`.
|
|
42
42
|
- **Verify the configuration:** Ensure the arguments match the expected flags exactly.
|
|
43
43
|
|
|
44
|
-
#### Symptom: Missing Tools / Only
|
|
44
|
+
#### Symptom: Missing Tools / Only a few tools available
|
|
45
45
|
|
|
46
|
-
If the server starts successfully but only a limited subset of tools (like `list_pages`, `
|
|
46
|
+
If the server starts successfully but only a limited subset of tools (like `list_pages`, `list_console_messages`, `get_console_message`, `list_network_requests`) are available, this is likely because the MCP client is enforcing a **read-only mode**.
|
|
47
47
|
|
|
48
48
|
All tools in `chrome-devtools-mcp` are annotated with `readOnlyHint: true` (for safe, non-modifying tools) or `readOnlyHint: false` (for tools that modify browser state, like `emulate`, `click`, `navigate_page`). To access the full suite of tools, the user must disable read-only mode in their MCP client (e.g., by exiting "Plan Mode" in Gemini CLI or adjusting their client's tool safety settings).
|
|
49
49
|
|
|
@@ -52,14 +52,13 @@ All tools in `chrome-devtools-mcp` are annotated with `readOnlyHint: true` (for
|
|
|
52
52
|
If the tools related to extensions (like `install_extension`) are not available, or if the extensions you load are not functioning:
|
|
53
53
|
|
|
54
54
|
1. **Check for the `--categoryExtensions` flag**: Ensure this flag is passed in the MCP server configuration to enable the extension category tools.
|
|
55
|
-
2. **Make sure the MCP server in configured to launch Chrome instead of connecting to an instance**: Chrome before 149 is not able to load extensions when connecting to an existing instance (`--auto-connect`, `--browserUrl`).
|
|
56
55
|
|
|
57
56
|
#### Other Common Errors
|
|
58
57
|
|
|
59
58
|
Identify other error messages from the failed tool call or the MCP initialization logs:
|
|
60
59
|
|
|
61
60
|
- `Target closed`
|
|
62
|
-
- "Tool not found" (check if they are using `--slim` which only enables navigation and screenshot tools).
|
|
61
|
+
- "Tool not found" (check if they are using `--slim` which only enables navigation, script evaluation and screenshot tools).
|
|
63
62
|
- Missing `pageId`: Page-scoped tools require a `pageId` argument. Call `list_pages` to find active page IDs.
|
|
64
63
|
- `ProtocolError: Network.enable timed out` or `The socket connection was closed unexpectedly`
|
|
65
64
|
- `Error [ERR_MODULE_NOT_FOUND]: Cannot find module`
|
|
@@ -89,7 +88,7 @@ _If you are unsure of the user's configuration, ask the user to provide their cu
|
|
|
89
88
|
If the issue is still unclear, run diagnostic commands to test the server directly:
|
|
90
89
|
|
|
91
90
|
- Run `npx chrome-devtools-mcp@latest --help` to verify the installation and Node.js environment.
|
|
92
|
-
- If you need more information, run `
|
|
91
|
+
- If you need more information, run `NODE_DEBUG=* npx chrome-devtools-mcp@latest --logFile=/tmp/cdm-test.log` to capture verbose logs. Analyze the output for errors.
|
|
93
92
|
|
|
94
93
|
### Step 6: Check GitHub for Existing Issues
|
|
95
94
|
|