chrome-devtools-mcp 1.3.0 → 1.5.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 (40) hide show
  1. package/README.md +42 -5
  2. package/build/src/HeapSnapshotManager.js +60 -3
  3. package/build/src/McpContext.js +47 -5
  4. package/build/src/McpResponse.js +66 -7
  5. package/build/src/bin/check-latest-version.js +1 -0
  6. package/build/src/bin/chrome-devtools-cli-options.js +51 -3
  7. package/build/src/bin/chrome-devtools-mcp-cli-options.js +3 -3
  8. package/build/src/bin/chrome-devtools.js +25 -1
  9. package/build/src/daemon/daemon.js +1 -1
  10. package/build/src/formatters/HeapSnapshotFormatter.js +43 -0
  11. package/build/src/formatters/NetworkFormatter.js +3 -1
  12. package/build/src/index.js +2 -2
  13. package/build/src/issue-descriptions.js +6 -4
  14. package/build/src/third_party/THIRD_PARTY_NOTICES +3 -33
  15. package/build/src/third_party/bundled-packages.json +3 -4
  16. package/build/src/third_party/devtools-heap-snapshot-worker.js +94 -0
  17. package/build/src/third_party/index.js +2396 -896
  18. package/build/src/tools/memory.js +60 -4
  19. package/build/src/tools/screencast.js +1 -2
  20. package/build/src/tools/script.js +3 -10
  21. package/build/src/tools/thirdPartyDeveloper.js +6 -6
  22. package/build/src/utils/check-for-updates.js +1 -0
  23. package/build/src/utils/files.js +0 -4
  24. package/build/src/version.js +1 -1
  25. package/package.json +15 -6
  26. package/skills/a11y-debugging/SKILL.md +89 -0
  27. package/skills/a11y-debugging/references/a11y-snippets.md +92 -0
  28. package/skills/chrome-devtools/SKILL.md +72 -0
  29. package/skills/chrome-devtools-cli/SKILL.md +153 -0
  30. package/skills/chrome-devtools-cli/references/installation.md +14 -0
  31. package/skills/debug-optimize-lcp/SKILL.md +121 -0
  32. package/skills/debug-optimize-lcp/references/elements-and-size.md +27 -0
  33. package/skills/debug-optimize-lcp/references/lcp-breakdown.md +23 -0
  34. package/skills/debug-optimize-lcp/references/lcp-snippets.md +79 -0
  35. package/skills/debug-optimize-lcp/references/optimization-strategies.md +38 -0
  36. package/skills/memory-leak-debugging/SKILL.md +50 -0
  37. package/skills/memory-leak-debugging/references/common-leaks.md +33 -0
  38. package/skills/memory-leak-debugging/references/compare_snapshots.js +109 -0
  39. package/skills/memory-leak-debugging/references/memlab.md +29 -0
  40. package/skills/troubleshooting/SKILL.md +98 -0
@@ -4,7 +4,6 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { zod } from '../third_party/index.js';
7
- import { ensureExtension } from '../utils/files.js';
8
7
  import { ToolCategory } from './categories.js';
9
8
  import { definePageTool, defineTool } from './ToolDefinition.js';
10
9
  export const takeHeapSnapshot = definePageTool({
@@ -21,12 +20,13 @@ export const takeHeapSnapshot = definePageTool({
21
20
  },
22
21
  blockedByDialog: true,
23
22
  verifyFilesSchema: ['filePath'],
24
- handler: async (request, response) => {
23
+ handler: async (request, response, context) => {
25
24
  const page = request.page;
25
+ const snapshotPath = await context.ensureExtension(request.params.filePath, '.heapsnapshot');
26
26
  await page.pptrPage.captureHeapSnapshot({
27
- path: ensureExtension(request.params.filePath, '.heapsnapshot'),
27
+ path: snapshotPath,
28
28
  });
29
- response.appendResponseLine(`Heap snapshot saved to ${request.params.filePath}`);
29
+ response.appendResponseLine(`Heap snapshot saved to ${snapshotPath}`);
30
30
  },
31
31
  });
32
32
  export const getHeapSnapshotSummary = defineTool({
@@ -224,4 +224,60 @@ export const getHeapSnapshotDominators = defineTool({
224
224
  response.setHeapSnapshotDominators(dominators);
225
225
  },
226
226
  });
227
+ export const compareHeapSnapshots = defineTool({
228
+ name: 'compare_heapsnapshots',
229
+ description: 'Loads two memory heapsnapshots and returns the comparison. If classIndex is provided, returns detailed diff for that class, otherwise returns summary diff.',
230
+ annotations: {
231
+ category: ToolCategory.MEMORY,
232
+ readOnlyHint: true,
233
+ conditions: ['memoryDebugging'],
234
+ },
235
+ verifyFilesSchema: ['baseFilePath', 'currentFilePath'],
236
+ schema: {
237
+ baseFilePath: zod
238
+ .string()
239
+ .describe('A path to the base .heapsnapshot file (earlier snapshot).'),
240
+ currentFilePath: zod
241
+ .string()
242
+ .describe('A path to the current .heapsnapshot file (later snapshot).'),
243
+ classIndex: zod
244
+ .number()
245
+ .optional()
246
+ .describe('Optional 0-based index of the class in the summary list to filter results, showing individual objects.'),
247
+ },
248
+ blockedByDialog: false,
249
+ handler: async (request, response, context) => {
250
+ if (request.params.classIndex !== undefined) {
251
+ const classDiffResult = await context.getHeapSnapshotDetailedClassDiff(request.params.baseFilePath, request.params.currentFilePath, request.params.classIndex);
252
+ response.setHeapSnapshotDetailedClassDiff(classDiffResult);
253
+ }
254
+ else {
255
+ const diff = await context.getHeapSnapshotClassDiffs(request.params.baseFilePath, request.params.currentFilePath);
256
+ response.setHeapSnapshotClassDiffs(diff);
257
+ }
258
+ },
259
+ });
260
+ export const getHeapSnapshotDuplicateStrings = defineTool({
261
+ name: 'get_heapsnapshot_duplicate_strings',
262
+ description: 'Loads a memory heapsnapshot and returns duplicate strings grouped by their value.',
263
+ annotations: {
264
+ category: ToolCategory.MEMORY,
265
+ readOnlyHint: true,
266
+ conditions: ['memoryDebugging'],
267
+ },
268
+ blockedByDialog: false,
269
+ verifyFilesSchema: ['filePath'],
270
+ schema: {
271
+ filePath: zod.string().describe('A path to a .heapsnapshot file to read.'),
272
+ pageIdx: zod.number().optional().describe('The page index for pagination.'),
273
+ pageSize: zod.number().optional().describe('The page size for pagination.'),
274
+ },
275
+ handler: async (request, response, context) => {
276
+ const duplicateStrings = await context.getHeapSnapshotDuplicateStrings(request.params.filePath);
277
+ response.setHeapSnapshotDuplicateStrings(duplicateStrings, {
278
+ pageIdx: request.params.pageIdx,
279
+ pageSize: request.params.pageSize,
280
+ });
281
+ },
282
+ });
227
283
  //# sourceMappingURL=memory.js.map
@@ -7,7 +7,6 @@ import fs from 'node:fs/promises';
7
7
  import os from 'node:os';
8
8
  import path from 'node:path';
9
9
  import { zod } from '../third_party/index.js';
10
- import { ensureExtension } from '../utils/files.js';
11
10
  import { ToolCategory } from './categories.js';
12
11
  import { definePageTool } from './ToolDefinition.js';
13
12
  async function generateTempFilePath() {
@@ -53,7 +52,7 @@ export const startScreencast = definePageTool(args => ({
53
52
  const enforcedExtension = matchedExtension ?? '.mp4';
54
53
  const format = (matchedExtension?.substring(1) ??
55
54
  'mp4');
56
- const resolvedPath = ensureExtension(path.resolve(filePath), enforcedExtension);
55
+ const resolvedPath = await context.ensureExtension(filePath, enforcedExtension);
57
56
  const page = request.page;
58
57
  let recorder;
59
58
  try {
@@ -9,8 +9,7 @@ import { defineTool, pageIdSchema } from './ToolDefinition.js';
9
9
  export const evaluateScript = defineTool(cliArgs => {
10
10
  return {
11
11
  name: 'evaluate_script',
12
- description: `Evaluate a JavaScript function inside the currently selected page${cliArgs?.categoryExtensions ? ' or service worker' : ''}. Returns the response as JSON,
13
- so returned values have to be JSON-serializable.`,
12
+ description: `Evaluate a JavaScript function inside the currently selected page${cliArgs?.categoryExtensions ? ' or service worker' : ''}. Returns the response as JSON, so returned values have to be JSON-serializable.`,
14
13
  annotations: {
15
14
  category: ToolCategory.DEBUGGING,
16
15
  readOnlyHint: false,
@@ -18,14 +17,8 @@ so returned values have to be JSON-serializable.`,
18
17
  schema: {
19
18
  ...(cliArgs?.experimentalPageIdRouting ? pageIdSchema : {}),
20
19
  function: zod.string().describe(`A JavaScript function declaration to be executed by the tool in the currently selected page.
21
- Example without arguments: \`() => {
22
- return document.title
23
- }\` or \`async () => {
24
- return await fetch("example.com")
25
- }\`.
26
- Example with arguments: \`(el) => {
27
- return el.innerText;
28
- }\`
20
+ Example without arguments: \`() => document.title\` or \`async () => await fetch("example.com")\`.
21
+ Example with arguments: \`(el) => el.innerText\`
29
22
  `),
30
23
  args: zod
31
24
  .array(zod
@@ -9,12 +9,12 @@ import { definePageTool } from './ToolDefinition.js';
9
9
  export const listThirdPartyDeveloperTools = definePageTool({
10
10
  name: 'list_3p_developer_tools',
11
11
  description: `Lists all third-party developer tools the page exposes for providing runtime information.
12
- Third-party developer tools can be called via the 'execute_3p_developer_tool()' MCP tool.
13
- Alternatively, third-party developer tools can be executed by calling 'evaluate_script' and adding the
14
- following command to the script:
15
- 'window.__dtmcp.executeTool(toolName, params)'
16
- This might be helpful when the third-party developer tools return non-serializable values or when composing
17
- third-party developer tools with additional functionality.`,
12
+ Third-party developer tools can be called via the 'execute_3p_developer_tool()' MCP tool.
13
+ Alternatively, third-party developer tools can be executed by calling 'evaluate_script' and adding the
14
+ following command to the script:
15
+ \`window.__dtmcp.executeTool(toolName, params)\`
16
+ This might be helpful when the third-party developer tools return non-serializable values or when composing
17
+ third-party developer tools with additional functionality.`,
18
18
  annotations: {
19
19
  category: ToolCategory.THIRD_PARTY,
20
20
  readOnlyHint: true,
@@ -64,6 +64,7 @@ export async function checkForUpdates(message) {
64
64
  const child = child_process.spawn(process.execPath, [scriptPath, cachePath], {
65
65
  detached: true,
66
66
  stdio: 'ignore',
67
+ windowsHide: true,
67
68
  });
68
69
  child.unref();
69
70
  }
@@ -11,10 +11,6 @@ export async function getTempFilePath(filename) {
11
11
  const filepath = path.join(dir, filename);
12
12
  return filepath;
13
13
  }
14
- export function ensureExtension(filepath, extension) {
15
- const ext = path.extname(filepath);
16
- return filepath.slice(0, filepath.length - ext.length) + extension;
17
- }
18
14
  export async function resolveCanonicalPath(filePath) {
19
15
  const absolutePath = path.resolve(filePath);
20
16
  try {
@@ -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.3.0';
8
+ export const VERSION = '1.5.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.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "MCP server for Chrome DevTools",
5
5
  "type": "module",
6
6
  "bin": {
@@ -35,6 +35,7 @@
35
35
  "files": [
36
36
  "build/src",
37
37
  "LICENSE",
38
+ "skills",
38
39
  "!*.tsbuildinfo",
39
40
  "!*.js.map"
40
41
  ],
@@ -57,23 +58,23 @@
57
58
  "@toon-format/toon": "^2.2.0",
58
59
  "@types/debug": "^4.1.12",
59
60
  "@types/filesystem": "^0.0.36",
60
- "@types/node": "^25.0.0",
61
+ "@types/node": "^26.0.0",
61
62
  "@types/semver": "^7.7.1",
62
63
  "@types/sinon": "^21.0.0",
63
64
  "@types/yargs": "^17.0.33",
64
65
  "@typescript-eslint/eslint-plugin": "^8.43.0",
65
66
  "@typescript-eslint/parser": "^8.43.0",
66
- "chrome-devtools-frontend": "1.0.1646286",
67
+ "chrome-devtools-frontend": "1.0.1652307",
67
68
  "core-js": "3.49.0",
68
69
  "debug": "4.4.3",
69
70
  "eslint": "^9.35.0",
70
71
  "eslint-import-resolver-typescript": "^4.4.4",
71
72
  "eslint-plugin-import": "^2.32.0",
72
73
  "globals": "^17.0.0",
73
- "lighthouse": "13.3.0",
74
+ "lighthouse": "13.4.0",
74
75
  "prettier": "^3.6.2",
75
- "puppeteer": "25.1.0",
76
- "rollup": "4.61.1",
76
+ "puppeteer": "25.2.1",
77
+ "rollup": "4.62.2",
77
78
  "rollup-plugin-cleanup": "^3.2.1",
78
79
  "rollup-plugin-license": "^3.6.0",
79
80
  "semver": "^7.7.4",
@@ -83,6 +84,14 @@
83
84
  "urlpattern-polyfill": "^10.1.0",
84
85
  "yargs": "18.0.0"
85
86
  },
87
+ "peerDependencies": {
88
+ "@toon-format/toon": "^2.2.0"
89
+ },
90
+ "peerDependenciesMeta": {
91
+ "@toon-format/toon": {
92
+ "optional": true
93
+ }
94
+ },
86
95
  "engines": {
87
96
  "node": "^20.19.0 || ^22.12.0 || >=23"
88
97
  },
@@ -0,0 +1,89 @@
1
+ ---
2
+ name: a11y-debugging
3
+ description: Uses Chrome DevTools MCP for accessibility (a11y) debugging and auditing based on web.dev guidelines. Use when testing semantic HTML, ARIA labels, focus states, keyboard navigation, tap targets, and color contrast.
4
+ ---
5
+
6
+ ## Core Concepts
7
+
8
+ **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
+
10
+ **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
+
12
+ ## Workflow Patterns
13
+
14
+ ### 1. Automated Audit (Lighthouse)
15
+
16
+ Start by running a Lighthouse accessibility audit to get a comprehensive baseline. This tool provides a high-level score and lists specific failing elements with remediation advice.
17
+
18
+ 1. Run the audit:
19
+ - Set `mode` to `"navigation"` to refresh the page and capture load issues.
20
+ - Set `outputDirPath` (e.g., `/tmp/lh-report`) to save the full JSON report.
21
+ 2. **Analyze the Summary**:
22
+ - Check `scores` (0-1 scale). A score < 1 indicates violations.
23
+ - Review `audits.failed` count.
24
+ 3. **Review the Report (CRITICAL)**:
25
+ - **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:
26
+ ```bash
27
+ # Extract failing audits with their details
28
+ node -e "const r=require('./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})))"
29
+ ```
30
+ - This efficiently extracts the `selector` and `snippet` of failing elements without loading the full report into context.
31
+
32
+ ### 2. Browser Issues & Audits
33
+
34
+ Chrome automatically checks for common accessibility problems. Use `list_console_messages` to check for these native audits:
35
+
36
+ - `types`: `["issue"]`
37
+ - `includePreservedMessages`: `true` (to catch issues that occurred during page load)
38
+
39
+ This often reveals missing labels, invalid ARIA attributes, and other critical errors without manual investigation.
40
+
41
+ ### 3. Semantics & Structure
42
+
43
+ The accessibility tree exposes the heading hierarchy and semantic landmarks.
44
+
45
+ 1. Navigate to the page.
46
+ 2. Use `take_snapshot` to capture the accessibility tree.
47
+ 3. **Check Heading Levels**: Ensure heading levels (`h1`, `h2`, `h3`, etc.) are logical and do not skip levels. The snapshot will include heading roles.
48
+ 4. **Content Reordering**: Verify that the DOM order (which drives the accessibility tree) matches the visual reading order. Use `take_screenshot` to inspect the visual layout and compare it against the snapshot structure to catch CSS floats or absolute positioning that jumbles the logical flow.
49
+
50
+ ### 4. Labels, Forms & Text Alternatives
51
+
52
+ 1. Locate buttons, inputs, and images in the `take_snapshot` output.
53
+ 2. Ensure interactive elements have an accessible name (e.g., a button should not just say `""` if it only contains an icon).
54
+ 3. **Orphaned Inputs**: Verify that all form inputs have associated labels. Use `evaluate_script` with the **"Find Orphaned Form Inputs" snippet** found in [references/a11y-snippets.md](references/a11y-snippets.md).
55
+ 4. Check images for `alt` text.
56
+
57
+ ### 5. Focus & Keyboard Navigation
58
+
59
+ Testing "keyboard traps" and proper focus management without visual feedback relies on tracking the focused element.
60
+
61
+ 1. Use the `press_key` tool with `"Tab"` or `"Shift+Tab"` to move focus.
62
+ 2. Use `take_snapshot` to capture the updated accessibility tree.
63
+ 3. Locate the element marked as focused in the snapshot to verify focus moved to the expected interactive element.
64
+ 4. If a modal opens, focus must move into the modal and "trap" within it until closed.
65
+
66
+ ### 6. Tap Targets and Visuals
67
+
68
+ According to web.dev, tap targets should be at least 48x48 pixels with sufficient spacing. Since the accessibility tree doesn't show sizes, use `evaluate_script` with the **"Measure Tap Target Size" snippet** found in [references/a11y-snippets.md](references/a11y-snippets.md).
69
+
70
+ _Pass the element's `uid` from the snapshot as an argument to `evaluate_script`._
71
+
72
+ ### 7. Color Contrast
73
+
74
+ To verify color contrast ratios, start by checking for native accessibility issues:
75
+
76
+ 1. Call `list_console_messages` with `types: ["issue"]`.
77
+ 2. Look for "Low Contrast" issues in the output.
78
+
79
+ If native audits do not report issues (which may happen in some headless environments) or if you need to check a specific element manually, use `evaluate_script` with the **"Check Color Contrast" snippet** found in [references/a11y-snippets.md](references/a11y-snippets.md).
80
+
81
+ ### 8. Global Page Checks
82
+
83
+ Verify document-level accessibility settings often missed in component testing using the **"Global Page Checks" snippet** found in [references/a11y-snippets.md](references/a11y-snippets.md).
84
+
85
+ ## Troubleshooting
86
+
87
+ If standard a11y queries fail or the `evaluate_script` snippets return unexpected results:
88
+
89
+ - **Visual Inspection**: If automated scripts cannot determine contrast (e.g., text over gradient images or complex backgrounds), use `take_screenshot` to capture the element. While models cannot measure exact contrast ratios from images, they can visually assess legibility and identify obvious issues.
@@ -0,0 +1,92 @@
1
+ # Accessibility Debugging Snippets
2
+
3
+ Use these JavaScript snippets with the `evaluate_script` tool.
4
+
5
+ ## 1. Find Orphaned Form Inputs
6
+
7
+ Finds form inputs that lack an associated label (no `label[for]`, `aria-label`, `aria-labelledby`, or wrapping `<label>`).
8
+
9
+ ```js
10
+ () =>
11
+ Array.from(document.querySelectorAll('input, select, textarea'))
12
+ .filter(i => {
13
+ const hasId = i.id && document.querySelector(`label[for="${i.id}"]`);
14
+ const hasAria =
15
+ i.getAttribute('aria-label') || i.getAttribute('aria-labelledby');
16
+ return !hasId && !hasAria && !i.closest('label');
17
+ })
18
+ .map(i => ({
19
+ tag: i.tagName,
20
+ id: i.id,
21
+ name: i.name,
22
+ placeholder: i.placeholder,
23
+ }));
24
+ ```
25
+
26
+ ## 2. Measure Tap Target Size
27
+
28
+ Returns the bounding box dimensions of an element. Pass the element's `uid` from the snapshot as an argument to `evaluate_script`.
29
+
30
+ ```js
31
+ el => {
32
+ const rect = el.getBoundingClientRect();
33
+ return {width: rect.width, height: rect.height};
34
+ };
35
+ ```
36
+
37
+ ## 3. Check Color Contrast
38
+
39
+ Approximates the contrast ratio between an element's text color and background color. Pass the element's `uid` to test against WCAG AA (4.5:1 for normal text, 3:1 for large text).
40
+
41
+ **Note**: This uses a simplified algorithm and may not account for transparency, gradients, or background images. For production-grade auditing, consider injecting `axe-core`.
42
+
43
+ ```js
44
+ el => {
45
+ function getRGB(colorStr) {
46
+ const match = colorStr.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
47
+ return match
48
+ ? [parseInt(match[1]), parseInt(match[2]), parseInt(match[3])]
49
+ : [255, 255, 255];
50
+ }
51
+ function luminance(r, g, b) {
52
+ const a = [r, g, b].map(function (v) {
53
+ v /= 255;
54
+ return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
55
+ });
56
+ return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
57
+ }
58
+
59
+ const style = window.getComputedStyle(el);
60
+ const fg = getRGB(style.color);
61
+ let bg = getRGB(style.backgroundColor);
62
+
63
+ const l1 = luminance(fg[0], fg[1], fg[2]);
64
+ const l2 = luminance(bg[0], bg[1], bg[2]);
65
+ const ratio = (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
66
+
67
+ return {
68
+ color: style.color,
69
+ bg: style.backgroundColor,
70
+ contrastRatio: ratio.toFixed(2),
71
+ };
72
+ };
73
+ ```
74
+
75
+ ## 4. Global Page Checks
76
+
77
+ Checks document-level accessibility settings often missed in component testing.
78
+
79
+ ```js
80
+ () => ({
81
+ lang:
82
+ document.documentElement.lang ||
83
+ 'MISSING - Screen readers need this for pronunciation',
84
+ title: document.title || 'MISSING - Required for context',
85
+ viewport:
86
+ document.querySelector('meta[name="viewport"]')?.content ||
87
+ 'MISSING - Check for user-scalable=no (bad practice)',
88
+ reducedMotion: window.matchMedia('(prefers-reduced-motion: reduce)').matches
89
+ ? 'Enabled'
90
+ : 'Disabled',
91
+ });
92
+ ```
@@ -0,0 +1,72 @@
1
+ ---
2
+ name: chrome-devtools
3
+ description: Uses Chrome DevTools via MCP for efficient debugging, troubleshooting and browser automation. Use when debugging web pages, automating browser interactions, analyzing performance, or inspecting network requests. This skill does not apply to `--slim` mode (MCP configuration).
4
+ ---
5
+
6
+ ## Core Concepts
7
+
8
+ **Browser lifecycle**: Browser starts automatically on first tool call using a persistent Chrome profile. Configure via CLI args in the MCP server configuration: `npx chrome-devtools-mcp@latest --help`.
9
+ Addional tooling can be enabled by providing the following flags:
10
+
11
+ - For extension tooling, use the `--categoryExtensions` flag.
12
+ - For memory tooling, use the `--memoryDebugging` flag.
13
+
14
+ **Page selection**: Tools operate on the currently selected page. Use `list_pages` to see available pages, then `select_page` to switch context.
15
+ **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
+ ## Workflow Patterns
18
+
19
+ ### Before interacting with a page
20
+
21
+ 1. Navigate: `navigate_page` or `new_page`
22
+ 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.
25
+
26
+ ### Efficient data retrieval
27
+
28
+ - Use `filePath` parameter for large outputs (screenshots, snapshots, traces)
29
+ - Use pagination (`pageIdx`, `pageSize`) and filtering (`types`) to minimize data
30
+ - Set `includeSnapshot: false` on input actions unless you need updated page state
31
+
32
+ ### Tool selection
33
+
34
+ - **Automation/interaction**: `take_snapshot` (text-based, faster, better for automation)
35
+ - **Visual inspection**: `take_screenshot` (when user needs to see visual state)
36
+ - **Additional details**: `evaluate_script` for data not in accessibility tree
37
+
38
+ ### Parallel execution
39
+
40
+ You can send multiple tool calls in parallel, but maintain correct order: navigate → wait → snapshot → interact.
41
+
42
+ ### Testing an extension
43
+
44
+ > **Before proceeding**: Extension tools (`install_extension`, `list_extensions`, etc.) are only available when the MCP server is started with the `--categoryExtensions` flag. If these tools are not in your tool list, stop and ask the user to update their MCP server configuration:
45
+ >
46
+ > ```json
47
+ > {
48
+ > "mcpServers": {
49
+ > "chrome-devtools": {
50
+ > "command": "npx",
51
+ > "args": ["chrome-devtools-mcp@latest", "--categoryExtensions"]
52
+ > }
53
+ > }
54
+ > }
55
+ > ```
56
+ >
57
+ > After updating, the user must restart the MCP server (or their AI client) for the change to take effect.
58
+
59
+ 1. **Install**: Use `install_extension` with the path to the unpacked extension.
60
+ 2. **Identify**: Get the extension ID from the response or by calling `list_extensions`.
61
+ 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
+ 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
+ ## Troubleshooting
66
+
67
+ If `chrome-devtools-mcp` is insufficient, guide users to use Chrome DevTools UI:
68
+
69
+ - https://developer.chrome.com/docs/devtools
70
+ - https://developer.chrome.com/docs/devtools/ai-assistance
71
+
72
+ If there are errors launching `chrome-devtools-mcp` or Chrome, refer to https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/main/docs/troubleshooting.md.
@@ -0,0 +1,153 @@
1
+ ---
2
+ name: chrome-devtools-cli
3
+ description: Use this skill to write shell scripts or run shell commands to automate tasks in the browser or otherwise use Chrome DevTools via CLI.
4
+ ---
5
+
6
+ The `chrome-devtools-mcp` CLI lets you interact with the browser from your terminal.
7
+
8
+ ## Setup
9
+
10
+ _Note: If this is your very first time using the CLI, see [references/installation.md](references/installation.md) for setup. Installation is a one-time prerequisite and is **not** part of the regular AI workflow._
11
+
12
+ ## AI Workflow
13
+
14
+ 1. **Execute**: Run tools directly (e.g., `chrome-devtools list_pages`). The background server starts implicitly; **do not** run `start`/`status`/`stop` before each use.
15
+ 2. **Inspect**: Use `take_snapshot` to get an element `<uid>`.
16
+ 3. **Act**: Use `click`, `fill`, etc. State persists across commands.
17
+
18
+ Snapshot example:
19
+
20
+ ```
21
+ uid=1_0 RootWebArea "Example Domain" url="https://example.com/"
22
+ uid=1_1 heading "Example Domain" level="1"
23
+ ```
24
+
25
+ ## Command Usage
26
+
27
+ ```sh
28
+ chrome-devtools <tool> [arguments] [flags]
29
+ ```
30
+
31
+ Use `--help` on any command. Output defaults to Markdown, use `--output-format=json` for JSON.
32
+
33
+ ## Input Automation (<uid> from snapshot)
34
+
35
+ ```bash
36
+ chrome-devtools take_snapshot --help # Help message for commands, works for any command.
37
+ chrome-devtools take_snapshot # Take a text snapshot of the page to get UIDs for elements
38
+ chrome-devtools click "id" # Clicks on the provided element
39
+ chrome-devtools click "id" --dblClick true --includeSnapshot true # Double clicks and returns a snapshot
40
+ chrome-devtools drag "src" "dst" # Drag an element onto another element
41
+ chrome-devtools drag "src" "dst" --includeSnapshot true # Drag an element and return a snapshot
42
+ chrome-devtools fill "id" "text" # Type text into an input or select an option
43
+ chrome-devtools fill "id" "text" --includeSnapshot true # Fill an element and return a snapshot
44
+ chrome-devtools handle_dialog accept # Handle a browser dialog
45
+ chrome-devtools handle_dialog dismiss --promptText "hi" # Dismiss a dialog with prompt text
46
+ chrome-devtools hover "id" # Hover over the provided element
47
+ chrome-devtools hover "id" --includeSnapshot true # Hover over an element and return a snapshot
48
+ chrome-devtools press_key "Enter" # Press a key or key combination
49
+ chrome-devtools press_key "Control+A" --includeSnapshot true # Press a key and return a snapshot
50
+ chrome-devtools type_text "hello" # Type text using keyboard into a focused input
51
+ chrome-devtools type_text "hello" --submitKey "Enter" # Type text and press a submit key
52
+ chrome-devtools upload_file "id" "file.txt" # Upload a file through a provided element
53
+ chrome-devtools upload_file "id" "file.txt" --includeSnapshot true # Upload a file and return a snapshot
54
+ ```
55
+
56
+ ## Navigation
57
+
58
+ ```bash
59
+ chrome-devtools close_page 1 # Closes the page by its index
60
+ 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 new_page "https://example.com" # Creates a new page
67
+ chrome-devtools new_page "https://example.com" --background true --timeout 5000 # Create new page in background
68
+ chrome-devtools new_page "https://example.com" --isolatedContext "ctx" # Create new page with isolated context
69
+ chrome-devtools select_page 1 # Select a page as a context for future tool calls
70
+ chrome-devtools select_page 1 --bringToFront true # Select a page and bring it to front
71
+ ```
72
+
73
+ ## Emulation
74
+
75
+ ```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
+ ```
82
+
83
+ ## Performance
84
+
85
+ ```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
+ chrome-devtools take_memory_snapshot "./snap.heapsnapshot" # Capture a memory heapsnapshot
92
+ ```
93
+
94
+ ## Network
95
+
96
+ ```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
104
+ ```
105
+
106
+ ## Debugging & Inspection
107
+
108
+ ```bash
109
+ chrome-devtools evaluate_script "() => document.title" # Evaluate a JavaScript function on the page
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
124
+ ```
125
+
126
+ ## Extensions
127
+
128
+ ```bash
129
+ chrome-devtools list_extensions # Lists all the Chrome extensions installed in the browser
130
+ chrome-devtools install_extension "/path/to/extension" # Installs a Chrome extension from the given path
131
+ chrome-devtools uninstall_extension "extension_id" # Uninstalls a Chrome extension by its ID
132
+ chrome-devtools reload_extension "extension_id" # Reloads an unpacked Chrome extension by its ID
133
+ chrome-devtools trigger_extension_action "extension_id" # Triggers the default action of an extension by its ID
134
+ ```
135
+
136
+ ## Experimental Features
137
+
138
+ Experimental tools are disabled by default. Enable them with the corresponding flag during `start`.
139
+
140
+ ```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)
145
+ ```
146
+
147
+ ## Service Management
148
+
149
+ ```bash
150
+ chrome-devtools start # Start or restart chrome-devtools-mcp
151
+ chrome-devtools status # Checks if chrome-devtools-mcp is running
152
+ chrome-devtools stop # Stop chrome-devtools-mcp if any
153
+ ```
@@ -0,0 +1,14 @@
1
+ # Installation
2
+
3
+ Install the package globally to make the `chrome-devtools` command available. You only need to do this the first time you use it.
4
+
5
+ ```sh
6
+ npm i chrome-devtools-mcp@latest -g
7
+ chrome-devtools status # check if install worked.
8
+ ```
9
+
10
+ ## Troubleshooting
11
+
12
+ - **Command not found:** If `chrome-devtools` is not recognized, ensure your global npm `bin` directory is in your system's `PATH`. Restart your terminal or source your shell configuration file (e.g., `.bashrc`, `.zshrc`).
13
+ - **Permission errors:** If you encounter `EACCES` or permission errors during installation, avoid using `sudo`. Instead, use a node version manager like `nvm`, or configure npm to use a different global directory.
14
+ - **Old version running:** Run `chrome-devtools stop && npm uninstall -g chrome-devtools-mcp` before reinstalling, or ensure the latest version is being picked up by your path.