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.
- package/README.md +72 -20
- package/build/src/BrowserManager.js +155 -27
- package/build/src/McpContext.js +598 -200
- package/build/src/McpPage.js +513 -131
- package/build/src/McpResponse.js +291 -116
- package/build/src/McpWorker.js +66 -0
- package/build/src/SlimMcpResponse.js +5 -1
- package/build/src/TextSnapshot.js +40 -20
- package/build/src/ToolHandler.js +306 -147
- package/build/src/bin/chrome-devtools-mcp-main.js +13 -10
- package/build/src/bin/chrome-devtools-mcp.js +1 -1
- package/build/src/bin/chrome-devtools.js +34 -44
- package/build/src/collectors/PageCollector.js +13 -9
- package/build/src/collectors/ServiceWorkerCollector.js +20 -13
- package/build/src/collectors/constants.js +7 -0
- package/build/src/config/ConfigLocator.js +70 -0
- package/build/src/config/ConfigParser.js +159 -0
- package/build/src/config/ConfigWatcher.js +94 -0
- package/build/src/config/ServerConfig.js +251 -0
- package/build/src/config/browser-options.js +15 -17
- package/build/src/config/category-options.js +15 -30
- package/build/src/config/cli-commands.js +165 -5
- package/build/src/config/cli-options.js +441 -58
- package/build/src/config/mcp-options.js +212 -264
- package/build/src/config/puppeteer-options.js +67 -0
- package/build/src/config/tool-options.js +60 -0
- package/build/src/daemon/client.js +84 -44
- package/build/src/daemon/daemon.js +59 -45
- package/build/src/daemon/utils.js +46 -12
- package/build/src/devtools/DevToolsCommentBridge.js +71 -11
- package/build/src/devtools/DevtoolsUtils.js +52 -15
- package/build/src/devtools/McpHostBindingAdapter.js +0 -1
- package/build/src/formatters/CommentFormatter.js +4 -13
- package/build/src/formatters/ConsoleFormatter.js +29 -2
- package/build/src/formatters/CssFormatter.js +3 -2
- package/build/src/formatters/HeapSnapshotFormatter.js +111 -57
- package/build/src/formatters/IssueFormatter.js +33 -32
- package/build/src/formatters/NetworkFormatter.js +62 -22
- package/build/src/formatters/RemoteObjectFormatter.js +231 -0
- package/build/src/formatters/SnapshotFormatter.js +44 -7
- package/build/src/index.js +285 -88
- package/build/src/processors/ChunkedTraceParser.js +11 -11
- package/build/src/processors/HeapSnapshotManager.js +455 -156
- package/build/src/processors/PerformanceTrace.js +9 -9
- package/build/src/telemetry/ClearcutLogger.js +1 -1
- package/build/src/telemetry/transformation.js +7 -11
- package/build/src/telemetry/watchdog/main.js +1 -1
- package/build/src/third_party/THIRD_PARTY_NOTICES +399 -689
- package/build/src/third_party/bundled-packages.json +7 -8
- package/build/src/third_party/cli.js +9239 -0
- package/build/src/third_party/devtools-formatter-worker.js +4299 -2517
- package/build/src/third_party/devtools-heap-snapshot-worker.js +1298 -22
- package/build/src/third_party/index.js +132003 -146852
- package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantRead.md +0 -1
- package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantReadOptOut.md +5 -0
- package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantSet.md +0 -1
- package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantSetOptOut.md +5 -0
- package/build/src/third_party/issue-descriptions/deprecation.md +1 -1
- package/build/src/third_party/issue-descriptions/genericGeolocationPromptWithoutUserGesture.md +5 -0
- package/build/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +2 -0
- package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +54576 -52174
- package/build/src/tools/ToolDefinition.js +102 -12
- package/build/src/tools/comments.js +62 -4
- package/build/src/tools/console.js +6 -4
- package/build/src/tools/css.js +5 -2
- package/build/src/tools/emulation.js +22 -8
- package/build/src/tools/extensions.js +5 -0
- package/build/src/tools/input.js +29 -9
- package/build/src/tools/lighthouse.js +136 -12
- package/build/src/tools/memory.js +166 -59
- package/build/src/tools/network.js +5 -4
- package/build/src/tools/pages.js +52 -7
- package/build/src/tools/performance.js +28 -7
- package/build/src/tools/pwa.js +7 -0
- package/build/src/tools/screencast.js +74 -33
- package/build/src/tools/screenshot.js +52 -21
- package/build/src/tools/script.js +125 -40
- package/build/src/tools/slim/tools.js +27 -13
- package/build/src/tools/snapshot.js +13 -3
- package/build/src/tools/thirdPartyDeveloper.js +9 -5
- package/build/src/tools/tools.js +35 -22
- package/build/src/tools/webmcp.js +11 -6
- package/build/src/types.js +11 -0
- package/build/src/utils/TaskRunner.js +136 -0
- package/build/src/utils/WaitForHelper.js +15 -2
- package/build/src/utils/bytes.js +2 -12
- package/build/src/utils/check-for-updates.js +2 -2
- package/build/src/utils/disclaimers.js +27 -0
- package/build/src/utils/errorHandling.js +20 -0
- package/build/src/utils/keyboard.js +14 -2
- package/build/src/utils/logger.js +84 -5
- package/build/src/utils/resourceType.js +27 -0
- package/build/src/utils/text.js +44 -0
- package/build/src/utils/timeout.js +14 -0
- package/build/src/utils/url.js +140 -3
- package/build/src/version.js +1 -1
- package/package.json +16 -11
- package/skills/a11y-debugging/SKILL.md +7 -12
- package/skills/chrome-devtools/SKILL.md +2 -2
- package/skills/chrome-devtools-cli/SKILL.md +18 -15
- package/skills/cookie-debugging/SKILL.md +8 -5
- package/skills/debug-optimize-lcp/SKILL.md +1 -1
- package/skills/troubleshooting/SKILL.md +5 -6
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Short id prefix that labels a worker's type in its id, e.g. `sw-1` for a
|
|
8
|
+
* service worker. The numeric part comes from a single shared counter, so the
|
|
9
|
+
* prefix is a readable type tag rather than a per-type sequence.
|
|
10
|
+
*/
|
|
11
|
+
const WORKER_ID_PREFIX = {
|
|
12
|
+
service_worker: 'sw',
|
|
13
|
+
dedicated_worker: 'dw',
|
|
14
|
+
shared_worker: 'shw',
|
|
15
|
+
};
|
|
16
|
+
export function workerIdPrefix(type) {
|
|
17
|
+
return WORKER_ID_PREFIX[type];
|
|
18
|
+
}
|
|
19
|
+
// Single shared counter across worker types. Ids are not reused across
|
|
20
|
+
// reconnects, mirroring the page id counter in McpContext; the type prefix is
|
|
21
|
+
// what distinguishes the kinds, not a per-type sequence.
|
|
22
|
+
let nextWorkerId = 1;
|
|
23
|
+
/**
|
|
24
|
+
* Wraps a Puppeteer worker {@link Target}, mirroring {@link McpPage}: it owns the
|
|
25
|
+
* target and the stable id assigned to it and lazily resolves the underlying
|
|
26
|
+
* {@link WebWorker}. Generalizes the former plain `ExtensionServiceWorker` type so
|
|
27
|
+
* dedicated and service workers share a single representation.
|
|
28
|
+
*/
|
|
29
|
+
export class McpWorker {
|
|
30
|
+
id;
|
|
31
|
+
type;
|
|
32
|
+
#target;
|
|
33
|
+
constructor(id, type, target) {
|
|
34
|
+
this.id = id;
|
|
35
|
+
this.type = type;
|
|
36
|
+
this.#target = target;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates a worker with a freshly minted id derived from its type (e.g.
|
|
40
|
+
* `sw-1`). Keeps id composition in one place so callers only supply the type.
|
|
41
|
+
*/
|
|
42
|
+
static create(type, target) {
|
|
43
|
+
return new McpWorker(`${workerIdPrefix(type)}-${nextWorkerId++}`, type, target);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Resets the shared id counter. For tests only, mirroring
|
|
47
|
+
* McpContext.resetPageIdsForTesting().
|
|
48
|
+
*/
|
|
49
|
+
static resetIdsForTesting() {
|
|
50
|
+
nextWorkerId = 1;
|
|
51
|
+
}
|
|
52
|
+
get target() {
|
|
53
|
+
return this.#target;
|
|
54
|
+
}
|
|
55
|
+
get url() {
|
|
56
|
+
return this.#target.url();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolves the worker's execution context, or `undefined` when the target
|
|
60
|
+
* does not expose one (e.g. it closed before the session attached).
|
|
61
|
+
*/
|
|
62
|
+
async worker() {
|
|
63
|
+
return (await this.#target.worker()) ?? undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=McpWorker.js.map
|
|
@@ -6,9 +6,13 @@
|
|
|
6
6
|
import { McpResponse } from './McpResponse.js';
|
|
7
7
|
export class SlimMcpResponse extends McpResponse {
|
|
8
8
|
async handle(_context) {
|
|
9
|
+
const error = this.error;
|
|
10
|
+
const responseText = error
|
|
11
|
+
? [...this.responseLines, `Error: ${error.message}`].join('\n')
|
|
12
|
+
: this.responseLines.join('\n');
|
|
9
13
|
const text = {
|
|
10
14
|
type: 'text',
|
|
11
|
-
text:
|
|
15
|
+
text: responseText,
|
|
12
16
|
};
|
|
13
17
|
return {
|
|
14
18
|
content: [text],
|
|
@@ -56,6 +56,16 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
56
56
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
57
57
|
});
|
|
58
58
|
import { logger } from './utils/logger.js';
|
|
59
|
+
import { withTimeout } from './utils/timeout.js';
|
|
60
|
+
const ACCESSIBILITY_SNAPSHOT_TIMEOUT_MS = 10_000;
|
|
61
|
+
/**
|
|
62
|
+
* InlineTextBox nodes are layout line fragments of a StaticText node. They
|
|
63
|
+
* repeat the parent text, have no backendNodeId and cannot be targeted by
|
|
64
|
+
* tools. Puppeteer only serializes them for non-interesting-only snapshots.
|
|
65
|
+
*/
|
|
66
|
+
function isLayoutOnlyNode(node) {
|
|
67
|
+
return node.role === 'InlineTextBox';
|
|
68
|
+
}
|
|
59
69
|
export class TextSnapshot {
|
|
60
70
|
static nextSnapshotId = 1;
|
|
61
71
|
static resetCounter() {
|
|
@@ -77,9 +87,12 @@ export class TextSnapshot {
|
|
|
77
87
|
}
|
|
78
88
|
static async create(page, options = {}) {
|
|
79
89
|
const verbose = options.verbose ?? false;
|
|
80
|
-
const rootNode = await page.pptrPage.accessibility.snapshot({
|
|
90
|
+
const rootNode = await withTimeout(page.pptrPage.accessibility.snapshot({
|
|
81
91
|
includeIframes: true,
|
|
82
92
|
interestingOnly: !verbose,
|
|
93
|
+
}), {
|
|
94
|
+
timeout: ACCESSIBILITY_SNAPSHOT_TIMEOUT_MS,
|
|
95
|
+
message: `Timed out after ${ACCESSIBILITY_SNAPSHOT_TIMEOUT_MS}ms waiting for the accessibility tree. The page may have a pending navigation or a crashed renderer. Navigate or reload the page, or select another page.`,
|
|
83
96
|
});
|
|
84
97
|
if (!rootNode) {
|
|
85
98
|
throw new Error('Failed to create accessibility snapshot');
|
|
@@ -96,25 +109,29 @@ export class TextSnapshot {
|
|
|
96
109
|
let id = '';
|
|
97
110
|
// @ts-expect-error untyped backendNodeId.
|
|
98
111
|
const backendNodeId = node.backendNodeId;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
if (backendNodeId !== undefined) {
|
|
113
|
+
// @ts-expect-error untyped loaderId.
|
|
114
|
+
const uniqueBackendId = `${node.loaderId}_${backendNodeId}`;
|
|
115
|
+
const existingMcpId = uniqueBackendNodeIdToMcpId.get(uniqueBackendId);
|
|
116
|
+
if (existingMcpId !== undefined) {
|
|
117
|
+
// Re-use MCP exposed ID if the uniqueId is the same.
|
|
118
|
+
id = existingMcpId;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
// Only generate a new ID if we have not seen the node before.
|
|
122
|
+
id = `${snapshotId}_${idCounter++}`;
|
|
123
|
+
uniqueBackendNodeIdToMcpId.set(uniqueBackendId, id);
|
|
124
|
+
}
|
|
125
|
+
seenUniqueIds.add(uniqueBackendId);
|
|
126
|
+
seenBackendNodeIds.add(backendNodeId);
|
|
110
127
|
}
|
|
111
|
-
seenUniqueIds.add(uniqueBackendId);
|
|
112
|
-
seenBackendNodeIds.add(backendNodeId);
|
|
113
128
|
const nodeWithId = {
|
|
114
129
|
...node,
|
|
115
130
|
id,
|
|
116
131
|
children: node.children
|
|
117
|
-
? node.children
|
|
132
|
+
? node.children
|
|
133
|
+
.filter(child => !isLayoutOnlyNode(child))
|
|
134
|
+
.map(child => assignIds(child))
|
|
118
135
|
: [],
|
|
119
136
|
};
|
|
120
137
|
// The AXNode for an option doesn't contain its `value`.
|
|
@@ -125,11 +142,13 @@ export class TextSnapshot {
|
|
|
125
142
|
nodeWithId.value = optionText.toString();
|
|
126
143
|
}
|
|
127
144
|
}
|
|
128
|
-
|
|
145
|
+
if (id) {
|
|
146
|
+
idToNode.set(nodeWithId.id, nodeWithId);
|
|
147
|
+
}
|
|
129
148
|
return nodeWithId;
|
|
130
149
|
};
|
|
131
150
|
const rootNodeWithId = assignIds(rootNode);
|
|
132
|
-
await TextSnapshot
|
|
151
|
+
await TextSnapshot.#insertExtraNodes(page, idToNode, seenUniqueIds, snapshotId, idCounter, rootNodeWithId, seenBackendNodeIds, options.extraHandles ?? []);
|
|
133
152
|
const snapshot = new TextSnapshot({
|
|
134
153
|
root: rootNodeWithId,
|
|
135
154
|
snapshotId: String(snapshotId),
|
|
@@ -157,21 +176,22 @@ export class TextSnapshot {
|
|
|
157
176
|
}
|
|
158
177
|
// TODO: index by backendNodeId instead.
|
|
159
178
|
const queue = [this.root];
|
|
160
|
-
|
|
161
|
-
|
|
179
|
+
let current = queue.pop();
|
|
180
|
+
while (current) {
|
|
162
181
|
if (current.backendNodeId === cdpBackendNodeId) {
|
|
163
182
|
return current.id;
|
|
164
183
|
}
|
|
165
184
|
for (const child of current.children) {
|
|
166
185
|
queue.push(child);
|
|
167
186
|
}
|
|
187
|
+
current = queue.pop();
|
|
168
188
|
}
|
|
169
189
|
return;
|
|
170
190
|
}
|
|
171
191
|
// ExtraHandles represent DOM nodes which might not be part of the accessibility tree, e.g. DOM nodes
|
|
172
192
|
// returned by third-party developer tools. We insert them into the tree by finding the closest ancestor
|
|
173
193
|
// in the tree and inserting the node as a child. The ancestor's child nodes are re-parented if necessary.
|
|
174
|
-
static async insertExtraNodes(page, idToNode, seenUniqueIds, snapshotId, idCounter, rootNodeWithId, seenBackendNodeIds, extraHandles) {
|
|
194
|
+
static async #insertExtraNodes(page, idToNode, seenUniqueIds, snapshotId, idCounter, rootNodeWithId, seenBackendNodeIds, extraHandles) {
|
|
175
195
|
const { uniqueBackendNodeIdToMcpId } = page;
|
|
176
196
|
const createExtraNode = async (handle) => {
|
|
177
197
|
const backendNodeId = await handle.backendNodeId();
|