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
@@ -55,7 +55,7 @@ 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 { TimeoutError, zod } from '../third_party/index.js';
59
59
  import { parseKey } from '../utils/keyboard.js';
60
60
  import { logger } from '../utils/logger.js';
61
61
  import { ToolCategory } from './categories.js';
@@ -72,13 +72,28 @@ const submitKeySchema = zod
72
72
  .string()
73
73
  .optional()
74
74
  .describe('Optional key to press after typing. E.g., "Enter", "Tab", "Escape"');
75
- function handleActionError(error, uid) {
75
+ /**
76
+ * Locator actions abort or time out while the page is blocked by a JavaScript
77
+ * dialog, even though the action itself was dispatched and opened that dialog.
78
+ * The open dialog is already reported in the response, so treat this as an
79
+ * interruption instead of a failure.
80
+ */
81
+ function handleActionError(error, uid, page) {
82
+ if (page.getDialog()) {
83
+ logger?.('action interrupted by a dialog', error);
84
+ return;
85
+ }
76
86
  logger?.('failed to act using a locator', error);
77
- throw new Error(`Failed to interact with the element with uid ${uid}. The element did not become interactive within the configured timeout.`, {
87
+ const reason = error instanceof TimeoutError
88
+ ? 'The element did not become interactive within the configured timeout.'
89
+ : error instanceof Error
90
+ ? error.message
91
+ : String(error);
92
+ throw new Error(`Failed to interact with the element with uid ${uid}. ${reason}`, {
78
93
  cause: error,
79
94
  });
80
95
  }
81
- async function selectNativeSelectOption(handle) {
96
+ async function selectNativeSelectOption(handle, signal) {
82
97
  const env_1 = { stack: [], error: void 0, hasError: false };
83
98
  try {
84
99
  const selectHandle = __addDisposableResource(env_1, await handle.evaluateHandle(node => {
@@ -105,7 +120,7 @@ async function selectNativeSelectOption(handle) {
105
120
  if (typeof value !== 'string') {
106
121
  return false;
107
122
  }
108
- await select.asLocator().fill(value);
123
+ await select.asLocator().fill(value, { signal });
109
124
  return true;
110
125
  }
111
126
  catch (e_1) {
@@ -116,7 +131,7 @@ async function selectNativeSelectOption(handle) {
116
131
  __disposeResources(env_1);
117
132
  }
118
133
  }
119
- export const click = definePageTool({
134
+ export const click = definePageTool(() => ({
120
135
  name: 'click',
121
136
  description: `Clicks on the provided element`,
122
137
  annotations: {
@@ -140,13 +155,14 @@ export const click = definePageTool({
140
155
  const aXNode = request.page.getAXNodeByUid(uid);
141
156
  const shouldSelectNativeOption = !request.params.dblClick && aXNode?.role === 'option';
142
157
  try {
143
- const result = await request.page.waitForEventsAfterAction(async () => {
158
+ const result = await request.page.waitForEventsAfterAction(async (signal) => {
144
159
  if (shouldSelectNativeOption &&
145
- (await selectNativeSelectOption(handle))) {
160
+ (await selectNativeSelectOption(handle, signal))) {
146
161
  return;
147
162
  }
148
163
  await handle.asLocator().click({
149
164
  count: request.params.dblClick ? 2 : 1,
165
+ signal,
150
166
  });
151
167
  });
152
168
  response.appendResponseLine(request.params.dblClick
@@ -158,7 +174,10 @@ export const click = definePageTool({
158
174
  }
159
175
  }
160
176
  catch (error) {
161
- handleActionError(error, uid);
177
+ handleActionError(error, uid, request.page);
178
+ response.appendResponseLine(request.params.dblClick
179
+ ? `The element was double clicked and it opened a dialog.`
180
+ : `The element was clicked and it opened a dialog.`);
162
181
  }
163
182
  }
164
183
  catch (e_2) {
@@ -169,8 +188,8 @@ export const click = definePageTool({
169
188
  __disposeResources(env_2);
170
189
  }
171
190
  },
172
- });
173
- export const clickAt = definePageTool({
191
+ }));
192
+ export const clickAt = definePageTool(() => ({
174
193
  name: 'click_at',
175
194
  description: `Clicks at the provided coordinates`,
176
195
  annotations: {
@@ -201,8 +220,8 @@ export const clickAt = definePageTool({
201
220
  response.includeSnapshot();
202
221
  }
203
222
  },
204
- });
205
- export const hover = definePageTool({
223
+ }));
224
+ export const hover = definePageTool(() => ({
206
225
  name: 'hover',
207
226
  description: `Hover over the provided element`,
208
227
  annotations: {
@@ -223,8 +242,8 @@ export const hover = definePageTool({
223
242
  const uid = request.params.uid;
224
243
  const handle = __addDisposableResource(env_3, await request.page.getElementByUid(uid), false);
225
244
  try {
226
- const result = await request.page.waitForEventsAfterAction(async () => {
227
- await handle.asLocator().hover();
245
+ const result = await request.page.waitForEventsAfterAction(async (signal) => {
246
+ await handle.asLocator().hover({ signal });
228
247
  });
229
248
  response.appendResponseLine(`Successfully hovered over the element`);
230
249
  response.attachWaitForResult(result);
@@ -233,7 +252,8 @@ export const hover = definePageTool({
233
252
  }
234
253
  }
235
254
  catch (error) {
236
- handleActionError(error, uid);
255
+ handleActionError(error, uid, request.page);
256
+ response.appendResponseLine(`The element was hovered and it opened a dialog.`);
237
257
  }
238
258
  }
239
259
  catch (e_3) {
@@ -244,26 +264,44 @@ export const hover = definePageTool({
244
264
  __disposeResources(env_3);
245
265
  }
246
266
  },
247
- });
267
+ }));
268
+ function raceWithSignal(promise, signal) {
269
+ if (signal.aborted) {
270
+ return Promise.reject(signal.reason);
271
+ }
272
+ return new Promise((resolve, reject) => {
273
+ const onAbort = () => {
274
+ reject(signal.reason);
275
+ };
276
+ signal.addEventListener('abort', onAbort, { once: true });
277
+ Promise.resolve(promise).then(value => {
278
+ signal.removeEventListener('abort', onAbort);
279
+ resolve(value);
280
+ }, error => {
281
+ signal.removeEventListener('abort', onAbort);
282
+ reject(error);
283
+ });
284
+ });
285
+ }
248
286
  // The AXNode for an option doesn't contain its `value`. We set text content of the option as value.
249
287
  // If the form is a combobox, we need to find the correct option by its text value.
250
288
  // To do that, loop through the children while checking which child's text matches the requested value (requested value is actually the text content).
251
289
  // When the correct option is found, use the element handle to get the real value.
252
- async function selectOption(handle, aXNode, value) {
290
+ async function selectOption(handle, aXNode, value, signal) {
253
291
  let optionFound = false;
254
292
  for (const child of aXNode.children) {
255
293
  if (child.role === 'option' && child.name === value && child.value) {
256
294
  const env_4 = { stack: [], error: void 0, hasError: false };
257
295
  try {
258
296
  optionFound = true;
259
- const childHandle = __addDisposableResource(env_4, await child.elementHandle(), false);
297
+ const childHandle = __addDisposableResource(env_4, await raceWithSignal(child.elementHandle(), signal), false);
260
298
  if (childHandle) {
261
299
  const env_5 = { stack: [], error: void 0, hasError: false };
262
300
  try {
263
- const childValueHandle = __addDisposableResource(env_5, await childHandle.getProperty('value'), false);
264
- const childValue = await childValueHandle.jsonValue();
301
+ const childValueHandle = __addDisposableResource(env_5, await raceWithSignal(childHandle.getProperty('value'), signal), false);
302
+ const childValue = await raceWithSignal(childValueHandle.jsonValue(), signal);
265
303
  if (typeof childValue === 'string') {
266
- await handle.asLocator().fill(childValue);
304
+ await handle.asLocator().fill(childValue, { signal });
267
305
  }
268
306
  break;
269
307
  }
@@ -292,54 +330,82 @@ async function selectOption(handle, aXNode, value) {
292
330
  function hasOptionChildren(aXNode) {
293
331
  return aXNode.children.some(child => child.role === 'option');
294
332
  }
295
- async function fillFormElement(uid, value, context, page) {
296
- const env_6 = { stack: [], error: void 0, hasError: false };
333
+ /**
334
+ * Fills one or more form elements and waits for resulting page events in a
335
+ * single `waitForEventsAfterAction` call.
336
+ * If an element opens a JavaScript dialog, returns the `interruptedUid` of that
337
+ * element so the caller can report it without filling remaining elements.
338
+ */
339
+ async function fillFormElements(elements, page) {
340
+ let currentUid;
297
341
  try {
298
- const handle = __addDisposableResource(env_6, await page.getElementByUid(uid), false);
299
- try {
300
- const aXNode = page.getAXNodeByUid(uid);
301
- // We assume that combobox needs to be handled as select if it has
302
- // role='combobox' and option children.
303
- if (aXNode && aXNode.role === 'combobox' && hasOptionChildren(aXNode)) {
304
- await selectOption(handle, aXNode, value);
305
- }
306
- else {
307
- const isToggle = await handle.evaluate(el => {
308
- if (el instanceof HTMLInputElement) {
309
- return el.type === 'checkbox' || el.type === 'radio';
310
- }
311
- const role = el.getAttribute('role');
312
- return role === 'checkbox' || role === 'radio' || role === 'switch';
313
- });
314
- if (isToggle) {
315
- if (['true', 'false'].includes(value)) {
316
- await handle.asLocator().fill(value === 'true');
342
+ const result = await page.waitForEventsAfterAction(async (signal) => {
343
+ for (const { uid, value } of elements) {
344
+ const env_6 = { stack: [], error: void 0, hasError: false };
345
+ try {
346
+ const previousUid = currentUid;
347
+ currentUid = undefined;
348
+ const handle = __addDisposableResource(env_6, await raceWithSignal(page.getElementByUid(uid), signal).catch(error => {
349
+ if (signal.aborted && previousUid) {
350
+ currentUid = previousUid;
351
+ }
352
+ throw error;
353
+ }), false);
354
+ currentUid = uid;
355
+ const aXNode = page.getAXNodeByUid(uid);
356
+ // We assume that combobox needs to be handled as select if it has
357
+ // role='combobox' and option children.
358
+ if (aXNode && aXNode.role === 'combobox' && hasOptionChildren(aXNode)) {
359
+ await raceWithSignal(selectOption(handle, aXNode, value, signal), signal);
317
360
  }
318
361
  else {
319
- throw new Error(`Checkboxes, radio boxes and toggles require "true" or "false" value, but ${value} was used`);
362
+ const isToggle = await raceWithSignal(handle.evaluate(el => {
363
+ if (el instanceof HTMLInputElement) {
364
+ return el.type === 'checkbox' || el.type === 'radio';
365
+ }
366
+ const role = el.getAttribute('role');
367
+ return (role === 'checkbox' || role === 'radio' || role === 'switch');
368
+ }), signal);
369
+ if (isToggle) {
370
+ if (['true', 'false'].includes(value)) {
371
+ await handle.asLocator().fill(value === 'true', { signal });
372
+ }
373
+ else {
374
+ throw new Error(`Checkboxes, radio boxes and toggles require "true" or "false" value, but ${value} was used`);
375
+ }
376
+ }
377
+ else {
378
+ // Increase timeout for longer input values.
379
+ const timeoutPerChar = 10; // ms
380
+ const fillTimeout = page.pptrPage.getDefaultTimeout() + value.length * timeoutPerChar;
381
+ await handle
382
+ .asLocator()
383
+ .setTimeout(fillTimeout)
384
+ .fill(value, { signal });
385
+ }
320
386
  }
387
+ signal.throwIfAborted();
388
+ }
389
+ catch (e_6) {
390
+ env_6.error = e_6;
391
+ env_6.hasError = true;
321
392
  }
322
- else {
323
- // Increase timeout for longer input values.
324
- const timeoutPerChar = 10; // ms
325
- const fillTimeout = page.pptrPage.getDefaultTimeout() + value.length * timeoutPerChar;
326
- await handle.asLocator().setTimeout(fillTimeout).fill(value);
393
+ finally {
394
+ __disposeResources(env_6);
327
395
  }
328
396
  }
329
- }
330
- catch (error) {
331
- handleActionError(error, uid);
332
- }
333
- }
334
- catch (e_6) {
335
- env_6.error = e_6;
336
- env_6.hasError = true;
397
+ });
398
+ return { result };
337
399
  }
338
- finally {
339
- __disposeResources(env_6);
400
+ catch (error) {
401
+ if (!currentUid) {
402
+ throw error;
403
+ }
404
+ handleActionError(error, currentUid, page);
405
+ return { interruptedUid: currentUid };
340
406
  }
341
407
  }
342
- export const fill = definePageTool({
408
+ export const fill = definePageTool(() => ({
343
409
  name: 'fill',
344
410
  description: `Type text into an input, text area or select an option from a <select> element.`,
345
411
  annotations: {
@@ -357,19 +423,20 @@ export const fill = definePageTool({
357
423
  },
358
424
  blockedByDialog: true,
359
425
  verifyFilesSchema: {},
360
- handler: async (request, response, context) => {
361
- const page = request.page;
362
- const result = await page.waitForEventsAfterAction(async () => {
363
- await fillFormElement(request.params.uid, request.params.value, context, page);
364
- });
426
+ handler: async (request, response) => {
427
+ const { result } = await fillFormElements([{ uid: request.params.uid, value: request.params.value }], request.page);
428
+ if (!result) {
429
+ response.appendResponseLine(`The element was filled out and it opened a dialog.`);
430
+ return;
431
+ }
365
432
  response.appendResponseLine(`Successfully filled out the element`);
366
433
  response.attachWaitForResult(result);
367
434
  if (request.params.includeSnapshot) {
368
435
  response.includeSnapshot();
369
436
  }
370
437
  },
371
- });
372
- export const typeText = definePageTool({
438
+ }));
439
+ export const typeText = definePageTool(() => ({
373
440
  name: 'type_text',
374
441
  description: `Type text using keyboard into a previously focused input`,
375
442
  annotations: {
@@ -393,8 +460,8 @@ export const typeText = definePageTool({
393
460
  response.appendResponseLine(`Typed text "${request.params.text}${request.params.submitKey ? ` + ${request.params.submitKey}` : ''}"`);
394
461
  response.attachWaitForResult(result);
395
462
  },
396
- });
397
- export const drag = definePageTool({
463
+ }));
464
+ export const drag = definePageTool(() => ({
398
465
  name: 'drag',
399
466
  description: `Drag an element onto another element`,
400
467
  annotations: {
@@ -432,8 +499,8 @@ export const drag = definePageTool({
432
499
  __disposeResources(env_7);
433
500
  }
434
501
  },
435
- });
436
- export const fillForm = definePageTool({
502
+ }));
503
+ export const fillForm = definePageTool(() => ({
437
504
  name: 'fill_form',
438
505
  description: `Fill out multiple form elements (inputs, selects, checkboxes, radios) at once. ALWAYS prefer this tool over multiple individual 'fill' or 'click' calls when interacting with forms. It is significantly faster, more reliable, and reduces turn count. Example: Fill username, password, and check "Remember Me" in one call.`,
439
506
  annotations: {
@@ -443,34 +510,39 @@ export const fillForm = definePageTool({
443
510
  schema: {
444
511
  elements: zod
445
512
  .array(
446
- // eslint-disable-next-line @local/enforce-zod-schema
447
- zod.object({
513
+ /* eslint-disable @local/enforce-zod-schema */
514
+ zod
515
+ .object({
448
516
  uid: zod.string().describe('The uid of the element to fill out'),
449
517
  value: zod
450
518
  .string()
451
519
  .describe('Value for the element. "true" or "false" for checkboxes and toggles, "true" for radio buttons.'),
452
- }))
520
+ })
521
+ .describe('An element to fill out'))
453
522
  .describe('Elements from snapshot to fill out.'),
454
523
  includeSnapshot: includeSnapshotSchema,
455
524
  },
456
525
  blockedByDialog: true,
457
526
  verifyFilesSchema: {},
458
- handler: async (request, response, context) => {
459
- const page = request.page;
460
- let lastResult = {};
461
- for (const element of request.params.elements) {
462
- lastResult = await page.waitForEventsAfterAction(async () => {
463
- await fillFormElement(element.uid, element.value, context, page);
464
- });
527
+ handler: async (request, response) => {
528
+ const { result, interruptedUid } = await fillFormElements(request.params.elements, request.page);
529
+ if (!result) {
530
+ // The page is blocked by a dialog, so the remaining elements cannot be
531
+ // filled out until it is handled.
532
+ const hasRemainingElements = interruptedUid !== request.params.elements.at(-1)?.uid;
533
+ response.appendResponseLine(`Filling out the element with uid ${interruptedUid} opened a dialog.${hasRemainingElements
534
+ ? ' The remaining elements were not filled out.'
535
+ : ''}`);
536
+ return;
465
537
  }
466
538
  response.appendResponseLine(`Successfully filled out the form`);
467
- response.attachWaitForResult(lastResult);
539
+ response.attachWaitForResult(result);
468
540
  if (request.params.includeSnapshot) {
469
541
  response.includeSnapshot();
470
542
  }
471
543
  },
472
- });
473
- export const uploadFile = definePageTool({
544
+ }));
545
+ export const uploadFile = definePageTool(() => ({
474
546
  name: 'upload_file',
475
547
  description: 'Upload a file through a provided element.',
476
548
  annotations: {
@@ -532,8 +604,8 @@ export const uploadFile = definePageTool({
532
604
  __disposeResources(env_8);
533
605
  }
534
606
  },
535
- });
536
- export const pressKey = definePageTool({
607
+ }));
608
+ export const pressKey = definePageTool(() => ({
537
609
  name: 'press_key',
538
610
  description: `Press a key or key combination. Use this when other input methods like fill() cannot be used (e.g., keyboard shortcuts, navigation keys, or special key combinations).`,
539
611
  annotations: {
@@ -576,5 +648,5 @@ export const pressKey = definePageTool({
576
648
  response.includeSnapshot();
577
649
  }
578
650
  },
579
- });
651
+ }));
580
652
  //# sourceMappingURL=input.js.map
@@ -4,13 +4,20 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import path from 'node:path';
7
- import { snapshot, navigation, generateReport, zod, } from '../third_party/index.js';
7
+ import { lighthouseRunner, generateReport, zod, } from '../third_party/index.js';
8
8
  import { ToolCategory } from './categories.js';
9
9
  import { startTrace } from './performance.js';
10
10
  import { definePageTool } from './ToolDefinition.js';
11
- export const lighthouseAudit = definePageTool({
11
+ // Kept in sync with `constants.userAgents` in Lighthouse's
12
+ // core/config/constants.js, which `lighthouse:default` and the `desktop`
13
+ // preset use. The bundle in src/third_party only re-exports the runner
14
+ // entrypoints, so these cannot be imported and are mirrored here alongside the
15
+ // screen emulation metrics below. Refresh via scripts/update-lighthouse.ts.
16
+ const MOBILE_USER_AGENT = 'Mozilla/5.0 (Linux; Android 11; moto g power (2022)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Mobile Safari/537.36';
17
+ const DESKTOP_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36';
18
+ export const lighthouseAudit = definePageTool((args) => ({
12
19
  name: 'lighthouse_audit',
13
- description: `Get Lighthouse score and reports for accessibility, SEO, best practices, and agentic browsing. This excludes performance. For performance audits, run ${startTrace.name}`,
20
+ description: `Get Lighthouse score and reports for accessibility, SEO, best practices, and agentic browsing. This excludes performance. For performance audits, run ${startTrace(args).name}`,
14
21
  annotations: {
15
22
  category: ToolCategory.DEBUGGING,
16
23
  readOnlyHint: false,
@@ -58,6 +65,7 @@ export const lighthouseAudit = definePageTool({
58
65
  deviceScaleFactor: 1,
59
66
  disabled: false,
60
67
  };
68
+ flags.emulatedUserAgent = DESKTOP_USER_AGENT;
61
69
  }
62
70
  else {
63
71
  flags.formFactor = 'mobile';
@@ -68,16 +76,17 @@ export const lighthouseAudit = definePageTool({
68
76
  deviceScaleFactor: 1.75,
69
77
  disabled: false,
70
78
  };
79
+ flags.emulatedUserAgent = MOBILE_USER_AGENT;
71
80
  }
72
81
  let result;
73
82
  try {
74
83
  if (mode === 'navigation') {
75
- result = await navigation(page.pptrPage, page.pptrPage.url(), {
84
+ result = await lighthouseRunner.navigation(page.pptrPage, page.pptrPage.url(), {
76
85
  flags,
77
86
  });
78
87
  }
79
88
  else {
80
- result = await snapshot(page.pptrPage, {
89
+ result = await lighthouseRunner.snapshot(page.pptrPage, {
81
90
  flags,
82
91
  });
83
92
  }
@@ -120,7 +129,9 @@ export const lighthouseAudit = definePageTool({
120
129
  summary: {
121
130
  mode,
122
131
  device,
123
- url: lhr.mainDocumentUrl,
132
+ // `mainDocumentUrl` is only set for navigations, whereas
133
+ // `finalDisplayedUrl` is populated for every gather mode.
134
+ url: lhr.finalDisplayedUrl,
124
135
  scores: categoryScores,
125
136
  audits: {
126
137
  failed: failedAudits,
@@ -134,5 +145,5 @@ export const lighthouseAudit = definePageTool({
134
145
  };
135
146
  response.attachLighthouseResult(output);
136
147
  },
137
- });
148
+ }));
138
149
  //# sourceMappingURL=lighthouse.js.map
@@ -16,7 +16,7 @@ const HEAP_SNAPSHOT_FILTERS = [
16
16
  'noNativeContext',
17
17
  'attributedToSpecificNativeContext',
18
18
  ];
19
- export const takeHeapSnapshot = definePageTool({
19
+ export const takeHeapSnapshot = definePageTool(() => ({
20
20
  name: 'take_heapsnapshot',
21
21
  description: `Capture a heap snapshot of the target page. Use to analyze the memory distribution of JavaScript objects and debug memory leaks.`,
22
22
  annotations: {
@@ -40,8 +40,8 @@ export const takeHeapSnapshot = definePageTool({
40
40
  });
41
41
  response.appendResponseLine(`Heap snapshot saved to ${snapshotPath}`);
42
42
  },
43
- });
44
- export const getHeapSnapshotSummary = defineTool({
43
+ }));
44
+ export const getHeapSnapshotSummary = defineTool(() => ({
45
45
  name: 'get_heapsnapshot_summary',
46
46
  description: 'Loads a memory heapsnapshot and returns snapshot summary stats, including native contexts and their sizes, and retained by context summary.',
47
47
  annotations: {
@@ -63,8 +63,8 @@ export const getHeapSnapshotSummary = defineTool({
63
63
  const retainedByContextSummary = await context.getHeapSnapshotRetainedByContextSummary(request.params.filePath);
64
64
  response.setHeapSnapshotStats(stats, staticData, nativeContextSizes, retainedByContextSummary);
65
65
  },
66
- });
67
- export const getHeapSnapshotDetails = defineTool({
66
+ }));
67
+ export const getHeapSnapshotDetails = defineTool(() => ({
68
68
  name: 'get_heapsnapshot_details',
69
69
  description: 'Loads a memory heapsnapshot and returns all available information including statistics, static data, and aggregated node information. Supports pagination for aggregates.',
70
70
  annotations: {
@@ -102,8 +102,8 @@ export const getHeapSnapshotDetails = defineTool({
102
102
  pageSize: request.params.pageSize,
103
103
  });
104
104
  },
105
- });
106
- export const getHeapSnapshotClassNodes = defineTool({
105
+ }));
106
+ export const getHeapSnapshotClassNodes = defineTool(() => ({
107
107
  name: 'get_heapsnapshot_class_nodes',
108
108
  description: 'Loads a memory heapsnapshot and returns instances of a specific class with their IDs.',
109
109
  annotations: {
@@ -136,8 +136,8 @@ export const getHeapSnapshotClassNodes = defineTool({
136
136
  pageSize: request.params.pageSize,
137
137
  });
138
138
  },
139
- });
140
- export const getHeapSnapshotRetainers = defineTool({
139
+ }));
140
+ export const getHeapSnapshotRetainers = defineTool(() => ({
141
141
  name: 'get_heapsnapshot_retainers',
142
142
  description: 'Loads a memory heapsnapshot and returns retainers for a specific node ID.',
143
143
  annotations: {
@@ -162,8 +162,8 @@ export const getHeapSnapshotRetainers = defineTool({
162
162
  pageSize: request.params.pageSize,
163
163
  });
164
164
  },
165
- });
166
- export const closeHeapSnapshot = defineTool({
165
+ }));
166
+ export const closeHeapSnapshot = defineTool(() => ({
167
167
  name: 'close_heapsnapshot',
168
168
  description: 'Closes a previously loaded memory heapsnapshot, freeing its memory.',
169
169
  annotations: {
@@ -187,8 +187,8 @@ export const closeHeapSnapshot = defineTool({
187
187
  }
188
188
  response.appendResponseLine(`Closed heap snapshot: ${request.params.filePath}`);
189
189
  },
190
- });
191
- export const getHeapSnapshotRetainingPaths = defineTool({
190
+ }));
191
+ export const getHeapSnapshotRetainingPaths = defineTool(() => ({
192
192
  name: 'get_heapsnapshot_retaining_paths',
193
193
  description: 'Loads a memory heapsnapshot and returns retaining paths for a specific node ID. This helps to understand why a node is not being garbage collected.',
194
194
  annotations: {
@@ -220,8 +220,8 @@ export const getHeapSnapshotRetainingPaths = defineTool({
220
220
  const retainingPaths = await context.getHeapSnapshotRetainingPaths(request.params.filePath, request.params.nodeId, request.params.maxDepth, request.params.maxNodes, request.params.maxSiblings);
221
221
  response.setHeapSnapshotRetainingPaths(retainingPaths);
222
222
  },
223
- });
224
- export const getHeapSnapshotEdges = defineTool({
223
+ }));
224
+ export const getHeapSnapshotEdges = defineTool(() => ({
225
225
  name: 'get_heapsnapshot_edges',
226
226
  description: 'Loads a memory heapsnapshot and returns outgoing edges (references) for a specific node ID.',
227
227
  annotations: {
@@ -260,8 +260,8 @@ export const getHeapSnapshotEdges = defineTool({
260
260
  pageSize: request.params.pageSize,
261
261
  });
262
262
  },
263
- });
264
- export const getHeapSnapshotDominators = defineTool({
263
+ }));
264
+ export const getHeapSnapshotDominators = defineTool(() => ({
265
265
  name: 'get_heapsnapshot_dominators',
266
266
  description: 'Loads a memory heapsnapshot and returns the dominator chain for a specific node ID. This helps to identify which objects are keeping the target node alive.',
267
267
  annotations: {
@@ -283,8 +283,8 @@ export const getHeapSnapshotDominators = defineTool({
283
283
  const dominators = await context.getHeapSnapshotDominators(request.params.filePath, request.params.nodeId);
284
284
  response.setHeapSnapshotDominators(dominators);
285
285
  },
286
- });
287
- export const compareHeapSnapshots = defineTool({
286
+ }));
287
+ export const compareHeapSnapshots = defineTool(() => ({
288
288
  name: 'compare_heapsnapshots',
289
289
  description: 'Loads two memory heapsnapshots and returns the comparison. If classIndex is provided, returns detailed diff for that class, otherwise returns summary diff.',
290
290
  annotations: {
@@ -319,8 +319,8 @@ export const compareHeapSnapshots = defineTool({
319
319
  response.setHeapSnapshotClassDiffs(diff);
320
320
  }
321
321
  },
322
- });
323
- export const getHeapSnapshotDuplicateStrings = defineTool({
322
+ }));
323
+ export const getHeapSnapshotDuplicateStrings = defineTool(() => ({
324
324
  name: 'get_heapsnapshot_duplicate_strings',
325
325
  description: 'Loads a memory heapsnapshot and returns duplicate strings grouped by their value.',
326
326
  annotations: {
@@ -344,8 +344,8 @@ export const getHeapSnapshotDuplicateStrings = defineTool({
344
344
  pageSize: request.params.pageSize,
345
345
  });
346
346
  },
347
- });
348
- export const getHeapSnapshotObjectDetails = defineTool({
347
+ }));
348
+ export const getHeapSnapshotObjectDetails = defineTool(() => ({
349
349
  name: 'get_heapsnapshot_object_details',
350
350
  description: 'Loads a memory heapsnapshot and returns detailed information about a specific object by its node ID, including size, type, distance, and DOM detachedness.',
351
351
  annotations: {
@@ -365,8 +365,8 @@ export const getHeapSnapshotObjectDetails = defineTool({
365
365
  const objectInfo = await context.getHeapSnapshotObjectDetails(request.params.filePath, request.params.nodeId);
366
366
  response.setHeapSnapshotObjectDetails(objectInfo);
367
367
  },
368
- });
369
- export const queryHeapSnapshotObjects = defineTool({
368
+ }));
369
+ export const queryHeapSnapshotObjects = defineTool(() => ({
370
370
  name: 'query_heapsnapshot_objects',
371
371
  description: 'Loads a memory heapsnapshot and queries objects matching specific filters (className, propertyName, nodeType, retainedSize, selfSize, isDetached, sortBy).',
372
372
  annotations: {
@@ -420,5 +420,5 @@ export const queryHeapSnapshotObjects = defineTool({
420
420
  pageSize: request.params.pageSize,
421
421
  });
422
422
  },
423
- });
423
+ }));
424
424
  //# sourceMappingURL=memory.js.map
@@ -27,7 +27,7 @@ const FILTERABLE_RESOURCE_TYPES = [
27
27
  'fedcm',
28
28
  'other',
29
29
  ];
30
- export const listNetworkRequests = definePageTool({
30
+ export const listNetworkRequests = definePageTool(() => ({
31
31
  name: 'list_network_requests',
32
32
  description: `Lists the most recent requests for the target page since the last navigation.`,
33
33
  annotations: {
@@ -73,10 +73,10 @@ export const listNetworkRequests = definePageTool({
73
73
  networkRequestIdInDevToolsUI: reqid,
74
74
  });
75
75
  },
76
- });
77
- export const getNetworkRequest = definePageTool({
76
+ }));
77
+ export const getNetworkRequest = definePageTool(() => ({
78
78
  name: 'get_network_request',
79
- description: `Gets a network request by an optional reqid, if omitted returns the currently selected request in the DevTools Network panel.`,
79
+ description: `Gets a network request by an optional reqid, if omitted returns the currently selected request in the DevTools Network panel. Useful for inspecting request headers (including 'Cookie') and response headers (including 'Set-Cookie' and directives).`,
80
80
  annotations: {
81
81
  category: ToolCategory.NETWORK,
82
82
  readOnlyHint: false,
@@ -124,5 +124,5 @@ export const getNetworkRequest = definePageTool({
124
124
  }
125
125
  }
126
126
  },
127
- });
127
+ }));
128
128
  //# sourceMappingURL=network.js.map