chrome-devtools-mcp 1.7.0 → 1.9.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 +20 -874
- package/build/src/McpContext.js +98 -45
- package/build/src/McpPage.js +10 -4
- package/build/src/McpResponse.js +22 -4
- package/build/src/ToolHandler.js +81 -57
- package/build/src/bin/chrome-devtools-mcp-main.js +4 -4
- package/build/src/bin/chrome-devtools.js +29 -30
- package/build/src/browser.js +8 -17
- package/build/src/{PageCollector.js → collectors/PageCollector.js} +7 -7
- package/build/src/{ServiceWorkerCollector.js → collectors/ServiceWorkerCollector.js} +1 -1
- package/build/src/config/browser-options.js +123 -0
- package/build/src/config/category-options.js +80 -0
- package/build/src/{bin/chrome-devtools-cli-options.js → config/cli-options.js} +380 -25
- package/build/src/{bin/chrome-devtools-mcp-cli-options.js → config/mcp-options.js} +113 -148
- package/build/src/daemon/client.js +11 -2
- package/build/src/daemon/daemon.js +2 -2
- package/build/src/daemon/utils.js +6 -0
- package/build/src/devtools/DevtoolsUtils.js +29 -35
- package/build/src/formatters/ConsoleFormatter.js +43 -10
- package/build/src/formatters/HeapSnapshotFormatter.js +10 -2
- package/build/src/formatters/IssueFormatter.js +1 -1
- package/build/src/formatters/NetworkFormatter.js +12 -9
- package/build/src/index.js +185 -91
- package/build/src/{HeapSnapshotManager.js → processors/HeapSnapshotManager.js} +21 -5
- package/build/src/{trace-processing/parse.js → processors/PerformanceTrace.js} +1 -1
- package/build/src/telemetry/ClearcutLogger.js +18 -5
- package/build/src/telemetry/flagUtils.js +4 -3
- package/build/src/telemetry/types.js +4 -0
- package/build/src/third_party/THIRD_PARTY_NOTICES +8 -65
- package/build/src/third_party/bundled-packages.json +4 -4
- package/build/src/third_party/devtools-formatter-worker.js +22 -0
- package/build/src/third_party/devtools-heap-snapshot-worker.js +296 -42
- package/build/src/third_party/index.js +38728 -37176
- package/build/src/third_party/issue-descriptions/connectionAllowlistEmbeddingRequirementNotSatisfied.md +26 -0
- package/build/src/third_party/issue-descriptions/connectionAllowlistIFrameAttributeLoosensEmbeddingRequirement.md +19 -0
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowConnectionAllowlistFrom.md +21 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsBlockedByConnectionAllowlist.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestConfigBlockedByConnectionAllowlist.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenBlockedByConnectionAllowlist.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestWellKnownBlockedByConnectionAllowlist.md +1 -0
- package/build/src/tools/ToolDefinition.js +15 -0
- package/build/src/tools/categories.js +2 -5
- package/build/src/tools/console.js +9 -3
- package/build/src/tools/emulation.js +2 -2
- package/build/src/tools/extensions.js +7 -5
- package/build/src/tools/input.js +26 -16
- package/build/src/tools/lighthouse.js +3 -1
- package/build/src/tools/memory.js +112 -16
- package/build/src/tools/network.js +7 -4
- package/build/src/tools/pages.js +34 -23
- package/build/src/tools/performance.js +16 -25
- package/build/src/tools/pwa.js +128 -0
- package/build/src/tools/screencast.js +7 -4
- package/build/src/tools/screenshot.js +42 -9
- package/build/src/tools/script.js +29 -8
- package/build/src/tools/slim/tools.js +43 -35
- package/build/src/tools/snapshot.js +5 -3
- package/build/src/tools/thirdPartyDeveloper.js +2 -2
- package/build/src/tools/tools.js +2 -0
- package/build/src/tools/webmcp.js +2 -2
- package/build/src/{WaitForHelper.js → utils/WaitForHelper.js} +74 -38
- package/build/src/utils/bytes.js +105 -0
- package/build/src/utils/logger.js +25 -11
- package/build/src/utils/url.js +73 -0
- package/build/src/version.js +1 -1
- package/package.json +21 -13
- package/skills/a11y-debugging/SKILL.md +2 -0
- package/skills/chrome-devtools/SKILL.md +5 -4
- package/skills/chrome-devtools-cli/SKILL.md +103 -64
- package/skills/cookie-debugging/SKILL.md +149 -0
- package/skills/debug-optimize-lcp/SKILL.md +9 -9
- package/skills/memory-leak-debugging/SKILL.md +6 -2
- package/skills/troubleshooting/SKILL.md +1 -0
- package/build/src/utils/string.js +0 -37
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chrome-devtools-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "MCP server for Chrome DevTools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"build": "tsc && node scripts/post-build.ts",
|
|
16
16
|
"typecheck": "tsc --noEmit",
|
|
17
17
|
"format": "eslint --cache --fix . && prettier --write --cache .",
|
|
18
|
-
"check-format": "eslint --cache . && prettier --check --cache
|
|
19
|
-
"gen": "npm run build && npm run
|
|
18
|
+
"check-format": "eslint --cache . && prettier --check --cache .",
|
|
19
|
+
"gen": "npm run build && npm run cli:generate && npm run docs:generate && npm run update-metrics && npm run format",
|
|
20
20
|
"docs:generate": "node scripts/generate-docs.ts",
|
|
21
21
|
"start": "npm run build && node build/src/bin/chrome-devtools-mcp.js",
|
|
22
|
-
"start-debug": "
|
|
22
|
+
"start-debug": "NODE_DEBUG=mcp:* npm run build && node build/src/bin/chrome-devtools-mcp.js",
|
|
23
23
|
"test": "npm run build && node scripts/test.js --test-skip-pattern=THIRD_PARTY_NOTICES",
|
|
24
24
|
"test:no-build": "node scripts/test.js --test-skip-pattern=THIRD_PARTY_NOTICES",
|
|
25
25
|
"test:notices": "npm run bundle && node scripts/test.js tests/third_party_notices.test.ts",
|
|
@@ -27,12 +27,15 @@
|
|
|
27
27
|
"test:only": "npm run build && node scripts/test.js --test-only",
|
|
28
28
|
"test:update-snapshots": "npm run build && node scripts/test.js --test-update-snapshots",
|
|
29
29
|
"prepare": "node scripts/prepare.ts",
|
|
30
|
+
"sync": "npm ci && git submodule update --init",
|
|
30
31
|
"verify-server-json-version": "node scripts/verify-server-json-version.ts",
|
|
31
32
|
"update-lighthouse": "node scripts/update-lighthouse.ts",
|
|
32
33
|
"update-metrics": "node scripts/update_metrics.ts",
|
|
33
34
|
"verify-npm-package": "node scripts/verify-npm-package.js",
|
|
34
35
|
"eval": "npm run build && node scripts/eval_gemini.ts",
|
|
35
|
-
"count-tokens": "node scripts/count_tokens.ts"
|
|
36
|
+
"count-tokens": "node scripts/count_tokens.ts",
|
|
37
|
+
"profile": "npm run build && node scripts/profile/profile_mcp.ts",
|
|
38
|
+
"test:memory": "npm run build && node scripts/profile/profile_mcp.ts --threshold-percentage 1"
|
|
36
39
|
},
|
|
37
40
|
"files": [
|
|
38
41
|
"build/src",
|
|
@@ -58,8 +61,7 @@
|
|
|
58
61
|
"@rollup/plugin-json": "^6.1.0",
|
|
59
62
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
60
63
|
"@stylistic/eslint-plugin": "^5.4.0",
|
|
61
|
-
"@toon-format/toon": "^
|
|
62
|
-
"@types/debug": "^4.1.12",
|
|
64
|
+
"@toon-format/toon": "^4.1.0",
|
|
63
65
|
"@types/filesystem": "^0.0.36",
|
|
64
66
|
"@types/node": "^26.0.0",
|
|
65
67
|
"@types/semver": "^7.7.1",
|
|
@@ -67,16 +69,15 @@
|
|
|
67
69
|
"@types/yargs": "^17.0.33",
|
|
68
70
|
"@typescript-eslint/eslint-plugin": "^8.43.0",
|
|
69
71
|
"@typescript-eslint/parser": "^8.43.0",
|
|
70
|
-
"core-js": "3.
|
|
71
|
-
"debug": "4.4.3",
|
|
72
|
+
"core-js": "3.50.0",
|
|
72
73
|
"eslint": "^10.7.0",
|
|
73
74
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
74
75
|
"eslint-plugin-import": "^2.32.0",
|
|
75
76
|
"globals": "^17.0.0",
|
|
76
|
-
"lighthouse": "13.4.
|
|
77
|
+
"lighthouse": "13.4.1",
|
|
77
78
|
"prettier": "^3.6.2",
|
|
78
|
-
"puppeteer": "25.
|
|
79
|
-
"rollup": "4.62.
|
|
79
|
+
"puppeteer": "25.10.0",
|
|
80
|
+
"rollup": "4.62.5",
|
|
80
81
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
81
82
|
"rollup-plugin-license": "^3.6.0",
|
|
82
83
|
"semver": "^7.7.4",
|
|
@@ -87,7 +88,7 @@
|
|
|
87
88
|
},
|
|
88
89
|
"peerDependencies": {
|
|
89
90
|
"@blackwell-systems/gcf": "^2.2.2",
|
|
90
|
-
"@toon-format/toon": "^
|
|
91
|
+
"@toon-format/toon": "^4.1.0"
|
|
91
92
|
},
|
|
92
93
|
"peerDependenciesMeta": {
|
|
93
94
|
"@toon-format/toon": {
|
|
@@ -105,5 +106,12 @@
|
|
|
105
106
|
"eslint": "$eslint"
|
|
106
107
|
},
|
|
107
108
|
"puppeteer-core": "$puppeteer"
|
|
109
|
+
},
|
|
110
|
+
"allowScripts": {
|
|
111
|
+
"core-js": false,
|
|
112
|
+
"@google/genai": false,
|
|
113
|
+
"protobufjs": false,
|
|
114
|
+
"unrs-resolver": false,
|
|
115
|
+
"puppeteer": true
|
|
108
116
|
}
|
|
109
117
|
}
|
|
@@ -5,6 +5,8 @@ description: Uses Chrome DevTools MCP for accessibility (a11y) debugging and aud
|
|
|
5
5
|
|
|
6
6
|
## Core Concepts
|
|
7
7
|
|
|
8
|
+
**Page Targeting**: Page-scoped tools (`take_snapshot`, `list_console_messages`, `evaluate_script`, `press_key`, `take_screenshot`, `lighthouse_audit`, etc.) require a `pageId` parameter. Retrieve available page IDs using `list_pages` or from `new_page`.
|
|
9
|
+
|
|
8
10
|
**Accessibility Tree vs DOM**: Visually hiding an element (e.g., `CSS opacity: 0`) behaves differently for screen readers than `display: none` or `aria-hidden="true"`. The `take_snapshot` tool returns the accessibility tree of the page, which represents what assistive technologies "see", making it the most reliable source of truth for semantic structure.
|
|
9
11
|
|
|
10
12
|
**Reading web.dev documentation**: If you need to research specific accessibility guidelines (like `https://web.dev/articles/accessible-tap-targets`), you can append `.md.txt` to the URL (e.g., `https://web.dev/articles/accessible-tap-targets.md.txt`) to fetch the clean, raw markdown version. This is much easier to read!
|
|
@@ -11,7 +11,8 @@ Addional tooling can be enabled by providing the following flags:
|
|
|
11
11
|
- For extension tooling, use the `--categoryExtensions` flag.
|
|
12
12
|
- For memory tooling, use the `--memoryDebugging` flag.
|
|
13
13
|
|
|
14
|
-
**Page
|
|
14
|
+
**Page targeting**: Page-scoped tools require a `pageId` parameter to target a specific page. Use `list_pages` to see available pages and their IDs (e.g. `pageId: 1`), or use the ID returned when creating a page with `new_page`.
|
|
15
|
+
Note: For `evaluate_script`, `pageId` is required when targeting pages. However, when `--categoryExtensions` is enabled, `pageId` is optional so you can pass `serviceWorkerId` instead to evaluate inside an extension background service worker.
|
|
15
16
|
**Element interaction**: Use `take_snapshot` to get page structure with element `uid`s. Each element has a unique `uid` for interaction. If an element isn't found, take a fresh snapshot - the element may have been removed or the page changed.
|
|
16
17
|
|
|
17
18
|
## Workflow Patterns
|
|
@@ -20,8 +21,8 @@ Addional tooling can be enabled by providing the following flags:
|
|
|
20
21
|
|
|
21
22
|
1. Navigate: `navigate_page` or `new_page`
|
|
22
23
|
2. Wait: `wait_for` to ensure content is loaded if you know what you look for.
|
|
23
|
-
3. Snapshot: `take_snapshot` to understand page structure
|
|
24
|
-
4. Interact: Use element `uid`s from snapshot for `click`, `fill`, etc
|
|
24
|
+
3. Snapshot: `take_snapshot` with `pageId` to understand page structure
|
|
25
|
+
4. Interact: Use element `uid`s from snapshot for `click`, `fill`, etc., passing the corresponding `pageId`.
|
|
25
26
|
|
|
26
27
|
### Efficient data retrieval
|
|
27
28
|
|
|
@@ -59,7 +60,7 @@ You can send multiple tool calls in parallel, but maintain correct order: naviga
|
|
|
59
60
|
1. **Install**: Use `install_extension` with the path to the unpacked extension.
|
|
60
61
|
2. **Identify**: Get the extension ID from the response or by calling `list_extensions`.
|
|
61
62
|
3. **Trigger Action**: Use `trigger_extension_action` to open the popup or side panel if applicable.
|
|
62
|
-
4. **Verify Service Worker**: Use `evaluate_script` with `serviceWorkerId` to check extension state or trigger background actions.
|
|
63
|
+
4. **Verify Service Worker**: Use `evaluate_script` with `serviceWorkerId` (omitting `pageId` and `args`) to check extension state or trigger background actions. When evaluating in a page, pass `pageId` (omitting `serviceWorkerId`).
|
|
63
64
|
5. **Verify Page Behavior**: Navigate to a page where the extension operates and use `take_snapshot` to check if content scripts injected elements or modified the page correctly.
|
|
64
65
|
|
|
65
66
|
## Troubleshooting
|
|
@@ -11,9 +11,9 @@ _Note: If this is your very first time using the CLI, see [references/installati
|
|
|
11
11
|
|
|
12
12
|
## AI Workflow
|
|
13
13
|
|
|
14
|
-
1. **Execute**: Run tools directly
|
|
15
|
-
2. **Inspect**: Use `take_snapshot
|
|
16
|
-
3. **Act**: Use `click
|
|
14
|
+
1. **Execute**: Run tools directly. If you don't know the target page's ID, run `chrome-devtools list_pages` to find it. The background server starts implicitly; **do not** run `start`/`status`/`stop` before each use.
|
|
15
|
+
2. **Inspect**: Use `chrome-devtools take_snapshot <pageId>` to get an element `<uid>`.
|
|
16
|
+
3. **Act**: Use `chrome-devtools click <pageId> <uid>`, `chrome-devtools fill <pageId> <uid> <value>`, etc. State persists across commands.
|
|
17
17
|
|
|
18
18
|
Snapshot example:
|
|
19
19
|
|
|
@@ -22,35 +22,40 @@ uid=1_0 RootWebArea "Example Domain" url="https://example.com/"
|
|
|
22
22
|
uid=1_1 heading "Example Domain" level="1"
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
## Permissions & File Access
|
|
26
|
+
|
|
27
|
+
By default, the CLI has full filesystem access (`--allowUnrestrictedPaths=true`), allowing file-saving parameters (`--filePath`, `--outputDirPath`) and `upload_file` to access files anywhere on the system. Pass `--allowUnrestrictedPaths=false` if you want to restrict file access to the OS temp directory.
|
|
28
|
+
|
|
25
29
|
## Command Usage
|
|
26
30
|
|
|
27
31
|
```sh
|
|
28
32
|
chrome-devtools <tool> [arguments] [flags]
|
|
29
33
|
```
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
- Required arguments are passed positionally; optional arguments use flags.
|
|
36
|
+
- Use `--help` on any command for usage details.
|
|
37
|
+
- Output defaults to plain Markdown-like text; pass `--output-format=json` for JSON.
|
|
32
38
|
|
|
33
39
|
## Input Automation (<uid> from snapshot)
|
|
34
40
|
|
|
35
41
|
```bash
|
|
36
|
-
chrome-devtools take_snapshot
|
|
37
|
-
chrome-devtools
|
|
38
|
-
chrome-devtools click "id" #
|
|
39
|
-
chrome-devtools
|
|
40
|
-
chrome-devtools drag "src" "dst" # Drag an element
|
|
41
|
-
chrome-devtools
|
|
42
|
-
chrome-devtools fill "id" "text"
|
|
43
|
-
chrome-devtools
|
|
44
|
-
chrome-devtools handle_dialog
|
|
45
|
-
chrome-devtools
|
|
46
|
-
chrome-devtools hover "id" # Hover over
|
|
47
|
-
chrome-devtools
|
|
48
|
-
chrome-devtools press_key "
|
|
49
|
-
chrome-devtools
|
|
50
|
-
chrome-devtools type_text "hello" # Type text
|
|
51
|
-
chrome-devtools
|
|
52
|
-
chrome-devtools upload_file "id" "file.txt" # Upload a file
|
|
53
|
-
chrome-devtools upload_file "id" "file.txt" --includeSnapshot true # Upload a file and return a snapshot
|
|
42
|
+
chrome-devtools take_snapshot 1 # Take a text snapshot of the page to get UIDs for elements
|
|
43
|
+
chrome-devtools click 1 "id" # Clicks on the provided element
|
|
44
|
+
chrome-devtools click 1 "id" --dblClick true --includeSnapshot true # Double clicks and returns a snapshot
|
|
45
|
+
chrome-devtools drag 1 "src" "dst" # Drag an element onto another element
|
|
46
|
+
chrome-devtools drag 1 "src" "dst" --includeSnapshot true # Drag an element and return a snapshot
|
|
47
|
+
chrome-devtools fill 1 "id" "text" # Type text into an input, textarea, or select an option
|
|
48
|
+
chrome-devtools fill 1 "id" "text" --includeSnapshot true # Fill an element and return a snapshot
|
|
49
|
+
chrome-devtools handle_dialog 1 accept # Handle a browser dialog (accept/dismiss)
|
|
50
|
+
chrome-devtools handle_dialog 1 dismiss --promptText "hi" # Dismiss a dialog with prompt text
|
|
51
|
+
chrome-devtools hover 1 "id" # Hover over the provided element
|
|
52
|
+
chrome-devtools hover 1 "id" --includeSnapshot true # Hover over an element and return a snapshot
|
|
53
|
+
chrome-devtools press_key 1 "Enter" # Press a key or key combination ("Control+A", "Escape")
|
|
54
|
+
chrome-devtools press_key 1 "Control+A" --includeSnapshot true # Press a key and return a snapshot
|
|
55
|
+
chrome-devtools type_text 1 "hello" # Type text using keyboard into a focused input
|
|
56
|
+
chrome-devtools type_text 1 "hello" --submitKey "Enter" # Type text and press a submit key
|
|
57
|
+
chrome-devtools upload_file 1 "id" "file.txt" # Upload a file through a provided element
|
|
58
|
+
chrome-devtools upload_file 1 "id" "file.txt" --includeSnapshot true # Upload a file and return a snapshot
|
|
54
59
|
```
|
|
55
60
|
|
|
56
61
|
## Navigation
|
|
@@ -58,11 +63,11 @@ chrome-devtools upload_file "id" "file.txt" --includeSnapshot true # Upload a fi
|
|
|
58
63
|
```bash
|
|
59
64
|
chrome-devtools close_page 1 # Closes the page by its index
|
|
60
65
|
chrome-devtools list_pages # Get a list of pages open in the browser
|
|
61
|
-
chrome-devtools navigate_page --url "https://example.com" # Navigates the currently selected page to a URL
|
|
62
|
-
chrome-devtools navigate_page --type "reload" --ignoreCache true # Reload page ignoring cache
|
|
63
|
-
chrome-devtools navigate_page --url "https://example.com" --timeout 5000 # Navigate with a timeout
|
|
64
|
-
chrome-devtools navigate_page --handleBeforeUnload "accept" # Handle before unload dialog
|
|
65
|
-
chrome-devtools navigate_page --type "back" --initScript "foo()" # Navigate back and run an init script
|
|
66
|
+
chrome-devtools navigate_page 1 --url "https://example.com" # Navigates the currently selected page to a URL
|
|
67
|
+
chrome-devtools navigate_page 1 --type "reload" --ignoreCache true # Reload page ignoring cache
|
|
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
|
|
70
|
+
chrome-devtools navigate_page 1 --type "back" --initScript "foo()" # Navigate back and run an init script
|
|
66
71
|
chrome-devtools new_page "https://example.com" # Creates a new page
|
|
67
72
|
chrome-devtools new_page "https://example.com" --background true --timeout 5000 # Create new page in background
|
|
68
73
|
chrome-devtools new_page "https://example.com" --isolatedContext "ctx" # Create new page with isolated context
|
|
@@ -73,54 +78,75 @@ chrome-devtools select_page 1 --bringToFront true # Select a page and bring it t
|
|
|
73
78
|
## Emulation
|
|
74
79
|
|
|
75
80
|
```bash
|
|
76
|
-
chrome-devtools emulate --networkConditions "Offline" # Emulate network conditions
|
|
77
|
-
chrome-devtools emulate --cpuThrottlingRate 4 --geolocation "0x0" # Emulate CPU throttling and geolocation
|
|
78
|
-
chrome-devtools emulate --colorScheme "dark" --viewport "1920x1080" # Emulate color scheme and viewport
|
|
79
|
-
chrome-devtools emulate --userAgent "Mozilla/5.0..." # Emulate user agent
|
|
80
|
-
chrome-devtools resize_page 1920 1080 # Resizes the selected page's window
|
|
81
|
+
chrome-devtools emulate 1 --networkConditions "Offline" # Emulate network conditions
|
|
82
|
+
chrome-devtools emulate 1 --cpuThrottlingRate 4 --geolocation "0x0" # Emulate CPU throttling and 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
|
|
85
|
+
chrome-devtools resize_page 1 1920 1080 # Resizes the selected page's window
|
|
81
86
|
```
|
|
82
87
|
|
|
83
88
|
## Performance
|
|
84
89
|
|
|
85
90
|
```bash
|
|
86
|
-
chrome-devtools performance_analyze_insight "1" "LCPBreakdown" # Get more details on a specific Performance Insight
|
|
87
|
-
chrome-devtools performance_start_trace true false # Starts a performance trace recording
|
|
88
|
-
chrome-devtools performance_start_trace true true --filePath t.gz # Start trace and save to a file
|
|
89
|
-
chrome-devtools performance_stop_trace # Stops the active performance trace
|
|
90
|
-
chrome-devtools performance_stop_trace --filePath "t.json" # Stop trace and save to a file
|
|
91
|
-
|
|
91
|
+
chrome-devtools performance_analyze_insight 1 "1" "LCPBreakdown" # Get more details on a specific Performance Insight (pageId, insightSetId, insightName)
|
|
92
|
+
chrome-devtools performance_start_trace 1 --reload true --autoStop false # Starts a performance trace recording (reload, autoStop)
|
|
93
|
+
chrome-devtools performance_start_trace 1 --reload true --autoStop true --filePath "t.json.gz" # Start trace and save to a file
|
|
94
|
+
chrome-devtools performance_stop_trace 1 # Stops the active performance trace
|
|
95
|
+
chrome-devtools performance_stop_trace 1 --filePath "t.json.gz" # Stop trace and save to a file
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Memory
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
chrome-devtools take_heapsnapshot 1 "./snap.heapsnapshot" # Capture a memory heap snapshot
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Memory Debugging (requires `--memoryDebugging=true`)
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
chrome-devtools get_heapsnapshot_summary "./snap.heapsnapshot" # Get snapshot summary stats
|
|
108
|
+
chrome-devtools compare_heapsnapshots "./base.heapsnapshot" "./target.heapsnapshot" # Compare two snapshots
|
|
109
|
+
chrome-devtools get_heapsnapshot_class_nodes "./snap.heapsnapshot" "Array" # Inspect class instances
|
|
110
|
+
chrome-devtools get_heapsnapshot_details "./snap.heapsnapshot" 123 # Detailed object properties
|
|
111
|
+
chrome-devtools get_heapsnapshot_dominators "./snap.heapsnapshot" 123 # Dominator tree for node
|
|
112
|
+
chrome-devtools get_heapsnapshot_duplicate_strings "./snap.heapsnapshot" # Find duplicated strings
|
|
113
|
+
chrome-devtools get_heapsnapshot_edges "./snap.heapsnapshot" 123 # Node edges/references
|
|
114
|
+
chrome-devtools get_heapsnapshot_object_details "./snap.heapsnapshot" 123 # Object details by node ID
|
|
115
|
+
chrome-devtools get_heapsnapshot_retainers "./snap.heapsnapshot" 123 # Retaining objects
|
|
116
|
+
chrome-devtools get_heapsnapshot_retaining_paths "./snap.heapsnapshot" 123 # Shortest retaining paths
|
|
117
|
+
chrome-devtools close_heapsnapshot "./snap.heapsnapshot" # Free memory from loaded snapshot
|
|
92
118
|
```
|
|
93
119
|
|
|
94
120
|
## Network
|
|
95
121
|
|
|
96
122
|
```bash
|
|
97
|
-
chrome-devtools get_network_request # Get the currently selected network request
|
|
98
|
-
chrome-devtools get_network_request --reqid 1 --requestFilePath req.md # Get request by id and save to file
|
|
99
|
-
chrome-devtools get_network_request --responseFilePath res.md # Save response body to file
|
|
100
|
-
chrome-devtools list_network_requests # List all network requests
|
|
101
|
-
chrome-devtools list_network_requests --pageSize 50 --pageIdx 0 # List network requests with pagination
|
|
102
|
-
chrome-devtools list_network_requests --resourceTypes Fetch # Filter requests by resource type
|
|
103
|
-
chrome-devtools list_network_requests --includePreservedRequests true # Include preserved requests
|
|
123
|
+
chrome-devtools get_network_request 1 # Get the currently selected network request for page 1
|
|
124
|
+
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
|
|
126
|
+
chrome-devtools list_network_requests 1 # List all network requests for page 1
|
|
127
|
+
chrome-devtools list_network_requests 1 --pageSize 50 --pageIdx 0 # List network requests with pagination
|
|
128
|
+
chrome-devtools list_network_requests 1 --resourceTypes Fetch # Filter requests by resource type
|
|
129
|
+
chrome-devtools list_network_requests 1 --includePreservedRequests true # Include preserved requests
|
|
104
130
|
```
|
|
105
131
|
|
|
106
132
|
## Debugging & Inspection
|
|
107
133
|
|
|
108
134
|
```bash
|
|
109
|
-
chrome-devtools evaluate_script "() => document.title" # Evaluate a JavaScript function on
|
|
110
|
-
chrome-devtools evaluate_script "(a) => a.innerText" --args 1_4 # Evaluate JS with UID arguments
|
|
111
|
-
chrome-devtools get_console_message 1 # Gets a console message by its ID
|
|
112
|
-
chrome-devtools lighthouse_audit --mode "navigation" # Run Lighthouse audit for navigation
|
|
113
|
-
chrome-devtools lighthouse_audit --mode "snapshot" --device "mobile" # Run Lighthouse audit for a snapshot on mobile
|
|
114
|
-
chrome-devtools lighthouse_audit --outputDirPath ./out # Run Lighthouse audit and save reports
|
|
115
|
-
chrome-devtools list_console_messages # List all console messages
|
|
116
|
-
chrome-devtools list_console_messages --pageSize 20 --pageIdx 1 # List console messages with pagination
|
|
117
|
-
chrome-devtools list_console_messages --types error --types info # Filter console messages by type
|
|
118
|
-
chrome-devtools list_console_messages --includePreservedMessages true # Include preserved messages
|
|
119
|
-
chrome-devtools take_screenshot # Take a screenshot of the page viewport
|
|
120
|
-
chrome-devtools take_screenshot --fullPage true --format "jpeg" --quality 80 # Take a full page screenshot as JPEG with quality
|
|
121
|
-
chrome-devtools take_screenshot --uid "id" --filePath "s.png" # Take a screenshot of an element
|
|
122
|
-
chrome-devtools take_snapshot # Take a text snapshot of the page from the a11y tree
|
|
123
|
-
chrome-devtools take_snapshot --verbose true --filePath "s.txt" # Take a verbose snapshot and save to file
|
|
135
|
+
chrome-devtools evaluate_script "() => document.title" --pageId 1 # Evaluate a JavaScript function on page 1
|
|
136
|
+
chrome-devtools evaluate_script "(a) => a.innerText" --pageId 1 --args 1_4 # Evaluate JS with UID arguments on page 1
|
|
137
|
+
chrome-devtools get_console_message 1 1 # Gets a console message by its ID
|
|
138
|
+
chrome-devtools lighthouse_audit 1 --mode "navigation" # Run Lighthouse audit for navigation
|
|
139
|
+
chrome-devtools lighthouse_audit 1 --mode "snapshot" --device "mobile" # Run Lighthouse audit for a snapshot on mobile
|
|
140
|
+
chrome-devtools lighthouse_audit 1 --outputDirPath ./out # Run Lighthouse audit and save reports
|
|
141
|
+
chrome-devtools list_console_messages 1 # List all console messages
|
|
142
|
+
chrome-devtools list_console_messages 1 --pageSize 20 --pageIdx 1 # List console messages with pagination
|
|
143
|
+
chrome-devtools list_console_messages 1 --types error --types info # Filter console messages by type
|
|
144
|
+
chrome-devtools list_console_messages 1 --includePreservedMessages true # Include preserved messages
|
|
145
|
+
chrome-devtools take_screenshot 1 # Take a screenshot of the page viewport
|
|
146
|
+
chrome-devtools take_screenshot 1 --fullPage true --format "jpeg" --quality 80 # Take a full page screenshot as JPEG with quality
|
|
147
|
+
chrome-devtools take_screenshot 1 --uid "id" --filePath "s.png" # Take a screenshot of an element
|
|
148
|
+
chrome-devtools take_snapshot 1 # Take a text snapshot of the page from the a11y tree
|
|
149
|
+
chrome-devtools take_snapshot 1 --verbose true --filePath "s.txt" # Take a verbose snapshot and save to file
|
|
124
150
|
```
|
|
125
151
|
|
|
126
152
|
## Extensions
|
|
@@ -133,21 +159,34 @@ chrome-devtools reload_extension "extension_id" # Reloads an unpacked Chrome ext
|
|
|
133
159
|
chrome-devtools trigger_extension_action "extension_id" # Triggers the default action of an extension by its ID
|
|
134
160
|
```
|
|
135
161
|
|
|
162
|
+
## Progressive Web Apps (requires `--categoryPwa=true`)
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
chrome-devtools install_pwa "https://example.com/" # Install PWA by manifest ID or URL
|
|
166
|
+
chrome-devtools launch_pwa "https://example.com/" # Launch installed PWA
|
|
167
|
+
chrome-devtools get_os_app_state "https://example.com/" # Get OS app installation state
|
|
168
|
+
chrome-devtools uninstall_pwa "https://example.com/" # Uninstall PWA and close windows
|
|
169
|
+
```
|
|
170
|
+
|
|
136
171
|
## Experimental Features
|
|
137
172
|
|
|
138
173
|
Experimental tools are disabled by default. Enable them with the corresponding flag during `start`.
|
|
139
174
|
|
|
140
175
|
```bash
|
|
141
|
-
chrome-devtools click_at 100 200 # Clicks at the provided coordinates (requires --experimentalVision=true)
|
|
142
|
-
chrome-devtools screencast_start # Starts a screencast recording (requires --experimentalScreencast=true and ffmpeg)
|
|
143
|
-
chrome-devtools screencast_stop # Stops the active screencast
|
|
144
|
-
chrome-devtools list_webmcp_tools # List all WebMCP tools (requires --categoryExperimentalWebmcp=true)
|
|
176
|
+
chrome-devtools click_at 1 100 200 # Clicks at the provided coordinates on page 1 (requires --experimentalVision=true)
|
|
177
|
+
chrome-devtools screencast_start 1 --filePath "screen.mp4" # Starts a screencast recording on page 1 (requires --experimentalScreencast=true and ffmpeg)
|
|
178
|
+
chrome-devtools screencast_stop 1 # Stops the active screencast on page 1
|
|
179
|
+
chrome-devtools list_webmcp_tools 1 # List all WebMCP tools on page 1 (requires --categoryExperimentalWebmcp=true)
|
|
180
|
+
chrome-devtools execute_webmcp_tool 1 "tool_name" --input '{"arg":"val"}' # Execute a WebMCP tool on page 1 (requires --categoryExperimentalWebmcp=true)
|
|
181
|
+
chrome-devtools list_3p_developer_tools 1 # List third-party developer tools on page 1 (requires --categoryExperimentalThirdParty=true)
|
|
182
|
+
chrome-devtools execute_3p_developer_tool 1 "tool_name" --params '{"arg":"val"}' # Execute third-party developer tool on page 1 (requires --categoryExperimentalThirdParty=true)
|
|
145
183
|
```
|
|
146
184
|
|
|
147
185
|
## Service Management
|
|
148
186
|
|
|
149
187
|
```bash
|
|
150
188
|
chrome-devtools start # Start or restart chrome-devtools-mcp
|
|
189
|
+
chrome-devtools start --headless=false # Start with visible browser window
|
|
151
190
|
chrome-devtools status # Checks if chrome-devtools-mcp is running
|
|
152
191
|
chrome-devtools stop # Stop chrome-devtools-mcp if any
|
|
153
192
|
```
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cookie-debugging
|
|
3
|
+
description: Uses Chrome DevTools MCP for inspecting, debugging, and testing cookies, session state, authentication issues, and cookie consent compliance. Use when diagnosing 401/403 errors, authentication redirects, session expiration, Cookie/Set-Cookie header issues, cookie banner consent conformance, or third-party cookie/SameSite/Partitioned cookie warnings.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Core Concepts
|
|
7
|
+
|
|
8
|
+
### HttpOnly vs Client-Side Storage
|
|
9
|
+
|
|
10
|
+
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`)**.
|
|
11
|
+
|
|
12
|
+
- To inspect current `HttpOnly` values: Look at the `Cookie` request header of any outgoing HTTP request via `get_network_request`.
|
|
13
|
+
- To inspect how cookies were created or configured: Look at the `Set-Cookie` response header of login/auth responses.
|
|
14
|
+
- To inspect non-`HttpOnly` cookies: Use `evaluate_script` with the modern `cookieStore` API (`async () => await cookieStore.getAll()`).
|
|
15
|
+
|
|
16
|
+
### Session Strategy: Live Tab vs Isolated Context
|
|
17
|
+
|
|
18
|
+
Choose the right session environment to avoid state contamination (e.g., residual analytics or auth tokens):
|
|
19
|
+
|
|
20
|
+
| Strategy | When to Use | Setup / Teardown |
|
|
21
|
+
| :---------------------------------- | :---------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------ |
|
|
22
|
+
| **Live Tab (Active Page)** | Diagnosing an active user session, live 401/403 error, or current state. | Operates directly on the currently selected page. |
|
|
23
|
+
| **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
|
+
|
|
25
|
+
### Client-Side Capabilities & Limitations
|
|
26
|
+
|
|
27
|
+
| Action | Client JavaScript (`cookieStore` / `document.cookie`) | DevTools Network & Context Tools |
|
|
28
|
+
| :--------------------------------------------------------------- | :---------------------------------------------------- | :------------------------------------------------------ |
|
|
29
|
+
| **Read Non-HttpOnly** | ✅ `async () => await cookieStore.getAll()` | ✅ `get_network_request` (Request `Cookie`) |
|
|
30
|
+
| **Read HttpOnly** | ❌ Blocked by browser security | ✅ `get_network_request` (Request `Cookie`) |
|
|
31
|
+
| **Inspect Attributes** (`Domain`, `Path`, `SameSite`, `Expires`) | ✅ `async () => await cookieStore.getAll()` | ✅ `get_network_request` (Response `Set-Cookie`) |
|
|
32
|
+
| **Modify / Delete Non-HttpOnly** | ✅ `async () => await cookieStore.set(...)` | N/A |
|
|
33
|
+
| **Modify / Delete HttpOnly** | ❌ **Silent failure** in JavaScript | ✅ Use `new_page(isolatedContext: ...)` for clean state |
|
|
34
|
+
|
|
35
|
+
> [!WARNING]
|
|
36
|
+
> Attempting to clear an `HttpOnly` cookie via JavaScript (`cookieStore.delete` or `document.cookie = "...; max-age=0"`) will silently fail. To test in an unauthenticated or fresh state, always spawn a new isolated context using `new_page` with `isolatedContext`.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Workflow Patterns
|
|
41
|
+
|
|
42
|
+
### 1. Diagnosing Authentication Failures & Redirects (401 / 403)
|
|
43
|
+
|
|
44
|
+
When an authenticated page request fails, returns 401/403, or redirects to login:
|
|
45
|
+
|
|
46
|
+
1. **List Recent Requests**: Call `list_network_requests` with `includePreservedRequests: true`.
|
|
47
|
+
2. **Find the Target Request**: Locate the failing request (401/403) or redirect (302/307).
|
|
48
|
+
3. **Inspect Outgoing `Cookie` Header**: Call `get_network_request` with the `reqid`.
|
|
49
|
+
- Verify if the `Cookie` header was attached and whether required tokens (e.g. `SESSION_ID`, `auth_token`) were sent.
|
|
50
|
+
4. **Trigger Active Inspection (If no recent request exists)**:
|
|
51
|
+
- If the cookie was set in a previous session and no network call is listed, trigger a request:
|
|
52
|
+
- Use `navigate_page` with `reload: true`, OR
|
|
53
|
+
- Call `evaluate_script` with `() => fetch(window.location.href)`
|
|
54
|
+
- Then call `get_network_request` on the new request to inspect the active `Cookie` header.
|
|
55
|
+
5. **Trace the Setting Request**: If the cookie is missing or rejected:
|
|
56
|
+
- Check earlier login/handshake responses for `Set-Cookie` directives:
|
|
57
|
+
- **Path mismatch**: e.g., `Path=/api` when the request is to `/`.
|
|
58
|
+
- **Domain mismatch**: e.g., `Domain=api.example.com` preventing cookies on `sub.example.com`.
|
|
59
|
+
- **Secure flag on HTTP**: `Secure` cookies are never sent over unencrypted `http://`.
|
|
60
|
+
- **SameSite blocking**: `SameSite=Strict` cookies are omitted on cross-site navigations.
|
|
61
|
+
- **Expiration**: Check if `Expires` or `Max-Age` elapsed.
|
|
62
|
+
|
|
63
|
+
### 2. Cookie Banner & Consent Conformance Testing
|
|
64
|
+
|
|
65
|
+
To verify that no non-essential or tracking cookies are set before consent or when declining:
|
|
66
|
+
|
|
67
|
+
1. **Start Clean**: Open a fresh isolated context with a dedicated name:
|
|
68
|
+
```json
|
|
69
|
+
{"url": "<PAGE_URL>", "isolatedContext": "consent-test-1"}
|
|
70
|
+
```
|
|
71
|
+
2. **Record Baseline Cookies**: Before interacting with the banner, run `evaluate_script` with `async () => await cookieStore.getAll()`.
|
|
72
|
+
3. **Inspect Premature Network Requests & Issues**:
|
|
73
|
+
- Call `list_network_requests` to ensure no third-party tracking beacons fired before consent.
|
|
74
|
+
- Call `list_console_messages` with `types: ["issue"]` to check for tracking warnings.
|
|
75
|
+
4. **Interact with Consent Banner**:
|
|
76
|
+
- Capture snapshot with `take_snapshot` to locate the "Decline" or "Reject All" button `uid`.
|
|
77
|
+
- Click the button with `click`.
|
|
78
|
+
5. **Verify Cookie Difference**:
|
|
79
|
+
- Run `evaluate_script` with `async () => await cookieStore.getAll()` after clicking to assert that only strictly necessary or consent-state cookies exist.
|
|
80
|
+
6. **Test Consent Revocation (Lifecycle Audit)**:
|
|
81
|
+
- When auditing consent withdrawal or preference changes:
|
|
82
|
+
- Locate and click the "Cookie Settings", "Manage Preferences", or footer privacy trigger (`take_snapshot` $\rightarrow$ `click`).
|
|
83
|
+
- Deselect non-essential categories or click "Revoke All" / "Save Preferences".
|
|
84
|
+
- Re-query `cookieStore.getAll()` to verify previously accepted non-essential cookies were cleared or expired.
|
|
85
|
+
- Call `list_network_requests` on subsequent actions to ensure tracking beacons are no longer fired.
|
|
86
|
+
7. **Teardown Context**: Call `close_page` when the audit is complete to prevent leftover cookies from affecting subsequent tasks.
|
|
87
|
+
|
|
88
|
+
### 3. Auditing Cookie Security, SameSite & CHIPS (Partitioned Cookies)
|
|
89
|
+
|
|
90
|
+
1. **Fast-Track: Native DevTools Issues (Recommended)**:
|
|
91
|
+
- Call `list_console_messages` with:
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"types": ["issue"],
|
|
95
|
+
"includePreservedMessages": true
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
- Check for `CookieIssue` entries, such as:
|
|
99
|
+
- `SameSiteNoneInsecure`: `SameSite=None` without `Secure`.
|
|
100
|
+
- `ThirdPartyCookiePhaseout`: Third-party cookie blocked or restricted.
|
|
101
|
+
- `SchemefulSameSite`: Cross-scheme cookie issues.
|
|
102
|
+
- `PartitionedCookies`: Invalid CHIPS partitioning attributes.
|
|
103
|
+
2. **Deep Audit: Lighthouse Third-Party Cookies**:
|
|
104
|
+
- Run `lighthouse_audit` with `mode: "navigation"` and `outputDirPath: "/tmp/lh-report"`.
|
|
105
|
+
- **Extract the specific cookie audit** without loading the full report into context:
|
|
106
|
+
```bash
|
|
107
|
+
node -e "const r=require('/tmp/lh-report/report.json'); const a=r.audits['third-party-cookies']; console.log(JSON.stringify({score: a?.score, displayValue: a?.displayValue, items: a?.details?.items}))"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 4. Client-Side Cookie Inspection & Manipulation
|
|
111
|
+
|
|
112
|
+
For client-accessible, non-`HttpOnly` cookies (e.g., UI preferences, non-sensitive feature flags):
|
|
113
|
+
|
|
114
|
+
1. **Read Cookies & Attributes**:
|
|
115
|
+
- Use the modern asynchronous Cookie Store API:
|
|
116
|
+
```js
|
|
117
|
+
async () => await cookieStore.getAll();
|
|
118
|
+
```
|
|
119
|
+
- _Fallback for insecure HTTP origins_: `() => document.cookie`.
|
|
120
|
+
2. **Set / Modify Cookie**:
|
|
121
|
+
- Set client cookie via `cookieStore`:
|
|
122
|
+
```js
|
|
123
|
+
async () =>
|
|
124
|
+
await cookieStore.set({
|
|
125
|
+
name: 'theme',
|
|
126
|
+
value: 'dark',
|
|
127
|
+
expires: Date.now() + 86400000,
|
|
128
|
+
sameSite: 'lax',
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
3. **Delete Cookie**:
|
|
132
|
+
- Clear client cookie:
|
|
133
|
+
```js
|
|
134
|
+
async () => await cookieStore.delete('theme');
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Troubleshooting
|
|
140
|
+
|
|
141
|
+
- **`cookieStore` is undefined**: `cookieStore` requires a Secure Context (`https://`, `localhost`, or `127.0.0.1`). On non-secure HTTP origins, use `() => document.cookie` or test over HTTPS.
|
|
142
|
+
- **`evaluate_script` returns empty / unresolved Promise**: `cookieStore` methods are asynchronous. Always wrap calls with `async () => await cookieStore.getAll()`.
|
|
143
|
+
- **Cookie not visible in JavaScript**: The cookie is marked `HttpOnly`. Trigger a network request and call `get_network_request` to view it in the `Cookie` request header.
|
|
144
|
+
- **JavaScript deletion did not remove cookie**: The cookie is `HttpOnly` or requires matching `Path` and `Domain` parameters. Use a fresh `isolatedContext` with `new_page` for a clean slate.
|
|
145
|
+
- **Cookie set in response but not sent in requests**:
|
|
146
|
+
- Verify if page is `http://` while cookie specifies `Secure`.
|
|
147
|
+
- Check if `Domain` restricts subdomains.
|
|
148
|
+
- Check `list_console_messages(types: ["issue"])` for browser rejection reasons.
|
|
149
|
+
- **Residual cookies contaminating audits**: Always use `new_page` with a unique `isolatedContext` when running compliance tests, and call `close_page` when done.
|
|
@@ -36,8 +36,8 @@ Follow these steps in order. Each step builds on the previous one.
|
|
|
36
36
|
|
|
37
37
|
Navigate to the page, then record a trace with reload to capture the full page load including LCP:
|
|
38
38
|
|
|
39
|
-
1. `navigate_page` to the target URL.
|
|
40
|
-
2. `performance_start_trace` with `reload: true` and `autoStop: true`.
|
|
39
|
+
1. `navigate_page` with `pageId` to the target URL.
|
|
40
|
+
2. `performance_start_trace` with `pageId`, `reload: true` and `autoStop: true`.
|
|
41
41
|
|
|
42
42
|
The trace results will include LCP timing and available insight sets. Note the insight set IDs from the output — you'll need them in the next step.
|
|
43
43
|
|
|
@@ -50,11 +50,11 @@ Use `performance_analyze_insight` to drill into LCP-specific insights. Look for
|
|
|
50
50
|
- **RenderBlocking** — Resources blocking the LCP element from rendering.
|
|
51
51
|
- **LCPDiscovery** — Whether the LCP resource was discoverable early.
|
|
52
52
|
|
|
53
|
-
Call `performance_analyze_insight` with the insight set ID and the insight name from the trace results.
|
|
53
|
+
Call `performance_analyze_insight` with `pageId`, the insight set ID, and the insight name from the trace results.
|
|
54
54
|
|
|
55
55
|
### Step 3: Identify the LCP Element
|
|
56
56
|
|
|
57
|
-
Use `evaluate_script` with the **"Identify LCP Element" snippet** found in [references/lcp-snippets.md](references/lcp-snippets.md) to reveal the LCP element's tag, resource URL, and raw timing data.
|
|
57
|
+
Use `evaluate_script` (with `pageId`) and the **"Identify LCP Element" snippet** found in [references/lcp-snippets.md](references/lcp-snippets.md) to reveal the LCP element's tag, resource URL, and raw timing data.
|
|
58
58
|
|
|
59
59
|
The `url` field tells you what resource to look for in the network waterfall. If `url` is empty, the LCP element is text-based (no resource to load).
|
|
60
60
|
|
|
@@ -62,8 +62,8 @@ 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` filtered by `resourceTypes: ["Image", "Font"]` (adjust based on Step 3).
|
|
66
|
-
- Then use `get_network_request` with the LCP resource's request ID for full details.
|
|
65
|
+
- Call `list_network_requests` with `pageId` filtered by `resourceTypes: ["Image", "Font"]` (adjust based on Step 3).
|
|
66
|
+
- Then use `get_network_request` with `pageId` and the LCP resource's request ID for full details.
|
|
67
67
|
|
|
68
68
|
**Key Checks:**
|
|
69
69
|
|
|
@@ -72,7 +72,7 @@ Use `list_network_requests` to see when the LCP resource loaded relative to othe
|
|
|
72
72
|
|
|
73
73
|
### Step 5: Inspect HTML for Common Issues
|
|
74
74
|
|
|
75
|
-
Use `evaluate_script` with the **"Audit Common Issues" snippet** found in [references/lcp-snippets.md](references/lcp-snippets.md) to check for lazy-loaded images in the viewport, missing fetchpriority, and render-blocking scripts.
|
|
75
|
+
Use `evaluate_script` (with `pageId`) and the **"Audit Common Issues" snippet** found in [references/lcp-snippets.md](references/lcp-snippets.md) to check for lazy-loaded images in the viewport, missing fetchpriority, and render-blocking scripts.
|
|
76
76
|
|
|
77
77
|
## Optimization Strategies
|
|
78
78
|
|
|
@@ -115,7 +115,7 @@ The HTML document itself takes too long to arrive.
|
|
|
115
115
|
|
|
116
116
|
## Verifying Fixes & Emulation
|
|
117
117
|
|
|
118
|
-
- **Verification**: Re-run the trace (`performance_start_trace` with `reload: true`) and compare the new subpart breakdown. The bottleneck should shrink.
|
|
118
|
+
- **Verification**: Re-run the trace (`performance_start_trace` with `pageId` and `reload: true`) and compare the new subpart breakdown. The bottleneck should shrink.
|
|
119
119
|
- **Emulation**: Lab measurements differ from real-world experience. Use `emulate` to test under constraints:
|
|
120
|
-
- `emulate` with `networkConditions: "Fast 3G"` and `cpuThrottlingRate: 4`.
|
|
120
|
+
- `emulate` with `pageId`, `networkConditions: "Fast 3G"` and `cpuThrottlingRate: 4`.
|
|
121
121
|
- This surfaces issues visible only on slower connections/devices.
|
|
@@ -7,6 +7,10 @@ description: Diagnoses and resolves memory leaks in JavaScript/Node.js applicati
|
|
|
7
7
|
|
|
8
8
|
This skill provides expert guidance and workflows for finding, diagnosing, and fixing memory leaks in JavaScript and Node.js applications using Chrome DevTools MCP tools.
|
|
9
9
|
|
|
10
|
+
## Prerequisites
|
|
11
|
+
|
|
12
|
+
Advanced memory debugging tools (`compare_heapsnapshots`, `get_heapsnapshot_details`, etc.) are only available when the server is started with the `--memoryDebugging` flag. First check if these tools are available; if not, try to read the MCP configuration file to check if `--memoryDebugging` is enabled.
|
|
13
|
+
|
|
10
14
|
## Core Principles
|
|
11
15
|
|
|
12
16
|
- **Prefer MCP memory tools:** Do NOT attempt to read raw `.heapsnapshot` files directly, as they are extremely large and will consume too many tokens. Use the Chrome DevTools MCP heap snapshot tools to summarize, compare, and inspect snapshots.
|
|
@@ -20,10 +24,10 @@ This skill provides expert guidance and workflows for finding, diagnosing, and f
|
|
|
20
24
|
|
|
21
25
|
When investigating a frontend web application memory leak, utilize the `chrome-devtools-mcp` tools to interact with the application and take snapshots.
|
|
22
26
|
|
|
23
|
-
- Use tools like `click`, `navigate_page`, `fill`, etc
|
|
27
|
+
- Use page-scoped tools like `click`, `navigate_page`, `fill`, etc. (specifying `pageId`) to manipulate the page into the desired state.
|
|
24
28
|
- Revert the page back to the original state after interactions to see if memory is released.
|
|
25
29
|
- Repeat the same user interactions 10 times to amplify the leak.
|
|
26
|
-
- Use `take_heapsnapshot` to save `.heapsnapshot` files to disk at baseline, target (after actions), and final (after reverting actions) states.
|
|
30
|
+
- Use `take_heapsnapshot` (with `pageId`) to save `.heapsnapshot` files to disk at baseline, target (after actions), and final (after reverting actions) states.
|
|
27
31
|
|
|
28
32
|
### 2. Comparing Snapshots
|
|
29
33
|
|
|
@@ -60,6 +60,7 @@ Identify other error messages from the failed tool call or the MCP initializatio
|
|
|
60
60
|
|
|
61
61
|
- `Target closed`
|
|
62
62
|
- "Tool not found" (check if they are using `--slim` which only enables navigation and screenshot tools).
|
|
63
|
+
- Missing `pageId`: Page-scoped tools require a `pageId` argument. Call `list_pages` to find active page IDs.
|
|
63
64
|
- `ProtocolError: Network.enable timed out` or `The socket connection was closed unexpectedly`
|
|
64
65
|
- `Error [ERR_MODULE_NOT_FOUND]: Cannot find module`
|
|
65
66
|
- Any sandboxing or host validation errors.
|