chrome-devtools-mcp 1.8.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +20 -908
  2. package/build/src/BrowserManager.js +401 -0
  3. package/build/src/McpContext.js +43 -26
  4. package/build/src/McpPage.js +112 -4
  5. package/build/src/McpResponse.js +68 -3
  6. package/build/src/ToolHandler.js +184 -160
  7. package/build/src/bin/chrome-devtools-mcp-main.js +12 -7
  8. package/build/src/bin/chrome-devtools.js +6 -12
  9. package/build/src/collectors/PageCollector.js +66 -3
  10. package/build/src/config/browser-options.js +125 -0
  11. package/build/src/config/category-options.js +89 -0
  12. package/build/src/config/cli-commands.js +26 -0
  13. package/build/src/config/cli-options.js +34 -2
  14. package/build/src/config/mcp-options.js +86 -147
  15. package/build/src/daemon/utils.js +6 -0
  16. package/build/src/devtools/DevToolsCommentBridge.js +91 -0
  17. package/build/src/devtools/DevtoolsUtils.js +27 -21
  18. package/build/src/formatters/CommentFormatter.js +82 -0
  19. package/build/src/formatters/CssFormatter.js +812 -0
  20. package/build/src/formatters/NetworkFormatter.js +5 -2
  21. package/build/src/index.js +175 -128
  22. package/build/src/processors/ChunkedTraceParser.js +361 -0
  23. package/build/src/processors/PerformanceTrace.js +60 -13
  24. package/build/src/telemetry/ClearcutLogger.js +95 -37
  25. package/build/src/telemetry/metricsRegistry.js +3 -0
  26. package/build/src/telemetry/persistence.js +17 -7
  27. package/build/src/telemetry/transformation.js +53 -4
  28. package/build/src/telemetry/types.js +1 -0
  29. package/build/src/third_party/THIRD_PARTY_NOTICES +687 -133
  30. package/build/src/third_party/bundled-packages.json +6 -3
  31. package/build/src/third_party/devtools-formatter-worker.js +158 -5
  32. package/build/src/third_party/devtools-heap-snapshot-worker.js +589 -6
  33. package/build/src/third_party/index.js +59173 -38013
  34. package/build/src/third_party/issue-descriptions/webInstallManifestMissingId.md +3 -0
  35. package/build/src/third_party/issue-descriptions/webInstallManifestMissingNameOrShortName.md +3 -0
  36. package/build/src/third_party/issue-descriptions/webInstallManifestParsingOrNetworkError.md +3 -0
  37. package/build/src/third_party/issue-descriptions/webInstallNoManifest.md +3 -0
  38. package/build/src/third_party/issue-descriptions/webInstallStartUrlInvalid.md +3 -0
  39. package/build/src/tools/ToolDefinition.js +28 -21
  40. package/build/src/tools/categories.js +0 -6
  41. package/build/src/tools/comments.js +169 -0
  42. package/build/src/tools/console.js +3 -3
  43. package/build/src/tools/css.js +45 -0
  44. package/build/src/tools/emulation.js +5 -5
  45. package/build/src/tools/extensions.js +10 -10
  46. package/build/src/tools/input.js +159 -87
  47. package/build/src/tools/lighthouse.js +18 -7
  48. package/build/src/tools/memory.js +26 -26
  49. package/build/src/tools/network.js +5 -5
  50. package/build/src/tools/pages.js +34 -19
  51. package/build/src/tools/performance.js +7 -6
  52. package/build/src/tools/pwa.js +8 -8
  53. package/build/src/tools/screencast.js +5 -4
  54. package/build/src/tools/screenshot.js +2 -2
  55. package/build/src/tools/script.js +8 -7
  56. package/build/src/tools/slim/tools.js +45 -37
  57. package/build/src/tools/snapshot.js +4 -4
  58. package/build/src/tools/thirdPartyDeveloper.js +4 -4
  59. package/build/src/tools/tools.js +6 -9
  60. package/build/src/tools/webmcp.js +4 -4
  61. package/build/src/types.js +4 -1
  62. package/build/src/utils/WaitForHelper.js +26 -9
  63. package/build/src/utils/logger.js +7 -6
  64. package/build/src/utils/url.js +73 -0
  65. package/build/src/version.js +1 -1
  66. package/package.json +9 -6
  67. package/skills/chrome-devtools/SKILL.md +2 -1
  68. package/skills/chrome-devtools-cli/SKILL.md +3 -7
  69. package/skills/cookie-debugging/SKILL.md +149 -0
  70. package/skills/memory-leak-debugging/SKILL.md +4 -0
  71. package/build/src/browser.js +0 -244
  72. package/build/src/third_party/issue-descriptions/cookieExcludeBlockedWithinRelatedWebsiteSet.md +0 -4
@@ -144,6 +144,9 @@ export class WaitForHelper {
144
144
  }
145
145
  }
146
146
  timeout(time) {
147
+ if (this.#abortController.signal.aborted) {
148
+ return Promise.resolve();
149
+ }
147
150
  return new Promise(res => {
148
151
  const id = setTimeout(res, time);
149
152
  this.#abortController.signal.addEventListener('abort', () => {
@@ -158,15 +161,12 @@ export class WaitForHelper {
158
161
  }
159
162
  const dialogHandler = (dialog) => {
160
163
  this.#dialogDetected = true;
161
- if (!options?.handleDialog) {
162
- return;
163
- }
164
164
  let actionToTake;
165
- if (typeof options.handleDialog === 'object') {
165
+ if (typeof options?.handleDialog === 'object') {
166
166
  actionToTake = options.handleDialog[dialog.type()];
167
167
  }
168
168
  else {
169
- actionToTake = options.handleDialog;
169
+ actionToTake = options?.handleDialog;
170
170
  }
171
171
  if (actionToTake) {
172
172
  this.#dialogHandled = true;
@@ -180,6 +180,9 @@ export class WaitForHelper {
180
180
  void dialog.accept(actionToTake);
181
181
  }
182
182
  }
183
+ else {
184
+ this.#abortController.abort(new Error('Action interrupted by a dialog'));
185
+ }
183
186
  };
184
187
  this.#page.on('dialog', dialogHandler);
185
188
  this.#abortController.signal.addEventListener('abort', () => {
@@ -187,7 +190,7 @@ export class WaitForHelper {
187
190
  });
188
191
  // A scoped AbortController used to clean up navigation probe listeners.
189
192
  // When aborted (either after navigation detection finishes or if this.#abortController
190
- // aborts), it removes the CDP Page.frameStartedNavigating listener and automatically
193
+ // aborts), it removes CDP navigation probe listeners and automatically
191
194
  // detaches the abort listener from this.#abortController.signal.
192
195
  const navigationAbortController = new AbortController();
193
196
  const navigationStartedResolvers = Promise.withResolvers();
@@ -201,11 +204,22 @@ export class WaitForHelper {
201
204
  }
202
205
  navigationStartedResolvers.resolve(true);
203
206
  };
207
+ const requestedNavigationListener = (event) => {
208
+ if (event.frameId === this.#page.mainFrame()._id) {
209
+ navigationStartedResolvers.resolve(true);
210
+ }
211
+ };
204
212
  this.#page._client().on('Page.frameStartedNavigating', navigationListener);
213
+ this.#page
214
+ ._client()
215
+ .on('Page.frameRequestedNavigation', requestedNavigationListener);
205
216
  navigationAbortController.signal.addEventListener('abort', () => {
206
217
  this.#page
207
218
  ._client()
208
219
  .off('Page.frameStartedNavigating', navigationListener);
220
+ this.#page
221
+ ._client()
222
+ .off('Page.frameRequestedNavigation', requestedNavigationListener);
209
223
  });
210
224
  this.#abortController.signal.addEventListener('abort', () => {
211
225
  navigationStartedResolvers.resolve(false);
@@ -217,7 +231,7 @@ export class WaitForHelper {
217
231
  // If no navigation occurs, this.#abortController will cancel it in the finally block.
218
232
  const navigationFinished = this.#page
219
233
  .waitForNavigation({
220
- timeout: options?.timeout ?? this.#navigationTimeout,
234
+ timeout: 0,
221
235
  signal: this.#abortController.signal,
222
236
  ignoreSameDocumentNavigation: true,
223
237
  })
@@ -233,7 +247,7 @@ export class WaitForHelper {
233
247
  logger?.(error);
234
248
  });
235
249
  try {
236
- await action();
250
+ await action(this.#abortController.signal);
237
251
  }
238
252
  catch (error) {
239
253
  // Clear up pending promises
@@ -253,7 +267,10 @@ export class WaitForHelper {
253
267
  // Only await navigation if one was actually initiated; otherwise, the
254
268
  // pending waitForNavigation promise will be cancelled when this.#abortController aborts.
255
269
  if (navigationStarted) {
256
- await navigationFinished;
270
+ await Promise.race([
271
+ navigationFinished,
272
+ this.timeout(options?.timeout ?? this.#navigationTimeout),
273
+ ]);
257
274
  }
258
275
  if (this.#dialogDetected) {
259
276
  return this.#getResult();
@@ -36,16 +36,17 @@ export const logger = (...args) => {
36
36
  }
37
37
  };
38
38
  export const puppeteerLogger = (prefix) => {
39
+ const dbg = util.debuglog(prefix);
40
+ if (!dbg.enabled) {
41
+ return;
42
+ }
39
43
  if (logFileStream) {
40
44
  return (...args) => {
41
45
  logFileStream.write(`${new Date().toISOString()} ${prefix} ${util.format(...args)}\n`);
42
46
  };
43
47
  }
44
- const dbg = util.debuglog(prefix);
45
- return dbg.enabled
46
- ? (...args) => {
47
- dbg('%s %s', new Date().toISOString(), util.format(...args));
48
- }
49
- : undefined;
48
+ return (...args) => {
49
+ dbg('%s %s', new Date().toISOString(), util.format(...args));
50
+ };
50
51
  };
51
52
  //# sourceMappingURL=logger.js.map
@@ -40,4 +40,77 @@ export function isLocalhost(url) {
40
40
  }
41
41
  return false;
42
42
  }
43
+ /**
44
+ * Determines whether a URL is allowed for navigation and page tracking.
45
+ *
46
+ * Disallowed schemes:
47
+ * - chrome: (except chrome://newtab/ and chrome://inspect*)
48
+ * - chrome-untrusted:
49
+ * - chrome-extension: (unless categoryExtensions is true)
50
+ *
51
+ * @param url The URL string to test.
52
+ * @param options Configuration specifying whether extensions are enabled.
53
+ * @returns true if the URL is allowed.
54
+ */
55
+ export function isAllowedUrl(url, options) {
56
+ let parsed;
57
+ try {
58
+ parsed = new URL(url);
59
+ }
60
+ catch {
61
+ return false;
62
+ }
63
+ if (parsed.protocol === 'chrome:') {
64
+ const host = parsed.hostname.toLowerCase();
65
+ const path = parsed.pathname.toLowerCase();
66
+ if (host === 'newtab' || host === 'new-tab-page' || host === 'inspect') {
67
+ return true;
68
+ }
69
+ if (host === '' &&
70
+ (path === 'newtab' ||
71
+ path === 'new-tab-page' ||
72
+ path.startsWith('inspect'))) {
73
+ return true;
74
+ }
75
+ }
76
+ if (parsed.protocol === 'chrome:' ||
77
+ parsed.protocol === 'chrome-untrusted:') {
78
+ return false;
79
+ }
80
+ if (!options.categoryExtensions && parsed.protocol === 'chrome-extension:') {
81
+ return false;
82
+ }
83
+ return true;
84
+ }
85
+ const DISALLOWED_PROTOCOLS = new Set(['javascript:', 'data:', 'vbscript:']);
86
+ /**
87
+ * Validates a URL string by parsing it with `new URL` and checking for disallowed protocols and restricted schemes.
88
+ *
89
+ * @param url The URL string to validate.
90
+ * @param options Options object containing javascriptEvaluation and categoryExtensions.
91
+ * @returns The parsed URL.
92
+ * @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.
94
+ */
95
+ export function validateUrl(url, options) {
96
+ const { javascriptEvaluation, categoryExtensions } = options;
97
+ let parsed;
98
+ try {
99
+ parsed = new URL(url);
100
+ }
101
+ catch {
102
+ throw new Error(`Invalid URL: "${url}". URLs must be valid according to the URL standard.`);
103
+ }
104
+ if (javascriptEvaluation === false &&
105
+ DISALLOWED_PROTOCOLS.has(parsed.protocol)) {
106
+ throw new Error(`Navigating to ${parsed.protocol} URLs is not allowed when JavaScript evaluation is disabled.`);
107
+ }
108
+ if (!isAllowedUrl(url, { categoryExtensions })) {
109
+ if (parsed.protocol === 'chrome-extension:') {
110
+ throw new Error(`Navigating to chrome-extension: URLs is not allowed without --categoryExtensions.`);
111
+ }
112
+ throw new Error(`Navigating to ${parsed.protocol} URLs is not allowed.`);
113
+ }
114
+ return parsed;
115
+ }
43
116
  //# sourceMappingURL=url.js.map
@@ -5,6 +5,6 @@
5
5
  */
6
6
  // If moved update release-please config
7
7
  // x-release-please-start-version
8
- export const VERSION = '1.8.0';
8
+ export const VERSION = '1.10.0';
9
9
  // x-release-please-end
10
10
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrome-devtools-mcp",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "description": "MCP server for Chrome DevTools",
5
5
  "type": "module",
6
6
  "bin": {
@@ -15,7 +15,7 @@
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 .;",
18
+ "check-format": "eslint --cache . && prettier --check --cache .",
19
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",
@@ -56,7 +56,9 @@
56
56
  "@blackwell-systems/gcf": "^2.2.2",
57
57
  "@eslint/js": "^10.0.1",
58
58
  "@google/genai": "^2.0.1",
59
- "@modelcontextprotocol/sdk": "1.30.0",
59
+ "@modelcontextprotocol/client": "2.0.0",
60
+ "@modelcontextprotocol/core": "2.0.0",
61
+ "@modelcontextprotocol/server": "2.0.0",
60
62
  "@rollup/plugin-commonjs": "^29.0.0",
61
63
  "@rollup/plugin-json": "^6.1.0",
62
64
  "@rollup/plugin-node-resolve": "^16.0.3",
@@ -76,15 +78,16 @@
76
78
  "globals": "^17.0.0",
77
79
  "lighthouse": "13.4.1",
78
80
  "prettier": "^3.6.2",
79
- "puppeteer": "25.8.0",
80
- "rollup": "4.62.4",
81
+ "puppeteer": "25.11.0",
82
+ "rollup": "4.63.3",
81
83
  "rollup-plugin-cleanup": "^3.2.1",
82
84
  "rollup-plugin-license": "^3.6.0",
83
85
  "semver": "^7.7.4",
84
86
  "sinon": "^22.0.0",
85
87
  "typescript": "^6.0.2",
86
88
  "typescript-eslint": "^8.43.0",
87
- "yargs": "18.1.0"
89
+ "yargs": "18.1.0",
90
+ "zod": "^4.4.3"
88
91
  },
89
92
  "peerDependencies": {
90
93
  "@blackwell-systems/gcf": "^2.2.2",
@@ -34,7 +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
- - **Additional details**: `evaluate_script` for data not in accessibility tree
37
+ - **CSS & Styling inspection**: Use `get_css_styles` to inspect matched rules, cascade, and CSS variables.
38
+ - **Additional details**: Use `evaluate_script` for final resolved values (`getComputedStyle`) or runtime DOM/JS data not in the accessibility tree.
38
39
 
39
40
  ### Parallel execution
40
41
 
@@ -24,12 +24,7 @@ uid=1_0 RootWebArea "Example Domain" url="https://example.com/"
24
24
 
25
25
  ## Permissions & File Access
26
26
 
27
- By default, the server only has access to the **OS temp directory** (as defined by Node APIs, `os.tmpdir()`). File-saving parameters (`--filePath`, `--outputDirPath`) and `upload_file` outside the temp directory require unrestricted filesystem access:
28
-
29
- ```bash
30
- # Start daemon with full filesystem access
31
- chrome-devtools start --allowUnrestrictedPaths=true
32
- ```
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.
33
28
 
34
29
  ## Command Usage
35
30
 
@@ -140,6 +135,8 @@ chrome-devtools list_network_requests 1 --includePreservedRequests true # Includ
140
135
  chrome-devtools evaluate_script "() => document.title" --pageId 1 # Evaluate a JavaScript function on page 1
141
136
  chrome-devtools evaluate_script "(a) => a.innerText" --pageId 1 --args 1_4 # Evaluate JS with UID arguments on page 1
142
137
  chrome-devtools get_console_message 1 1 # Gets a console message by its ID
138
+ chrome-devtools get_css_styles 1 "1_4" # Retrieves resolved CSS styles (inline, matched, inherited, pseudo) for an element on page 1
139
+ chrome-devtools get_css_styles 1 "1_4" --pageSize 20 --pageIdx 0 # Get CSS styles with pagination on page 1
143
140
  chrome-devtools lighthouse_audit 1 --mode "navigation" # Run Lighthouse audit for navigation
144
141
  chrome-devtools lighthouse_audit 1 --mode "snapshot" --device "mobile" # Run Lighthouse audit for a snapshot on mobile
145
142
  chrome-devtools lighthouse_audit 1 --outputDirPath ./out # Run Lighthouse audit and save reports
@@ -191,7 +188,6 @@ chrome-devtools execute_3p_developer_tool 1 "tool_name" --params '{"arg":"val"}'
191
188
 
192
189
  ```bash
193
190
  chrome-devtools start # Start or restart chrome-devtools-mcp
194
- chrome-devtools start --allowUnrestrictedPaths=true # Start with full filesystem access
195
191
  chrome-devtools start --headless=false # Start with visible browser window
196
192
  chrome-devtools status # Checks if chrome-devtools-mcp is running
197
193
  chrome-devtools stop # Stop chrome-devtools-mcp if any
@@ -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.
@@ -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.