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
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import { MAX_NAME_LENGTH } from '../formatters/HeapSnapshotFormatter.js';
|
|
6
7
|
import { zod } from '../third_party/index.js';
|
|
7
8
|
import { byteSizeRangeSchema } from '../utils/bytes.js';
|
|
8
9
|
import { ToolCategory } from './categories.js';
|
|
9
|
-
import { definePageTool,
|
|
10
|
+
import { defineBrowserlessTool, definePageTool, } from './ToolDefinition.js';
|
|
10
11
|
const HEAP_SNAPSHOT_FILTERS = [
|
|
11
12
|
'objectsRetainedByDetachedDomNodes',
|
|
12
13
|
'objectsRetainedByConsole',
|
|
@@ -16,6 +17,25 @@ const HEAP_SNAPSHOT_FILTERS = [
|
|
|
16
17
|
'noNativeContext',
|
|
17
18
|
'attributedToSpecificNativeContext',
|
|
18
19
|
];
|
|
20
|
+
const maxNameLengthSchema = zod
|
|
21
|
+
.number()
|
|
22
|
+
.int()
|
|
23
|
+
.min(1)
|
|
24
|
+
.optional()
|
|
25
|
+
.describe(`Maximum length of names before truncation. Defaults to ${MAX_NAME_LENGTH}.`);
|
|
26
|
+
const DEFAULT_HEAP_SNAPSHOT_PAGE_SIZE = 50;
|
|
27
|
+
const pageIdxSchema = zod
|
|
28
|
+
.number()
|
|
29
|
+
.int()
|
|
30
|
+
.nonnegative()
|
|
31
|
+
.default(0)
|
|
32
|
+
.describe('The zero-based page index. Defaults to 0 (the first page).');
|
|
33
|
+
const pageSizeSchema = zod
|
|
34
|
+
.number()
|
|
35
|
+
.int()
|
|
36
|
+
.positive()
|
|
37
|
+
.default(DEFAULT_HEAP_SNAPSHOT_PAGE_SIZE)
|
|
38
|
+
.describe(`The maximum number of items to return per page. Defaults to ${DEFAULT_HEAP_SNAPSHOT_PAGE_SIZE}.`);
|
|
19
39
|
export const takeHeapSnapshot = definePageTool(() => ({
|
|
20
40
|
name: 'take_heapsnapshot',
|
|
21
41
|
description: `Capture a heap snapshot of the target page. Use to analyze the memory distribution of JavaScript objects and debug memory leaks.`,
|
|
@@ -29,6 +49,7 @@ export const takeHeapSnapshot = definePageTool(() => ({
|
|
|
29
49
|
.describe('A path to a .heapsnapshot file to save the heapsnapshot to.'),
|
|
30
50
|
},
|
|
31
51
|
blockedByDialog: true,
|
|
52
|
+
concurrency: 'exclusive',
|
|
32
53
|
verifyFilesSchema: {
|
|
33
54
|
filePath: true,
|
|
34
55
|
},
|
|
@@ -41,16 +62,19 @@ export const takeHeapSnapshot = definePageTool(() => ({
|
|
|
41
62
|
response.appendResponseLine(`Heap snapshot saved to ${snapshotPath}`);
|
|
42
63
|
},
|
|
43
64
|
}));
|
|
44
|
-
export const getHeapSnapshotSummary =
|
|
65
|
+
export const getHeapSnapshotSummary = defineBrowserlessTool(() => ({
|
|
45
66
|
name: 'get_heapsnapshot_summary',
|
|
46
|
-
description: 'Loads a memory heapsnapshot and returns snapshot summary stats, including native contexts and their sizes, and retained by context summary.',
|
|
67
|
+
description: 'Loads and caches a memory heapsnapshot and returns snapshot summary stats, including native contexts and their sizes, and retained by context summary.',
|
|
47
68
|
annotations: {
|
|
48
69
|
category: ToolCategory.MEMORY,
|
|
49
70
|
readOnlyHint: true,
|
|
50
71
|
conditions: ['memoryDebugging'],
|
|
51
72
|
},
|
|
52
73
|
schema: {
|
|
53
|
-
filePath: zod
|
|
74
|
+
filePath: zod
|
|
75
|
+
.string()
|
|
76
|
+
.describe('A path to a .heapsnapshot file to read.'),
|
|
77
|
+
maxNameLength: maxNameLengthSchema,
|
|
54
78
|
},
|
|
55
79
|
blockedByDialog: false,
|
|
56
80
|
verifyFilesSchema: {
|
|
@@ -61,19 +85,23 @@ export const getHeapSnapshotSummary = defineTool(() => ({
|
|
|
61
85
|
const staticData = await context.getHeapSnapshotStaticData(request.params.filePath);
|
|
62
86
|
const nativeContextSizes = await context.getHeapSnapshotNativeContextSizes(request.params.filePath);
|
|
63
87
|
const retainedByContextSummary = await context.getHeapSnapshotRetainedByContextSummary(request.params.filePath);
|
|
64
|
-
response.setHeapSnapshotStats(stats, staticData, nativeContextSizes, retainedByContextSummary
|
|
88
|
+
response.setHeapSnapshotStats(stats, staticData, nativeContextSizes, retainedByContextSummary, {
|
|
89
|
+
maxNameLength: request.params.maxNameLength,
|
|
90
|
+
});
|
|
65
91
|
},
|
|
66
92
|
}));
|
|
67
|
-
export const getHeapSnapshotDetails =
|
|
93
|
+
export const getHeapSnapshotDetails = defineBrowserlessTool(() => ({
|
|
68
94
|
name: 'get_heapsnapshot_details',
|
|
69
|
-
description: 'Loads a memory heapsnapshot and returns all available information including statistics, static data, and aggregated node information. Supports pagination for aggregates.',
|
|
95
|
+
description: 'Loads and caches a memory heapsnapshot and returns all available information including statistics, static data, and aggregated node information. Supports pagination for aggregates.',
|
|
70
96
|
annotations: {
|
|
71
97
|
category: ToolCategory.MEMORY,
|
|
72
98
|
readOnlyHint: true,
|
|
73
99
|
conditions: ['memoryDebugging'],
|
|
74
100
|
},
|
|
75
101
|
schema: {
|
|
76
|
-
filePath: zod
|
|
102
|
+
filePath: zod
|
|
103
|
+
.string()
|
|
104
|
+
.describe('A path to a .heapsnapshot file to read.'),
|
|
77
105
|
filterName: zod
|
|
78
106
|
.enum(HEAP_SNAPSHOT_FILTERS)
|
|
79
107
|
.optional()
|
|
@@ -82,14 +110,9 @@ export const getHeapSnapshotDetails = defineTool(() => ({
|
|
|
82
110
|
.number()
|
|
83
111
|
.optional()
|
|
84
112
|
.describe('The object ID (nodeId) of the specific native context to filter by when filterName is attributedToSpecificNativeContext.'),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
.describe('The page index for pagination of aggregates.'),
|
|
89
|
-
pageSize: zod
|
|
90
|
-
.number()
|
|
91
|
-
.optional()
|
|
92
|
-
.describe('The page size for pagination of aggregates.'),
|
|
113
|
+
maxNameLength: maxNameLengthSchema,
|
|
114
|
+
pageIdx: pageIdxSchema,
|
|
115
|
+
pageSize: pageSizeSchema,
|
|
93
116
|
},
|
|
94
117
|
blockedByDialog: false,
|
|
95
118
|
verifyFilesSchema: {
|
|
@@ -100,19 +123,22 @@ export const getHeapSnapshotDetails = defineTool(() => ({
|
|
|
100
123
|
response.setHeapSnapshotAggregates(aggregates, {
|
|
101
124
|
pageIdx: request.params.pageIdx,
|
|
102
125
|
pageSize: request.params.pageSize,
|
|
126
|
+
maxNameLength: request.params.maxNameLength,
|
|
103
127
|
});
|
|
104
128
|
},
|
|
105
129
|
}));
|
|
106
|
-
export const getHeapSnapshotClassNodes =
|
|
130
|
+
export const getHeapSnapshotClassNodes = defineBrowserlessTool(() => ({
|
|
107
131
|
name: 'get_heapsnapshot_class_nodes',
|
|
108
|
-
description: 'Loads a memory heapsnapshot and returns instances of a specific class with their IDs.',
|
|
132
|
+
description: 'Loads and caches a memory heapsnapshot and returns instances of a specific class with their IDs.',
|
|
109
133
|
annotations: {
|
|
110
134
|
category: ToolCategory.MEMORY,
|
|
111
135
|
readOnlyHint: true,
|
|
112
136
|
conditions: ['memoryDebugging'],
|
|
113
137
|
},
|
|
114
138
|
schema: {
|
|
115
|
-
filePath: zod
|
|
139
|
+
filePath: zod
|
|
140
|
+
.string()
|
|
141
|
+
.describe('A path to a .heapsnapshot file to read.'),
|
|
116
142
|
id: zod.number().describe('The ID for the class, obtained from details.'),
|
|
117
143
|
filterName: zod
|
|
118
144
|
.enum(HEAP_SNAPSHOT_FILTERS)
|
|
@@ -122,8 +148,9 @@ export const getHeapSnapshotClassNodes = defineTool(() => ({
|
|
|
122
148
|
.number()
|
|
123
149
|
.optional()
|
|
124
150
|
.describe('The object ID (nodeId) of the specific native context to filter by when filterName is attributedToSpecificNativeContext.'),
|
|
125
|
-
|
|
126
|
-
|
|
151
|
+
maxNameLength: maxNameLengthSchema,
|
|
152
|
+
pageIdx: pageIdxSchema,
|
|
153
|
+
pageSize: pageSizeSchema,
|
|
127
154
|
},
|
|
128
155
|
blockedByDialog: false,
|
|
129
156
|
verifyFilesSchema: {
|
|
@@ -134,12 +161,13 @@ export const getHeapSnapshotClassNodes = defineTool(() => ({
|
|
|
134
161
|
response.setHeapSnapshotNodes(nodes, {
|
|
135
162
|
pageIdx: request.params.pageIdx,
|
|
136
163
|
pageSize: request.params.pageSize,
|
|
164
|
+
maxNameLength: request.params.maxNameLength,
|
|
137
165
|
});
|
|
138
166
|
},
|
|
139
167
|
}));
|
|
140
|
-
export const getHeapSnapshotRetainers =
|
|
168
|
+
export const getHeapSnapshotRetainers = defineBrowserlessTool(() => ({
|
|
141
169
|
name: 'get_heapsnapshot_retainers',
|
|
142
|
-
description: 'Loads a memory heapsnapshot and returns retainers for a specific node ID.',
|
|
170
|
+
description: 'Loads and caches a memory heapsnapshot and returns retainers for a specific node ID.',
|
|
143
171
|
annotations: {
|
|
144
172
|
category: ToolCategory.MEMORY,
|
|
145
173
|
readOnlyHint: true,
|
|
@@ -150,22 +178,26 @@ export const getHeapSnapshotRetainers = defineTool(() => ({
|
|
|
150
178
|
filePath: true,
|
|
151
179
|
},
|
|
152
180
|
schema: {
|
|
153
|
-
filePath: zod
|
|
181
|
+
filePath: zod
|
|
182
|
+
.string()
|
|
183
|
+
.describe('A path to a .heapsnapshot file to read.'),
|
|
154
184
|
nodeId: zod.number().describe('The node ID to get retainers for.'),
|
|
155
|
-
|
|
156
|
-
|
|
185
|
+
maxNameLength: maxNameLengthSchema,
|
|
186
|
+
pageIdx: pageIdxSchema,
|
|
187
|
+
pageSize: pageSizeSchema,
|
|
157
188
|
},
|
|
158
189
|
handler: async (request, response, context) => {
|
|
159
190
|
const retainers = await context.getHeapSnapshotRetainers(request.params.filePath, request.params.nodeId);
|
|
160
191
|
response.setHeapSnapshotNodes(retainers, {
|
|
161
192
|
pageIdx: request.params.pageIdx,
|
|
162
193
|
pageSize: request.params.pageSize,
|
|
194
|
+
maxNameLength: request.params.maxNameLength,
|
|
163
195
|
});
|
|
164
196
|
},
|
|
165
197
|
}));
|
|
166
|
-
export const closeHeapSnapshot =
|
|
198
|
+
export const closeHeapSnapshot = defineBrowserlessTool(() => ({
|
|
167
199
|
name: 'close_heapsnapshot',
|
|
168
|
-
description: 'Closes a previously loaded memory heapsnapshot, freeing its memory.',
|
|
200
|
+
description: 'Closes a previously loaded and cached memory heapsnapshot, freeing its memory.',
|
|
169
201
|
annotations: {
|
|
170
202
|
category: ToolCategory.MEMORY,
|
|
171
203
|
readOnlyHint: false,
|
|
@@ -188,9 +220,9 @@ export const closeHeapSnapshot = defineTool(() => ({
|
|
|
188
220
|
response.appendResponseLine(`Closed heap snapshot: ${request.params.filePath}`);
|
|
189
221
|
},
|
|
190
222
|
}));
|
|
191
|
-
export const getHeapSnapshotRetainingPaths =
|
|
223
|
+
export const getHeapSnapshotRetainingPaths = defineBrowserlessTool(() => ({
|
|
192
224
|
name: 'get_heapsnapshot_retaining_paths',
|
|
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.',
|
|
225
|
+
description: 'Loads and caches 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
226
|
annotations: {
|
|
195
227
|
category: ToolCategory.MEMORY,
|
|
196
228
|
readOnlyHint: true,
|
|
@@ -201,7 +233,9 @@ export const getHeapSnapshotRetainingPaths = defineTool(() => ({
|
|
|
201
233
|
},
|
|
202
234
|
blockedByDialog: false,
|
|
203
235
|
schema: {
|
|
204
|
-
filePath: zod
|
|
236
|
+
filePath: zod
|
|
237
|
+
.string()
|
|
238
|
+
.describe('A path to a .heapsnapshot file to read.'),
|
|
205
239
|
nodeId: zod.number().describe('The node ID to get retaining paths for.'),
|
|
206
240
|
maxDepth: zod
|
|
207
241
|
.number()
|
|
@@ -215,15 +249,18 @@ export const getHeapSnapshotRetainingPaths = defineTool(() => ({
|
|
|
215
249
|
.number()
|
|
216
250
|
.optional()
|
|
217
251
|
.describe('The maximum number of siblings to return.'),
|
|
252
|
+
maxNameLength: maxNameLengthSchema,
|
|
218
253
|
},
|
|
219
254
|
handler: async (request, response, context) => {
|
|
220
255
|
const retainingPaths = await context.getHeapSnapshotRetainingPaths(request.params.filePath, request.params.nodeId, request.params.maxDepth, request.params.maxNodes, request.params.maxSiblings);
|
|
221
|
-
response.setHeapSnapshotRetainingPaths(retainingPaths
|
|
256
|
+
response.setHeapSnapshotRetainingPaths(retainingPaths, {
|
|
257
|
+
maxNameLength: request.params.maxNameLength,
|
|
258
|
+
});
|
|
222
259
|
},
|
|
223
260
|
}));
|
|
224
|
-
export const getHeapSnapshotEdges =
|
|
261
|
+
export const getHeapSnapshotEdges = defineBrowserlessTool(() => ({
|
|
225
262
|
name: 'get_heapsnapshot_edges',
|
|
226
|
-
description: 'Loads a memory heapsnapshot and returns outgoing edges (references) for a specific node ID.',
|
|
263
|
+
description: 'Loads and caches a memory heapsnapshot and returns outgoing edges (references) for a specific node ID.',
|
|
227
264
|
annotations: {
|
|
228
265
|
category: ToolCategory.MEMORY,
|
|
229
266
|
readOnlyHint: true,
|
|
@@ -234,7 +271,9 @@ export const getHeapSnapshotEdges = defineTool(() => ({
|
|
|
234
271
|
filePath: true,
|
|
235
272
|
},
|
|
236
273
|
schema: {
|
|
237
|
-
filePath: zod
|
|
274
|
+
filePath: zod
|
|
275
|
+
.string()
|
|
276
|
+
.describe('A path to a .heapsnapshot file to read.'),
|
|
238
277
|
nodeId: zod.number().describe('The node ID to get outgoing edges for.'),
|
|
239
278
|
sortBy: zod
|
|
240
279
|
.enum(['retainedSize', 'selfSize', 'name'])
|
|
@@ -245,8 +284,9 @@ export const getHeapSnapshotEdges = defineTool(() => ({
|
|
|
245
284
|
.boolean()
|
|
246
285
|
.optional()
|
|
247
286
|
.describe('Whether to exclude primitive target nodes. Default is true.'),
|
|
248
|
-
|
|
249
|
-
|
|
287
|
+
maxNameLength: maxNameLengthSchema,
|
|
288
|
+
pageIdx: pageIdxSchema,
|
|
289
|
+
pageSize: pageSizeSchema,
|
|
250
290
|
},
|
|
251
291
|
handler: async (request, response, context) => {
|
|
252
292
|
const edges = await context.getHeapSnapshotEdges(request.params.filePath, request.params.nodeId, {
|
|
@@ -258,12 +298,13 @@ export const getHeapSnapshotEdges = defineTool(() => ({
|
|
|
258
298
|
response.setHeapSnapshotNodes(edges, {
|
|
259
299
|
pageIdx: request.params.pageIdx,
|
|
260
300
|
pageSize: request.params.pageSize,
|
|
301
|
+
maxNameLength: request.params.maxNameLength,
|
|
261
302
|
});
|
|
262
303
|
},
|
|
263
304
|
}));
|
|
264
|
-
export const getHeapSnapshotDominators =
|
|
305
|
+
export const getHeapSnapshotDominators = defineBrowserlessTool(() => ({
|
|
265
306
|
name: 'get_heapsnapshot_dominators',
|
|
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.',
|
|
307
|
+
description: 'Loads and caches 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
308
|
annotations: {
|
|
268
309
|
category: ToolCategory.MEMORY,
|
|
269
310
|
readOnlyHint: true,
|
|
@@ -274,19 +315,24 @@ export const getHeapSnapshotDominators = defineTool(() => ({
|
|
|
274
315
|
filePath: true,
|
|
275
316
|
},
|
|
276
317
|
schema: {
|
|
277
|
-
filePath: zod
|
|
318
|
+
filePath: zod
|
|
319
|
+
.string()
|
|
320
|
+
.describe('A path to a .heapsnapshot file to read.'),
|
|
278
321
|
nodeId: zod
|
|
279
322
|
.number()
|
|
280
323
|
.describe('The node ID to get the dominator chain for.'),
|
|
324
|
+
maxNameLength: maxNameLengthSchema,
|
|
281
325
|
},
|
|
282
326
|
handler: async (request, response, context) => {
|
|
283
327
|
const dominators = await context.getHeapSnapshotDominators(request.params.filePath, request.params.nodeId);
|
|
284
|
-
response.setHeapSnapshotDominators(dominators
|
|
328
|
+
response.setHeapSnapshotDominators(dominators, {
|
|
329
|
+
maxNameLength: request.params.maxNameLength,
|
|
330
|
+
});
|
|
285
331
|
},
|
|
286
332
|
}));
|
|
287
|
-
export const compareHeapSnapshots =
|
|
333
|
+
export const compareHeapSnapshots = defineBrowserlessTool(() => ({
|
|
288
334
|
name: 'compare_heapsnapshots',
|
|
289
|
-
description: 'Loads two memory heapsnapshots and returns the comparison. If classIndex is provided, returns detailed diff for that class, otherwise returns summary diff.',
|
|
335
|
+
description: 'Loads and caches two memory heapsnapshots and returns the comparison. If classIndex is provided, returns detailed diff for that class, otherwise returns summary diff.',
|
|
290
336
|
annotations: {
|
|
291
337
|
category: ToolCategory.MEMORY,
|
|
292
338
|
readOnlyHint: true,
|
|
@@ -307,22 +353,33 @@ export const compareHeapSnapshots = defineTool(() => ({
|
|
|
307
353
|
.number()
|
|
308
354
|
.optional()
|
|
309
355
|
.describe('Optional 0-based index of the class in the summary list to filter results, showing individual objects.'),
|
|
356
|
+
maxNameLength: maxNameLengthSchema,
|
|
357
|
+
pageIdx: pageIdxSchema,
|
|
358
|
+
pageSize: pageSizeSchema,
|
|
310
359
|
},
|
|
311
360
|
blockedByDialog: false,
|
|
312
361
|
handler: async (request, response, context) => {
|
|
313
362
|
if (request.params.classIndex !== undefined) {
|
|
314
363
|
const classDiffResult = await context.getHeapSnapshotDetailedClassDiff(request.params.baseFilePath, request.params.currentFilePath, request.params.classIndex);
|
|
315
|
-
response.setHeapSnapshotDetailedClassDiff(classDiffResult
|
|
364
|
+
response.setHeapSnapshotDetailedClassDiff(classDiffResult, {
|
|
365
|
+
pageIdx: request.params.pageIdx,
|
|
366
|
+
pageSize: request.params.pageSize,
|
|
367
|
+
maxNameLength: request.params.maxNameLength,
|
|
368
|
+
});
|
|
316
369
|
}
|
|
317
370
|
else {
|
|
318
371
|
const diff = await context.getHeapSnapshotClassDiffs(request.params.baseFilePath, request.params.currentFilePath);
|
|
319
|
-
response.setHeapSnapshotClassDiffs(diff
|
|
372
|
+
response.setHeapSnapshotClassDiffs(diff, {
|
|
373
|
+
pageIdx: request.params.pageIdx,
|
|
374
|
+
pageSize: request.params.pageSize,
|
|
375
|
+
maxNameLength: request.params.maxNameLength,
|
|
376
|
+
});
|
|
320
377
|
}
|
|
321
378
|
},
|
|
322
379
|
}));
|
|
323
|
-
export const getHeapSnapshotDuplicateStrings =
|
|
380
|
+
export const getHeapSnapshotDuplicateStrings = defineBrowserlessTool(() => ({
|
|
324
381
|
name: 'get_heapsnapshot_duplicate_strings',
|
|
325
|
-
description: 'Loads a memory heapsnapshot and returns duplicate strings grouped by their value.',
|
|
382
|
+
description: 'Loads and caches a memory heapsnapshot and returns duplicate strings grouped by their value.',
|
|
326
383
|
annotations: {
|
|
327
384
|
category: ToolCategory.MEMORY,
|
|
328
385
|
readOnlyHint: true,
|
|
@@ -333,21 +390,25 @@ export const getHeapSnapshotDuplicateStrings = defineTool(() => ({
|
|
|
333
390
|
filePath: true,
|
|
334
391
|
},
|
|
335
392
|
schema: {
|
|
336
|
-
filePath: zod
|
|
337
|
-
|
|
338
|
-
|
|
393
|
+
filePath: zod
|
|
394
|
+
.string()
|
|
395
|
+
.describe('A path to a .heapsnapshot file to read.'),
|
|
396
|
+
pageIdx: pageIdxSchema,
|
|
397
|
+
pageSize: pageSizeSchema,
|
|
398
|
+
maxNameLength: maxNameLengthSchema,
|
|
339
399
|
},
|
|
340
400
|
handler: async (request, response, context) => {
|
|
341
401
|
const duplicateStrings = await context.getHeapSnapshotDuplicateStrings(request.params.filePath);
|
|
342
402
|
response.setHeapSnapshotDuplicateStrings(duplicateStrings, {
|
|
343
403
|
pageIdx: request.params.pageIdx,
|
|
344
404
|
pageSize: request.params.pageSize,
|
|
405
|
+
maxNameLength: request.params.maxNameLength,
|
|
345
406
|
});
|
|
346
407
|
},
|
|
347
408
|
}));
|
|
348
|
-
export const getHeapSnapshotObjectDetails =
|
|
409
|
+
export const getHeapSnapshotObjectDetails = defineBrowserlessTool(() => ({
|
|
349
410
|
name: 'get_heapsnapshot_object_details',
|
|
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.',
|
|
411
|
+
description: 'Loads and caches a memory heapsnapshot and returns detailed information about a specific object by its node ID, including size, type, distance, and DOM detachedness.',
|
|
351
412
|
annotations: {
|
|
352
413
|
category: ToolCategory.MEMORY,
|
|
353
414
|
readOnlyHint: true,
|
|
@@ -358,17 +419,22 @@ export const getHeapSnapshotObjectDetails = defineTool(() => ({
|
|
|
358
419
|
filePath: true,
|
|
359
420
|
},
|
|
360
421
|
schema: {
|
|
361
|
-
filePath: zod
|
|
422
|
+
filePath: zod
|
|
423
|
+
.string()
|
|
424
|
+
.describe('A path to a .heapsnapshot file to read.'),
|
|
362
425
|
nodeId: zod.number().describe('The node ID to get object details for.'),
|
|
426
|
+
maxNameLength: maxNameLengthSchema,
|
|
363
427
|
},
|
|
364
428
|
handler: async (request, response, context) => {
|
|
365
429
|
const objectInfo = await context.getHeapSnapshotObjectDetails(request.params.filePath, request.params.nodeId);
|
|
366
|
-
response.setHeapSnapshotObjectDetails(objectInfo
|
|
430
|
+
response.setHeapSnapshotObjectDetails(objectInfo, {
|
|
431
|
+
maxNameLength: request.params.maxNameLength,
|
|
432
|
+
});
|
|
367
433
|
},
|
|
368
434
|
}));
|
|
369
|
-
export const queryHeapSnapshotObjects =
|
|
435
|
+
export const queryHeapSnapshotObjects = defineBrowserlessTool(() => ({
|
|
370
436
|
name: 'query_heapsnapshot_objects',
|
|
371
|
-
description: 'Loads a memory heapsnapshot and queries objects matching specific filters (className, propertyName, nodeType, retainedSize, selfSize, isDetached, sortBy).',
|
|
437
|
+
description: 'Loads and caches a memory heapsnapshot and queries objects matching specific filters (className, propertyName, nodeType, retainedSize, selfSize, isDetached, sortBy).',
|
|
372
438
|
annotations: {
|
|
373
439
|
category: ToolCategory.MEMORY,
|
|
374
440
|
readOnlyHint: true,
|
|
@@ -377,7 +443,9 @@ export const queryHeapSnapshotObjects = defineTool(() => ({
|
|
|
377
443
|
blockedByDialog: false,
|
|
378
444
|
verifyFilesSchema: { filePath: true },
|
|
379
445
|
schema: {
|
|
380
|
-
filePath: zod
|
|
446
|
+
filePath: zod
|
|
447
|
+
.string()
|
|
448
|
+
.describe('A path to a .heapsnapshot file to read.'),
|
|
381
449
|
className: zod
|
|
382
450
|
.string()
|
|
383
451
|
.optional()
|
|
@@ -400,8 +468,9 @@ export const queryHeapSnapshotObjects = defineTool(() => ({
|
|
|
400
468
|
.enum(['retainedSize', 'selfSize', 'id'])
|
|
401
469
|
.optional()
|
|
402
470
|
.describe('Sort order for results. Default is retainedSize.'),
|
|
403
|
-
pageIdx:
|
|
404
|
-
pageSize:
|
|
471
|
+
pageIdx: pageIdxSchema,
|
|
472
|
+
pageSize: pageSizeSchema,
|
|
473
|
+
maxNameLength: maxNameLengthSchema,
|
|
405
474
|
},
|
|
406
475
|
handler: async (request, response, context) => {
|
|
407
476
|
const range = await context.queryHeapSnapshotObjects(request.params.filePath, {
|
|
@@ -418,6 +487,44 @@ export const queryHeapSnapshotObjects = defineTool(() => ({
|
|
|
418
487
|
response.setHeapSnapshotNodes(range, {
|
|
419
488
|
pageIdx: request.params.pageIdx,
|
|
420
489
|
pageSize: request.params.pageSize,
|
|
490
|
+
maxNameLength: request.params.maxNameLength,
|
|
491
|
+
});
|
|
492
|
+
},
|
|
493
|
+
}));
|
|
494
|
+
export const analyzeHeapSnapshotContexts = defineBrowserlessTool(() => ({
|
|
495
|
+
name: 'analyze_heapsnapshot_contexts',
|
|
496
|
+
description: 'Loads and caches a memory heapsnapshot to identify and rank closure contexts holding dead captured fields—variables no remaining live closure can read. Scopes are ranked globally by the retained size of these dead values to provide a prioritizing heuristic, rather than an exact measure of reclaimable bytes.',
|
|
497
|
+
annotations: {
|
|
498
|
+
category: ToolCategory.MEMORY,
|
|
499
|
+
readOnlyHint: true,
|
|
500
|
+
conditions: ['memoryDebugging'],
|
|
501
|
+
},
|
|
502
|
+
blockedByDialog: false,
|
|
503
|
+
verifyFilesSchema: {
|
|
504
|
+
filePath: true,
|
|
505
|
+
},
|
|
506
|
+
schema: {
|
|
507
|
+
filePath: zod
|
|
508
|
+
.string()
|
|
509
|
+
.describe('A path to a .heapsnapshot file to read.'),
|
|
510
|
+
retainedSize: byteSizeRangeSchema('Inclusive range for the dead-field score of a context (e.g. "10KB", "1MB-2MB", "-1MB", or "1MB-"). A single value is treated as a minimum.').optional(),
|
|
511
|
+
scopeInfoNodeId: zod
|
|
512
|
+
.number()
|
|
513
|
+
.int()
|
|
514
|
+
.optional()
|
|
515
|
+
.describe('Only return contexts declared by the scope with this ScopeInfo node id, as reported in the scope header of a previous call.'),
|
|
516
|
+
maxNameLength: maxNameLengthSchema,
|
|
517
|
+
pageIdx: pageIdxSchema,
|
|
518
|
+
pageSize: pageSizeSchema,
|
|
519
|
+
},
|
|
520
|
+
handler: async (request, response, context) => {
|
|
521
|
+
const analysis = await context.analyzeHeapSnapshotContexts(request.params.filePath);
|
|
522
|
+
response.setHeapSnapshotContextAnalysis(analysis, {
|
|
523
|
+
retainedSize: request.params.retainedSize,
|
|
524
|
+
scopeInfoNodeId: request.params.scopeInfoNodeId,
|
|
525
|
+
maxNameLength: request.params.maxNameLength,
|
|
526
|
+
pageIdx: request.params.pageIdx,
|
|
527
|
+
pageSize: request.params.pageSize,
|
|
421
528
|
});
|
|
422
529
|
},
|
|
423
530
|
}));
|
|
@@ -18,7 +18,6 @@ const FILTERABLE_RESOURCE_TYPES = [
|
|
|
18
18
|
'fetch',
|
|
19
19
|
'prefetch',
|
|
20
20
|
'eventsource',
|
|
21
|
-
'websocket',
|
|
22
21
|
'manifest',
|
|
23
22
|
'signedexchange',
|
|
24
23
|
'ping',
|
|
@@ -27,7 +26,7 @@ const FILTERABLE_RESOURCE_TYPES = [
|
|
|
27
26
|
'fedcm',
|
|
28
27
|
'other',
|
|
29
28
|
];
|
|
30
|
-
export const listNetworkRequests = definePageTool(() => ({
|
|
29
|
+
export const listNetworkRequests = definePageTool((args) => ({
|
|
31
30
|
name: 'list_network_requests',
|
|
32
31
|
description: `Lists the most recent requests for the target page since the last navigation.`,
|
|
33
32
|
annotations: {
|
|
@@ -46,7 +45,7 @@ export const listNetworkRequests = definePageTool(() => ({
|
|
|
46
45
|
.int()
|
|
47
46
|
.min(0)
|
|
48
47
|
.optional()
|
|
49
|
-
.describe('Page number to return (0-based). When omitted, returns the first page.'),
|
|
48
|
+
.describe('Page number to return (0-based). When omitted, returns the first page. Ignored unless pageSize is set.'),
|
|
50
49
|
resourceTypes: zod
|
|
51
50
|
.array(zod.enum(FILTERABLE_RESOURCE_TYPES))
|
|
52
51
|
.optional()
|
|
@@ -55,9 +54,10 @@ export const listNetworkRequests = definePageTool(() => ({
|
|
|
55
54
|
.boolean()
|
|
56
55
|
.default(false)
|
|
57
56
|
.optional()
|
|
58
|
-
.describe(
|
|
57
|
+
.describe(`Set to true to return the preserved requests over the last ${args.maxNavigationSaved} navigations.`),
|
|
59
58
|
},
|
|
60
59
|
blockedByDialog: false,
|
|
60
|
+
concurrency: 'page',
|
|
61
61
|
verifyFilesSchema: {},
|
|
62
62
|
handler: async (request, response) => {
|
|
63
63
|
const data = await request.page.getDevToolsData();
|
|
@@ -96,6 +96,7 @@ export const getNetworkRequest = definePageTool(() => ({
|
|
|
96
96
|
.describe('The absolute or relative path to a .network-response file to save the response body to. If omitted, the body is returned inline.'),
|
|
97
97
|
},
|
|
98
98
|
blockedByDialog: true,
|
|
99
|
+
concurrency: 'page',
|
|
99
100
|
verifyFilesSchema: {
|
|
100
101
|
requestFilePath: true,
|
|
101
102
|
responseFilePath: true,
|
package/build/src/tools/pages.js
CHANGED
|
@@ -18,6 +18,7 @@ export const listPages = defineTool((args) => {
|
|
|
18
18
|
},
|
|
19
19
|
schema: {},
|
|
20
20
|
blockedByDialog: false,
|
|
21
|
+
concurrency: 'exclusive',
|
|
21
22
|
verifyFilesSchema: {},
|
|
22
23
|
handler: async (_request, response) => {
|
|
23
24
|
response.setIncludePages(true);
|
|
@@ -43,9 +44,11 @@ export const selectPage = defineTool((args) => ({
|
|
|
43
44
|
.describe('Whether to focus the page and bring it to the top.'),
|
|
44
45
|
},
|
|
45
46
|
blockedByDialog: false,
|
|
47
|
+
concurrency: 'exclusive',
|
|
46
48
|
verifyFilesSchema: {},
|
|
47
49
|
handler: async (request, response, context) => {
|
|
48
50
|
const page = context.getPageById(request.params.pageId);
|
|
51
|
+
await page.init({ emulateFocus: true });
|
|
49
52
|
context.selectPage(page);
|
|
50
53
|
response.setIncludePages(true);
|
|
51
54
|
response.setListThirdPartyDeveloperTools();
|
|
@@ -68,6 +71,7 @@ export const closePage = defineTool(() => ({
|
|
|
68
71
|
.describe('The ID of the page to close. Call list_pages to list pages.'),
|
|
69
72
|
},
|
|
70
73
|
blockedByDialog: false,
|
|
74
|
+
concurrency: 'exclusive',
|
|
71
75
|
verifyFilesSchema: {},
|
|
72
76
|
handler: async (request, response, context) => {
|
|
73
77
|
try {
|
|
@@ -108,18 +112,54 @@ export const newPage = defineTool((args) => {
|
|
|
108
112
|
...timeoutSchema,
|
|
109
113
|
},
|
|
110
114
|
blockedByDialog: false,
|
|
115
|
+
concurrency: 'exclusive',
|
|
111
116
|
verifyFilesSchema: {},
|
|
112
117
|
handler: async (request, response, context) => {
|
|
113
118
|
validateUrl(request.params.url, {
|
|
114
119
|
javascriptEvaluation: args?.javascriptEvaluation,
|
|
115
120
|
categoryExtensions: args?.categoryExtensions,
|
|
121
|
+
fileNavigations: args?.fileNavigations,
|
|
116
122
|
});
|
|
123
|
+
let previousPage;
|
|
124
|
+
try {
|
|
125
|
+
previousPage = context.getSelectedMcpPage();
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// Nothing is selected, so there is no selection to restore on failure.
|
|
129
|
+
}
|
|
117
130
|
const page = await context.newPage(request.params.background, request.params.isolatedContext);
|
|
118
|
-
|
|
119
|
-
await page.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
131
|
+
try {
|
|
132
|
+
await page.waitForEventsAfterAction(async () => {
|
|
133
|
+
await page.pptrPage.goto(request.params.url, {
|
|
134
|
+
timeout: request.params.timeout,
|
|
135
|
+
});
|
|
136
|
+
}, { timeout: request.params.timeout });
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
// A dialog-blocked load stays open for handle_dialog. Otherwise cleanup is
|
|
140
|
+
// best-effort: the navigation error is always what gets rethrown.
|
|
141
|
+
if (page.getDialog()) {
|
|
142
|
+
response.setIncludePages(true);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
try {
|
|
146
|
+
if (previousPage && !previousPage.isClosed()) {
|
|
147
|
+
context.selectPage(previousPage);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
// Keep the new tab selected.
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
await context.closePage(page.id);
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
// The tab survived, so list pages to tell the caller its pageId.
|
|
158
|
+
response.setIncludePages(true);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
123
163
|
response.setIncludePages(true);
|
|
124
164
|
response.setListThirdPartyDeveloperTools();
|
|
125
165
|
},
|
|
@@ -158,6 +198,7 @@ export const navigatePage = definePageTool((args) => {
|
|
|
158
198
|
...timeoutSchema,
|
|
159
199
|
},
|
|
160
200
|
blockedByDialog: false,
|
|
201
|
+
concurrency: 'page',
|
|
161
202
|
verifyFilesSchema: {},
|
|
162
203
|
handler: async (request, response) => {
|
|
163
204
|
const page = request.page;
|
|
@@ -174,6 +215,7 @@ export const navigatePage = definePageTool((args) => {
|
|
|
174
215
|
validateUrl(request.params.url, {
|
|
175
216
|
javascriptEvaluation: args?.javascriptEvaluation,
|
|
176
217
|
categoryExtensions: args?.categoryExtensions,
|
|
218
|
+
fileNavigations: args?.fileNavigations,
|
|
177
219
|
});
|
|
178
220
|
}
|
|
179
221
|
let initScriptId;
|
|
@@ -260,10 +302,11 @@ export const resizePage = definePageTool(() => ({
|
|
|
260
302
|
readOnlyHint: false,
|
|
261
303
|
},
|
|
262
304
|
schema: {
|
|
263
|
-
width: zod.number().describe('Page width'),
|
|
264
|
-
height: zod.number().describe('Page height'),
|
|
305
|
+
width: zod.number().int().positive().describe('Page width'),
|
|
306
|
+
height: zod.number().int().positive().describe('Page height'),
|
|
265
307
|
},
|
|
266
308
|
blockedByDialog: false,
|
|
309
|
+
concurrency: 'exclusive',
|
|
267
310
|
verifyFilesSchema: {},
|
|
268
311
|
handler: async (request, response) => {
|
|
269
312
|
const page = request.page;
|
|
@@ -307,6 +350,7 @@ export const handleDialog = definePageTool(() => ({
|
|
|
307
350
|
.describe('Optional prompt text to enter into the dialog.'),
|
|
308
351
|
},
|
|
309
352
|
blockedByDialog: false,
|
|
353
|
+
concurrency: 'page',
|
|
310
354
|
verifyFilesSchema: {},
|
|
311
355
|
handler: async (request, response) => {
|
|
312
356
|
const page = request.page;
|
|
@@ -352,6 +396,7 @@ export const getTabId = definePageTool(() => ({
|
|
|
352
396
|
},
|
|
353
397
|
schema: {},
|
|
354
398
|
blockedByDialog: false,
|
|
399
|
+
concurrency: 'page',
|
|
355
400
|
verifyFilesSchema: {},
|
|
356
401
|
handler: async (request, response) => {
|
|
357
402
|
const page = request.page;
|