chrome-devtools-mcp 1.10.1 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/README.md +72 -20
  2. package/build/src/BrowserManager.js +155 -27
  3. package/build/src/McpContext.js +598 -200
  4. package/build/src/McpPage.js +513 -131
  5. package/build/src/McpResponse.js +291 -116
  6. package/build/src/McpWorker.js +66 -0
  7. package/build/src/SlimMcpResponse.js +5 -1
  8. package/build/src/TextSnapshot.js +40 -20
  9. package/build/src/ToolHandler.js +306 -147
  10. package/build/src/bin/chrome-devtools-mcp-main.js +13 -10
  11. package/build/src/bin/chrome-devtools-mcp.js +1 -1
  12. package/build/src/bin/chrome-devtools.js +34 -44
  13. package/build/src/collectors/PageCollector.js +13 -9
  14. package/build/src/collectors/ServiceWorkerCollector.js +20 -13
  15. package/build/src/collectors/constants.js +7 -0
  16. package/build/src/config/ConfigLocator.js +70 -0
  17. package/build/src/config/ConfigParser.js +159 -0
  18. package/build/src/config/ConfigWatcher.js +94 -0
  19. package/build/src/config/ServerConfig.js +251 -0
  20. package/build/src/config/browser-options.js +15 -17
  21. package/build/src/config/category-options.js +15 -30
  22. package/build/src/config/cli-commands.js +165 -5
  23. package/build/src/config/cli-options.js +441 -58
  24. package/build/src/config/mcp-options.js +212 -264
  25. package/build/src/config/puppeteer-options.js +67 -0
  26. package/build/src/config/tool-options.js +60 -0
  27. package/build/src/daemon/client.js +84 -44
  28. package/build/src/daemon/daemon.js +59 -45
  29. package/build/src/daemon/utils.js +46 -12
  30. package/build/src/devtools/DevToolsCommentBridge.js +71 -11
  31. package/build/src/devtools/DevtoolsUtils.js +52 -15
  32. package/build/src/devtools/McpHostBindingAdapter.js +0 -1
  33. package/build/src/formatters/CommentFormatter.js +4 -13
  34. package/build/src/formatters/ConsoleFormatter.js +29 -2
  35. package/build/src/formatters/CssFormatter.js +3 -2
  36. package/build/src/formatters/HeapSnapshotFormatter.js +111 -57
  37. package/build/src/formatters/IssueFormatter.js +33 -32
  38. package/build/src/formatters/NetworkFormatter.js +62 -22
  39. package/build/src/formatters/RemoteObjectFormatter.js +231 -0
  40. package/build/src/formatters/SnapshotFormatter.js +44 -7
  41. package/build/src/index.js +285 -88
  42. package/build/src/processors/ChunkedTraceParser.js +11 -11
  43. package/build/src/processors/HeapSnapshotManager.js +455 -156
  44. package/build/src/processors/PerformanceTrace.js +9 -9
  45. package/build/src/telemetry/ClearcutLogger.js +1 -1
  46. package/build/src/telemetry/transformation.js +7 -11
  47. package/build/src/telemetry/watchdog/main.js +1 -1
  48. package/build/src/third_party/THIRD_PARTY_NOTICES +399 -689
  49. package/build/src/third_party/bundled-packages.json +7 -8
  50. package/build/src/third_party/cli.js +9239 -0
  51. package/build/src/third_party/devtools-formatter-worker.js +4299 -2517
  52. package/build/src/third_party/devtools-heap-snapshot-worker.js +1298 -22
  53. package/build/src/third_party/index.js +132003 -146852
  54. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantRead.md +0 -1
  55. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantReadOptOut.md +5 -0
  56. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantSet.md +0 -1
  57. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantSetOptOut.md +5 -0
  58. package/build/src/third_party/issue-descriptions/deprecation.md +1 -1
  59. package/build/src/third_party/issue-descriptions/genericGeolocationPromptWithoutUserGesture.md +5 -0
  60. package/build/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +2 -0
  61. package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +54576 -52174
  62. package/build/src/tools/ToolDefinition.js +102 -12
  63. package/build/src/tools/comments.js +62 -4
  64. package/build/src/tools/console.js +6 -4
  65. package/build/src/tools/css.js +5 -2
  66. package/build/src/tools/emulation.js +22 -8
  67. package/build/src/tools/extensions.js +5 -0
  68. package/build/src/tools/input.js +29 -9
  69. package/build/src/tools/lighthouse.js +136 -12
  70. package/build/src/tools/memory.js +166 -59
  71. package/build/src/tools/network.js +5 -4
  72. package/build/src/tools/pages.js +52 -7
  73. package/build/src/tools/performance.js +28 -7
  74. package/build/src/tools/pwa.js +7 -0
  75. package/build/src/tools/screencast.js +74 -33
  76. package/build/src/tools/screenshot.js +52 -21
  77. package/build/src/tools/script.js +125 -40
  78. package/build/src/tools/slim/tools.js +27 -13
  79. package/build/src/tools/snapshot.js +13 -3
  80. package/build/src/tools/thirdPartyDeveloper.js +9 -5
  81. package/build/src/tools/tools.js +35 -22
  82. package/build/src/tools/webmcp.js +11 -6
  83. package/build/src/types.js +11 -0
  84. package/build/src/utils/TaskRunner.js +136 -0
  85. package/build/src/utils/WaitForHelper.js +15 -2
  86. package/build/src/utils/bytes.js +2 -12
  87. package/build/src/utils/check-for-updates.js +2 -2
  88. package/build/src/utils/disclaimers.js +27 -0
  89. package/build/src/utils/errorHandling.js +20 -0
  90. package/build/src/utils/keyboard.js +14 -2
  91. package/build/src/utils/logger.js +84 -5
  92. package/build/src/utils/resourceType.js +27 -0
  93. package/build/src/utils/text.js +44 -0
  94. package/build/src/utils/timeout.js +14 -0
  95. package/build/src/utils/url.js +140 -3
  96. package/build/src/version.js +1 -1
  97. package/package.json +16 -11
  98. package/skills/a11y-debugging/SKILL.md +7 -12
  99. package/skills/chrome-devtools/SKILL.md +2 -2
  100. package/skills/chrome-devtools-cli/SKILL.md +18 -15
  101. package/skills/cookie-debugging/SKILL.md +8 -5
  102. package/skills/debug-optimize-lcp/SKILL.md +1 -1
  103. package/skills/troubleshooting/SKILL.md +5 -6
@@ -55,13 +55,14 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
55
55
  var e = new Error(message);
56
56
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
57
57
  });
58
- import { zod } from '../third_party/index.js';
58
+ import { pathToFileURL } from 'node:url';
59
+ import { zod, } from '../third_party/index.js';
59
60
  import { ToolCategory } from './categories.js';
60
- import { defineTool, pageIdSchema } from './ToolDefinition.js';
61
+ import { defineTool, pageIdSchema, } from './ToolDefinition.js';
61
62
  export const evaluateScript = defineTool((cliArgs) => {
62
63
  return {
63
64
  name: 'evaluate_script',
64
- description: `Evaluate a JavaScript function inside the target page${cliArgs.categoryExtensions ? ' or service worker' : ''}. Returns the response as JSON, so returned values have to be JSON-serializable.`,
65
+ description: `Evaluate JavaScript inside the target page${cliArgs.categoryExtensions ? ' or service worker' : ''}. The source can be provided inline or loaded from a local file. Returns the response as JSON, so returned values have to be JSON-serializable.`,
65
66
  annotations: {
66
67
  category: ToolCategory.DEBUGGING,
67
68
  readOnlyHint: false,
@@ -78,16 +79,27 @@ export const evaluateScript = defineTool((cliArgs) => {
78
79
  }
79
80
  : pageIdSchema
80
81
  : {}),
81
- function: zod.string().describe(`A JavaScript function declaration to be executed by the tool in the target page.
82
+ function: zod
83
+ .string()
84
+ .optional()
85
+ .describe(`JavaScript source to execute in the target page. Provide either this or sourcePath, but not both. The source is interpreted according to format.
82
86
  Example without arguments: \`() => document.title\` or \`async () => await fetch("example.com")\`.
83
87
  Example with arguments: \`(el) => el.innerText\`
84
88
  `),
89
+ sourcePath: zod
90
+ .string()
91
+ .optional()
92
+ .describe("The absolute or relative path to a JavaScript file on the MCP server's local filesystem. Provide either this or function, but not both."),
93
+ format: zod
94
+ .enum(['function', 'script'])
95
+ .optional()
96
+ .describe('How to interpret the source. "function" treats it as a function declaration and supports args. "script" evaluates it as classic JavaScript and does not support args. Defaults to "function". ECMAScript modules are not supported.'),
85
97
  args: zod
86
98
  .array(zod
87
99
  .string()
88
100
  .describe('The uid of an element on the page from the page content snapshot'))
89
101
  .optional()
90
- .describe(`An optional list of arguments to pass to the function.`),
102
+ .describe(`An optional list of arguments (element uids from the page content snapshot) to pass to the function.`),
91
103
  filePath: zod
92
104
  .string()
93
105
  .optional()
@@ -109,14 +121,22 @@ Example with arguments: \`(el) => el.innerText\`
109
121
  }
110
122
  : {}),
111
123
  },
112
- blockedByDialog: true,
124
+ blockedByDialog: false,
125
+ concurrency: 'exclusive',
113
126
  verifyFilesSchema: {
114
127
  filePath: true,
128
+ // sourcePath may be an http(s): URL the server fetches, so allow URLs
129
+ // through; a file: path or plain path is still validated.
130
+ sourcePath: { local: true, remote: true, allowUrl: true },
115
131
  },
116
132
  handler: async (request, response, context) => {
117
133
  const env_1 = { stack: [], error: void 0, hasError: false };
118
134
  try {
119
- const { serviceWorkerId, args: uidArgs, function: fnString, pageId, dialogAction, filePath, waitForStableDom, } = request.params;
135
+ const { serviceWorkerId, args: uidArgs, function: fnString, sourcePath, format = 'function', pageId, dialogAction, filePath, waitForStableDom, } = request.params;
136
+ const source = await resolveScriptSource(fnString, sourcePath, context);
137
+ if (format === 'script' && uidArgs && uidArgs.length > 0) {
138
+ throw new Error('args cannot be used when format is "script".');
139
+ }
120
140
  if (cliArgs.categoryExtensions && serviceWorkerId) {
121
141
  if (uidArgs && uidArgs.length > 0) {
122
142
  throw new Error('args (element uids) cannot be used when evaluating in a service worker.');
@@ -128,7 +148,7 @@ Example with arguments: \`(el) => el.innerText\`
128
148
  const result = await context
129
149
  .getSelectedMcpPage()
130
150
  .waitForEventsAfterAction(async () => {
131
- await performEvaluation(worker, fnString, [], response, {
151
+ await performEvaluation(worker, source, format, [], response, {
132
152
  filePath,
133
153
  context,
134
154
  });
@@ -147,6 +167,13 @@ Example with arguments: \`(el) => el.innerText\`
147
167
  const mcpPage = cliArgs.pageIdRouting && request.params.pageId
148
168
  ? context.getPageById(request.params.pageId)
149
169
  : context.getSelectedMcpPage();
170
+ await mcpPage.init({ emulateFocus: true });
171
+ // evaluate_script is not page-scoped, so ToolHandler does not run the
172
+ // blockedByDialog check for it. Without this, an evaluation started
173
+ // while a dialog is open waits until the protocol timeout.
174
+ // TODO: include the "# Open dialog ... Call handle_dialog" hint once
175
+ // Response can attach the page for non-page-scoped tools.
176
+ mcpPage.throwIfDialogOpen();
150
177
  const page = mcpPage.pptrPage;
151
178
  const args = [];
152
179
  const stack = __addDisposableResource(env_1, new DisposableStack(), false);
@@ -159,7 +186,7 @@ Example with arguments: \`(el) => el.innerText\`
159
186
  }
160
187
  const evaluatable = await getPageOrFrame(page, frames);
161
188
  const result = await mcpPage.waitForEventsAfterAction(async () => {
162
- await performEvaluation(evaluatable, fnString, args, response, {
189
+ await performEvaluation(evaluatable, source, format, args, response, {
163
190
  filePath,
164
191
  context,
165
192
  });
@@ -176,32 +203,93 @@ Example with arguments: \`(el) => el.innerText\`
176
203
  },
177
204
  };
178
205
  });
179
- const performEvaluation = async (evaluatable, fnString, args, response, options) => {
180
- const env_2 = { stack: [], error: void 0, hasError: false };
206
+ const resolveScriptSource = async (inlineSource, sourcePath, context) => {
207
+ if (inlineSource !== undefined) {
208
+ if (sourcePath !== undefined) {
209
+ throw new Error('Specify exactly one of function or sourcePath.');
210
+ }
211
+ return inlineSource;
212
+ }
213
+ if (sourcePath === undefined) {
214
+ throw new Error('Specify exactly one of function or sourcePath.');
215
+ }
216
+ const resourceUrl = sourcePath.startsWith('file:')
217
+ ? sourcePath
218
+ : pathToFileURL(sourcePath).href;
181
219
  try {
182
- const fn = __addDisposableResource(env_2, await evaluatable.evaluateHandle(`(${fnString})`), false);
183
- const result = await evaluatable.evaluate(async (fn, ...args) => {
184
- // @ts-expect-error no types for function fn
185
- return JSON.stringify(await fn(...args));
186
- }, fn, ...args);
187
- if (options?.filePath) {
188
- const data = new TextEncoder().encode(result ?? 'undefined');
189
- const { filename } = await options.context.saveFile(data, options.filePath, '.json');
190
- response.appendResponseLine(`Script ran on page. Output saved to ${filename}.`);
220
+ return await context.loadResource(resourceUrl);
221
+ }
222
+ catch (error) {
223
+ const errorMessage = error instanceof Error ? error.message : String(error);
224
+ throw new Error(`Unable to read script source from ${sourcePath}: ${errorMessage}`, { cause: error });
225
+ }
226
+ };
227
+ const performEvaluation = async (evaluatable, source, format, args, response, options) => {
228
+ let result;
229
+ if (format === 'function') {
230
+ const env_2 = { stack: [], error: void 0, hasError: false };
231
+ try {
232
+ const functionSource = source.trimEnd().replace(/;$/, '');
233
+ const fn = __addDisposableResource(env_2, await evaluatable.evaluateHandle(`(\n${functionSource}\n)`), false);
234
+ // Normalize non-Error values inside the page callback (serialized by Puppeteer) so CDP preserves the message.
235
+ result = await evaluatable.evaluate(async (fn, ...args) => {
236
+ try {
237
+ return JSON.stringify(await fn(...args));
238
+ }
239
+ catch (err) {
240
+ if (err instanceof Error ||
241
+ (typeof err === 'object' &&
242
+ err !== null &&
243
+ 'message' in err &&
244
+ typeof err.message === 'string')) {
245
+ throw err;
246
+ }
247
+ let message;
248
+ try {
249
+ message =
250
+ typeof err === 'object' && err !== null
251
+ ? JSON.stringify(err)
252
+ : String(err);
253
+ }
254
+ catch {
255
+ message = String(err);
256
+ }
257
+ throw new Error(message);
258
+ }
259
+ }, fn, ...args);
260
+ }
261
+ catch (e_2) {
262
+ env_2.error = e_2;
263
+ env_2.hasError = true;
264
+ }
265
+ finally {
266
+ __disposeResources(env_2);
267
+ }
268
+ }
269
+ else {
270
+ const env_3 = { stack: [], error: void 0, hasError: false };
271
+ try {
272
+ const value = __addDisposableResource(env_3, await evaluatable.evaluateHandle(source), false);
273
+ result = await evaluatable.evaluate(value => JSON.stringify(value), value);
274
+ }
275
+ catch (e_3) {
276
+ env_3.error = e_3;
277
+ env_3.hasError = true;
191
278
  }
192
- else {
193
- response.appendResponseLine('Script ran on page and returned:');
194
- response.appendResponseLine('```json');
195
- response.appendResponseLine(`${result}`);
196
- response.appendResponseLine('```');
279
+ finally {
280
+ __disposeResources(env_3);
197
281
  }
198
282
  }
199
- catch (e_2) {
200
- env_2.error = e_2;
201
- env_2.hasError = true;
283
+ if (options.filePath) {
284
+ const data = new TextEncoder().encode(result ?? 'undefined');
285
+ const { filename } = await options.context.saveFile(data, options.filePath, '.json');
286
+ response.appendResponseLine(`Script ran on page. Output saved to ${filename}.`);
202
287
  }
203
- finally {
204
- __disposeResources(env_2);
288
+ else {
289
+ response.appendResponseLine('Script ran on page and returned:');
290
+ response.appendResponseLine('```json');
291
+ response.appendResponseLine(`${result}`);
292
+ response.appendResponseLine('```');
205
293
  }
206
294
  };
207
295
  const getPageOrFrame = async (page, frames) => {
@@ -216,17 +304,14 @@ const getPageOrFrame = async (page, frames) => {
216
304
  return pageOrFrame;
217
305
  };
218
306
  const getWebWorker = async (context, serviceWorkerId) => {
219
- const serviceWorkers = context.getExtensionServiceWorkers();
220
- const serviceWorker = serviceWorkers.find((sw) => context.getExtensionServiceWorkerId(sw) === serviceWorkerId);
221
- if (serviceWorker && serviceWorker.target) {
222
- const worker = await serviceWorker.target.worker();
223
- if (!worker) {
224
- throw new Error('Service worker target not found.');
225
- }
226
- return worker;
227
- }
228
- else {
307
+ const serviceWorker = context.getWorkerById(serviceWorkerId);
308
+ if (!serviceWorker || serviceWorker.type !== 'service_worker') {
229
309
  throw new Error('Service worker not found.');
230
310
  }
311
+ const worker = await serviceWorker.worker();
312
+ if (!worker) {
313
+ throw new Error('Service worker target not found.');
314
+ }
315
+ return worker;
231
316
  };
232
317
  //# sourceMappingURL=script.js.map
@@ -9,23 +9,38 @@ import { definePageTool } from '../ToolDefinition.js';
9
9
  import { validateUrl } from '../../utils/url.js';
10
10
  export const screenshot = definePageTool(() => ({
11
11
  name: 'screenshot',
12
- description: `Takes a screenshot`,
12
+ description: `Takes a png screenshot`,
13
13
  annotations: {
14
14
  category: ToolCategory.DEBUGGING,
15
15
  // Not read-only due to filePath param.
16
16
  readOnlyHint: false,
17
+ conditions: ['slim'],
18
+ },
19
+ schema: {
20
+ filePath: zod
21
+ .string()
22
+ .optional()
23
+ .describe('The absolute path, or a path relative to the current working directory, to save the screenshot to instead of attaching it to the response.'),
17
24
  },
18
- schema: {},
19
25
  blockedByDialog: true,
20
- verifyFilesSchema: {},
26
+ concurrency: 'page',
27
+ verifyFilesSchema: {
28
+ filePath: true,
29
+ },
21
30
  handler: async (request, response, context) => {
22
31
  const page = request.page;
23
32
  const screenshot = await page.pptrPage.screenshot({
24
33
  type: 'png',
25
34
  optimizeForSpeed: true,
26
35
  });
27
- const { filepath } = await context.saveTemporaryFile(screenshot, `screenshot.png`);
28
- response.appendResponseLine(filepath);
36
+ if (request.params.filePath) {
37
+ const result = await context.saveFile(screenshot, request.params.filePath, '.png');
38
+ response.appendResponseLine(result.filename);
39
+ }
40
+ else {
41
+ const { filepath } = await context.saveTemporaryFile(screenshot, `screenshot.png`);
42
+ response.appendResponseLine(filepath);
43
+ }
29
44
  },
30
45
  }));
31
46
  export const navigate = definePageTool((args) => {
@@ -35,16 +50,19 @@ export const navigate = definePageTool((args) => {
35
50
  annotations: {
36
51
  category: ToolCategory.NAVIGATION,
37
52
  readOnlyHint: false,
53
+ conditions: ['slim'],
38
54
  },
39
55
  schema: {
40
56
  url: zod.string().describe('URL to navigate to'),
41
57
  },
42
58
  blockedByDialog: false,
59
+ concurrency: 'page',
43
60
  verifyFilesSchema: {},
44
61
  handler: async (request, response) => {
45
62
  validateUrl(request.params.url, {
46
63
  javascriptEvaluation: args?.javascriptEvaluation,
47
64
  categoryExtensions: args?.categoryExtensions,
65
+ fileNavigations: args?.fileNavigations,
48
66
  });
49
67
  const page = request.page;
50
68
  const options = {
@@ -75,22 +93,18 @@ export const evaluate = definePageTool(() => ({
75
93
  annotations: {
76
94
  category: ToolCategory.DEBUGGING,
77
95
  readOnlyHint: false,
78
- conditions: ['javascriptEvaluation'],
96
+ conditions: ['slim', 'javascriptEvaluation'],
79
97
  },
80
98
  schema: {
81
99
  script: zod.string().describe(`JS script to run on the page`),
82
100
  },
83
101
  blockedByDialog: true,
102
+ concurrency: 'page',
84
103
  verifyFilesSchema: {},
85
104
  handler: async (request, response) => {
86
105
  const page = request.page;
87
- try {
88
- const result = await page.pptrPage.evaluate(request.params.script);
89
- response.appendResponseLine(JSON.stringify(result));
90
- }
91
- catch (err) {
92
- response.appendResponseLine(String(err.message));
93
- }
106
+ const result = await page.pptrPage.evaluate(request.params.script);
107
+ response.appendResponseLine(JSON.stringify(result));
94
108
  },
95
109
  }));
96
110
  //# sourceMappingURL=tools.js.map
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { zod } from '../third_party/index.js';
7
7
  import { ToolCategory } from './categories.js';
8
- import { definePageTool, timeoutSchema } from './ToolDefinition.js';
8
+ import { definePageTool, timeoutSchema, } from './ToolDefinition.js';
9
9
  export const takeSnapshot = definePageTool(() => ({
10
10
  name: 'take_snapshot',
11
11
  description: `Take a text snapshot of the target page based on the a11y tree. The snapshot lists page elements along with a unique
@@ -27,6 +27,7 @@ in the DevTools Elements panel (if any).`,
27
27
  .describe('The absolute path, or a path relative to the current working directory, to save the snapshot to instead of attaching it to the response.'),
28
28
  },
29
29
  blockedByDialog: true,
30
+ concurrency: 'page',
30
31
  verifyFilesSchema: {
31
32
  filePath: true,
32
33
  },
@@ -39,7 +40,7 @@ in the DevTools Elements panel (if any).`,
39
40
  }));
40
41
  export const waitFor = definePageTool(() => ({
41
42
  name: 'wait_for',
42
- description: `Wait for the specified text to appear on the selected page.`,
43
+ description: `Wait for the specified text to appear on the selected page. By default, hidden text is also matched. Set visible to true to wait until the matched text is visible.`,
43
44
  annotations: {
44
45
  category: ToolCategory.NAVIGATION,
45
46
  readOnlyHint: true,
@@ -50,12 +51,21 @@ export const waitFor = definePageTool(() => ({
50
51
  .min(1)
51
52
  .describe('Non-empty list of texts. Resolves when any value appears on the page.'),
52
53
  ...timeoutSchema,
54
+ visible: zod
55
+ .boolean()
56
+ .default(false)
57
+ .optional()
58
+ .describe('If true, wait until the matching text is visible. By default, hidden text also counts.'),
53
59
  },
54
60
  blockedByDialog: true,
61
+ concurrency: 'page',
55
62
  verifyFilesSchema: {},
56
63
  handler: async (request, response) => {
57
64
  const page = request.page;
58
- await page.waitForTextOnPage(request.params.text, request.params.timeout);
65
+ await page.waitForTextOnPage(request.params.text, {
66
+ timeout: request.params.timeout,
67
+ visible: request.params.visible,
68
+ });
59
69
  response.appendResponseLine(`Element matching one of ${JSON.stringify(request.params.text)} found.`);
60
70
  response.includeSnapshot();
61
71
  },
@@ -8,9 +8,9 @@ import { ToolCategory } from './categories.js';
8
8
  import { definePageTool } from './ToolDefinition.js';
9
9
  export const listThirdPartyDeveloperTools = definePageTool(() => ({
10
10
  name: 'list_3p_developer_tools',
11
- description: `Lists all third-party developer tools the page exposes for providing runtime information.
11
+ description: `Lists all third-party developer tools the page exposes for providing runtime information (including debugging WebMCP tools and tools exposed via the 'devtoolstooldiscovery' event).
12
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
13
+ Alternatively, third-party developer tools exposed via the 'devtoolstooldiscovery' event can be executed by calling 'evaluate_script' and adding the
14
14
  following command to the script:
15
15
  \`window.__dtmcp.executeTool(toolName, params)\`
16
16
  This might be helpful when the third-party developer tools return non-serializable values or when composing
@@ -21,6 +21,7 @@ third-party developer tools with additional functionality.`,
21
21
  },
22
22
  schema: {},
23
23
  blockedByDialog: false,
24
+ concurrency: 'page',
24
25
  verifyFilesSchema: {},
25
26
  handler: async (_request, response) => {
26
27
  response.setListThirdPartyDeveloperTools();
@@ -28,7 +29,7 @@ third-party developer tools with additional functionality.`,
28
29
  }));
29
30
  export const executeThirdPartyDeveloperTool = definePageTool(() => ({
30
31
  name: 'execute_3p_developer_tool',
31
- description: `Executes a tool exposed by the page.`,
32
+ description: `Executes a third-party developer tool exposed by the page.`,
32
33
  annotations: {
33
34
  category: ToolCategory.THIRD_PARTY,
34
35
  readOnlyHint: false,
@@ -41,6 +42,7 @@ export const executeThirdPartyDeveloperTool = definePageTool(() => ({
41
42
  .describe('The JSON-stringified parameters to pass to the tool'),
42
43
  },
43
44
  blockedByDialog: false,
45
+ concurrency: 'page',
44
46
  verifyFilesSchema: {},
45
47
  handler: async (request, response) => {
46
48
  const toolName = request.params.toolName;
@@ -48,7 +50,9 @@ export const executeThirdPartyDeveloperTool = definePageTool(() => ({
48
50
  if (request.params.params) {
49
51
  try {
50
52
  const parsed = JSON.parse(request.params.params);
51
- if (typeof parsed === 'object' && parsed !== null) {
53
+ if (typeof parsed === 'object' &&
54
+ parsed !== null &&
55
+ !Array.isArray(parsed)) {
52
56
  params = parsed;
53
57
  }
54
58
  else {
@@ -60,7 +64,7 @@ export const executeThirdPartyDeveloperTool = definePageTool(() => ({
60
64
  throw new Error(`Failed to parse params as JSON: ${errorMessage}`);
61
65
  }
62
66
  }
63
- const toolGroups = request.page.getThirdPartyDeveloperTools();
67
+ const toolGroups = await request.page.discoverThirdPartyDeveloperTools();
64
68
  let tool;
65
69
  if (toolGroups) {
66
70
  for (const group of toolGroups) {
@@ -3,6 +3,7 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import { mcpOptions } from '../config/mcp-options.js';
6
7
  import * as commentsTools from './comments.js';
7
8
  import * as consoleTools from './console.js';
8
9
  import * as cssTools from './css.js';
@@ -23,28 +24,27 @@ import * as snapshotTools from './snapshot.js';
23
24
  import * as thirdPartyDeveloperTools from './thirdPartyDeveloper.js';
24
25
  import * as webmcpTools from './webmcp.js';
25
26
  export const createTools = (args) => {
26
- const rawTools = args.slim
27
- ? Object.values(slimTools)
28
- : [
29
- ...(args.devtoolsComments ? Object.values(commentsTools) : []),
30
- ...Object.values(consoleTools),
31
- ...Object.values(cssTools),
32
- ...Object.values(emulationTools),
33
- ...Object.values(extensionTools),
34
- ...Object.values(inputTools),
35
- ...Object.values(lighthouseTools),
36
- ...Object.values(memoryTools),
37
- ...Object.values(networkTools),
38
- ...Object.values(pagesTools),
39
- ...Object.values(performanceTools),
40
- ...Object.values(pwaTools),
41
- ...Object.values(screencastTools),
42
- ...Object.values(screenshotTools),
43
- ...Object.values(scriptTools),
44
- ...Object.values(snapshotTools),
45
- ...Object.values(thirdPartyDeveloperTools),
46
- ...Object.values(webmcpTools),
47
- ];
27
+ const rawTools = [
28
+ ...Object.values(commentsTools),
29
+ ...Object.values(consoleTools),
30
+ ...Object.values(cssTools),
31
+ ...Object.values(emulationTools),
32
+ ...Object.values(extensionTools),
33
+ ...Object.values(inputTools),
34
+ ...Object.values(lighthouseTools),
35
+ ...Object.values(memoryTools),
36
+ ...Object.values(networkTools),
37
+ ...Object.values(pagesTools),
38
+ ...Object.values(performanceTools),
39
+ ...Object.values(pwaTools),
40
+ ...Object.values(screencastTools),
41
+ ...Object.values(screenshotTools),
42
+ ...Object.values(scriptTools),
43
+ ...Object.values(slimTools),
44
+ ...Object.values(snapshotTools),
45
+ ...Object.values(thirdPartyDeveloperTools),
46
+ ...Object.values(webmcpTools),
47
+ ];
48
48
  const tools = [];
49
49
  for (const tool of rawTools) {
50
50
  tools.push(tool(args));
@@ -52,4 +52,17 @@ export const createTools = (args) => {
52
52
  tools.sort((a, b) => a.name.localeCompare(b.name));
53
53
  return tools;
54
54
  };
55
+ /**
56
+ * Returns true if the tool is gated behind a hidden (internal) flag. Such
57
+ * tools are excluded from the generated documentation and CLI.
58
+ */
59
+ export function requiresHiddenFlag(tool) {
60
+ for (const condition of tool.annotations.conditions ?? []) {
61
+ const option = mcpOptions[condition];
62
+ if (option.hidden) {
63
+ return true;
64
+ }
65
+ }
66
+ return false;
67
+ }
55
68
  //# sourceMappingURL=tools.js.map
@@ -8,13 +8,14 @@ import { ToolCategory } from './categories.js';
8
8
  import { definePageTool } from './ToolDefinition.js';
9
9
  export const listWebMcpTools = definePageTool(() => ({
10
10
  name: 'list_webmcp_tools',
11
- description: `Lists all WebMCP tools the page exposes.`,
11
+ description: `Lists all WebMCP tools the page exposes (excluding debugging tools, which are exposed via 'list_3p_developer_tools').`,
12
12
  annotations: {
13
13
  category: ToolCategory.WEBMCP,
14
14
  readOnlyHint: true,
15
15
  },
16
16
  schema: {},
17
17
  blockedByDialog: false,
18
+ concurrency: 'page',
18
19
  verifyFilesSchema: {},
19
20
  handler: async (_request, response) => {
20
21
  response.setListWebMcpTools();
@@ -22,7 +23,7 @@ export const listWebMcpTools = definePageTool(() => ({
22
23
  }));
23
24
  export const executeWebMcpTool = definePageTool(() => ({
24
25
  name: 'execute_webmcp_tool',
25
- description: `Executes a WebMCP tool exposed by the page.`,
26
+ description: `Executes a WebMCP tool exposed by the page (for debugging tools, use 'execute_3p_developer_tool').`,
26
27
  annotations: {
27
28
  category: ToolCategory.WEBMCP,
28
29
  readOnlyHint: false,
@@ -35,6 +36,7 @@ export const executeWebMcpTool = definePageTool(() => ({
35
36
  .describe('The JSON-stringified parameters to pass to the WebMCP tool'),
36
37
  },
37
38
  blockedByDialog: false,
39
+ concurrency: 'page',
38
40
  verifyFilesSchema: {},
39
41
  handler: async (request, response) => {
40
42
  const toolName = request.params.toolName;
@@ -42,7 +44,9 @@ export const executeWebMcpTool = definePageTool(() => ({
42
44
  if (request.params.input) {
43
45
  try {
44
46
  const parsed = JSON.parse(request.params.input);
45
- if (typeof parsed === 'object' && parsed !== null) {
47
+ if (typeof parsed === 'object' &&
48
+ parsed !== null &&
49
+ !Array.isArray(parsed)) {
46
50
  input = parsed;
47
51
  }
48
52
  else {
@@ -54,13 +58,14 @@ export const executeWebMcpTool = definePageTool(() => ({
54
58
  throw new Error(`Failed to parse input as JSON: ${errorMessage}`);
55
59
  }
56
60
  }
57
- const tools = request.page.pptrPage.webmcp.tools();
61
+ const tools = request.page.getWebMcpTools();
58
62
  const tool = tools.find(t => t.name === toolName);
59
63
  if (!tool) {
60
64
  throw new Error(`Tool ${toolName} not found`);
61
65
  }
62
- const { status, output, errorText } = await tool.execute(input);
63
- response.appendResponseLine(JSON.stringify({ status, output, errorText }, null, 2));
66
+ const { status, output, errorText, exception } = await tool.execute(input);
67
+ const error = exception?.description ?? exception?.value ?? errorText;
68
+ response.appendResponseLine(JSON.stringify({ status, output, error }, null, 2));
64
69
  },
65
70
  }));
66
71
  //# sourceMappingURL=webmcp.js.map
@@ -3,6 +3,17 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ export const FORCED_COLORS_VALUES = ['active', 'none'];
7
+ export const PREFERS_CONTRAST_VALUES = [
8
+ 'more',
9
+ 'less',
10
+ 'custom',
11
+ 'no-preference',
12
+ ];
13
+ export const PREFERS_REDUCED_MOTION_VALUES = [
14
+ 'reduce',
15
+ 'no-preference',
16
+ ];
6
17
  export var CD4ABridgeEvents;
7
18
  (function (CD4ABridgeEvents) {
8
19
  CD4ABridgeEvents["COMMENT_THREADS_CHANGED"] = "CommentThreadsChanged";