chrome-devtools-mcp 0.22.0 → 0.24.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 +4 -0
- package/build/src/DevToolsConnectionAdapter.js +1 -0
- package/build/src/DevtoolsUtils.js +1 -0
- package/build/src/HeapSnapshotManager.js +16 -0
- package/build/src/McpContext.js +54 -126
- package/build/src/McpPage.js +204 -0
- package/build/src/McpResponse.js +44 -6
- package/build/src/Mutex.js +1 -0
- package/build/src/PageCollector.js +1 -0
- package/build/src/SlimMcpResponse.js +1 -0
- package/build/src/TextSnapshot.js +236 -0
- package/build/src/WaitForHelper.js +6 -0
- package/build/src/bin/check-latest-version.js +1 -0
- package/build/src/bin/chrome-devtools-cli-options.js +206 -46
- package/build/src/bin/chrome-devtools-mcp-cli-options.js +13 -1
- package/build/src/bin/chrome-devtools-mcp-main.js +1 -0
- package/build/src/bin/chrome-devtools-mcp.js +1 -0
- package/build/src/bin/chrome-devtools.js +27 -27
- package/build/src/browser.js +1 -0
- package/build/src/daemon/client.js +14 -12
- package/build/src/daemon/daemon.js +7 -5
- package/build/src/daemon/types.js +1 -0
- package/build/src/daemon/utils.js +20 -14
- package/build/src/formatters/ConsoleFormatter.js +48 -1
- package/build/src/formatters/HeapSnapshotFormatter.js +18 -2
- package/build/src/formatters/IssueFormatter.js +1 -0
- package/build/src/formatters/NetworkFormatter.js +1 -0
- package/build/src/formatters/SnapshotFormatter.js +2 -1
- package/build/src/index.js +114 -51
- package/build/src/issue-descriptions.js +1 -0
- package/build/src/logger.js +1 -0
- package/build/src/polyfill.js +1 -0
- package/build/src/telemetry/ClearcutLogger.js +13 -1
- package/build/src/telemetry/WatchdogClient.js +1 -0
- package/build/src/telemetry/flagUtils.js +1 -0
- package/build/src/telemetry/metricUtils.js +1 -0
- package/build/src/telemetry/persistence.js +1 -0
- package/build/src/telemetry/toolMetricsUtils.js +2 -1
- package/build/src/telemetry/types.js +1 -0
- package/build/src/telemetry/watchdog/ClearcutSender.js +1 -0
- package/build/src/telemetry/watchdog/main.js +1 -0
- package/build/src/third_party/THIRD_PARTY_NOTICES +32 -5
- package/build/src/third_party/bundled-packages.json +3 -2
- package/build/src/third_party/devtools-formatter-worker.js +2451 -2933
- package/build/src/third_party/devtools-heap-snapshot-worker.js +32 -26
- package/build/src/third_party/index.js +1942 -1536
- package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +21717 -20261
- package/build/src/tools/ToolDefinition.js +1 -0
- package/build/src/tools/categories.js +6 -2
- package/build/src/tools/console.js +3 -0
- package/build/src/tools/emulation.js +2 -0
- package/build/src/tools/extensions.js +6 -0
- package/build/src/tools/inPage.js +5 -35
- package/build/src/tools/input.js +13 -2
- package/build/src/tools/lighthouse.js +17 -9
- package/build/src/tools/memory.js +34 -1
- package/build/src/tools/network.js +7 -2
- package/build/src/tools/pages.js +218 -146
- package/build/src/tools/performance.js +6 -0
- package/build/src/tools/screencast.js +25 -10
- package/build/src/tools/screenshot.js +3 -0
- package/build/src/tools/script.js +2 -0
- package/build/src/tools/slim/tools.js +4 -0
- package/build/src/tools/snapshot.js +5 -1
- package/build/src/tools/tools.js +1 -0
- package/build/src/tools/webmcp.js +3 -0
- package/build/src/trace-processing/parse.js +1 -0
- package/build/src/types.js +1 -0
- package/build/src/utils/check-for-updates.js +1 -0
- package/build/src/utils/files.js +5 -10
- package/build/src/utils/id.js +1 -0
- package/build/src/utils/keyboard.js +1 -0
- package/build/src/utils/pagination.js +1 -0
- package/build/src/utils/string.js +1 -0
- package/build/src/utils/types.js +1 -0
- package/build/src/version.js +2 -1
- package/package.json +10 -9
- package/build/src/bin/cliDefinitions.js +0 -621
package/build/src/tools/pages.js
CHANGED
|
@@ -7,6 +7,51 @@ import { logger } from '../logger.js';
|
|
|
7
7
|
import { zod } from '../third_party/index.js';
|
|
8
8
|
import { ToolCategory } from './categories.js';
|
|
9
9
|
import { CLOSE_PAGE_ERROR, definePageTool, defineTool, timeoutSchema, } from './ToolDefinition.js';
|
|
10
|
+
async function navigateWithInterception(page, action, allowListString, timeout) {
|
|
11
|
+
const allowList = allowListString
|
|
12
|
+
? allowListString.split(',').map((p) => new URLPattern(p.trim()))
|
|
13
|
+
: undefined;
|
|
14
|
+
const requestHandler = (interceptedRequest) => {
|
|
15
|
+
if (!interceptedRequest.isNavigationRequest()) {
|
|
16
|
+
void interceptedRequest.continue();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const requestUrl = interceptedRequest.url();
|
|
20
|
+
const isAllowed = allowList.some((pattern) => pattern.test(requestUrl));
|
|
21
|
+
if (isAllowed) {
|
|
22
|
+
void interceptedRequest.continue();
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
logger(`Blocking request to: ${requestUrl}`);
|
|
26
|
+
void interceptedRequest.abort('blockedbyclient');
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const cleanupInterception = async () => {
|
|
30
|
+
if (allowList) {
|
|
31
|
+
page.pptrPage.off('request', requestHandler);
|
|
32
|
+
await page.pptrPage.setRequestInterception(false).catch(error => {
|
|
33
|
+
logger(`Failed to disable request interception`, error);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
if (allowList) {
|
|
38
|
+
await page.pptrPage.setRequestInterception(true);
|
|
39
|
+
page.pptrPage.on('request', requestHandler);
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
await page.waitForEventsAfterAction(async () => {
|
|
43
|
+
try {
|
|
44
|
+
await action();
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
await cleanupInterception();
|
|
48
|
+
}
|
|
49
|
+
}, { timeout });
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
await cleanupInterception();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
10
55
|
export const listPages = defineTool(args => {
|
|
11
56
|
return {
|
|
12
57
|
name: 'list_pages',
|
|
@@ -16,6 +61,7 @@ export const listPages = defineTool(args => {
|
|
|
16
61
|
readOnlyHint: true,
|
|
17
62
|
},
|
|
18
63
|
schema: {},
|
|
64
|
+
blockedByDialog: false,
|
|
19
65
|
handler: async (_request, response) => {
|
|
20
66
|
response.setIncludePages(true);
|
|
21
67
|
response.setListInPageTools();
|
|
@@ -39,6 +85,7 @@ export const selectPage = defineTool({
|
|
|
39
85
|
.optional()
|
|
40
86
|
.describe('Whether to focus the page and bring it to the top.'),
|
|
41
87
|
},
|
|
88
|
+
blockedByDialog: false,
|
|
42
89
|
handler: async (request, response, context) => {
|
|
43
90
|
const page = context.getPageById(request.params.pageId);
|
|
44
91
|
context.selectPage(page);
|
|
@@ -62,6 +109,7 @@ export const closePage = defineTool({
|
|
|
62
109
|
.number()
|
|
63
110
|
.describe('The ID of the page to close. Call list_pages to list pages.'),
|
|
64
111
|
},
|
|
112
|
+
blockedByDialog: false,
|
|
65
113
|
handler: async (request, response, context) => {
|
|
66
114
|
try {
|
|
67
115
|
await context.closePage(request.params.pageId);
|
|
@@ -78,159 +126,179 @@ export const closePage = defineTool({
|
|
|
78
126
|
response.setListInPageTools();
|
|
79
127
|
},
|
|
80
128
|
});
|
|
81
|
-
export const newPage = defineTool({
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
129
|
+
export const newPage = defineTool(args => {
|
|
130
|
+
return {
|
|
131
|
+
name: 'new_page',
|
|
132
|
+
description: `Open a new tab and load a URL. Use project URL if not specified otherwise.`,
|
|
133
|
+
annotations: {
|
|
134
|
+
category: ToolCategory.NAVIGATION,
|
|
135
|
+
readOnlyHint: false,
|
|
136
|
+
},
|
|
137
|
+
schema: {
|
|
138
|
+
url: zod.string().describe('URL to load in a new page.'),
|
|
139
|
+
background: zod
|
|
140
|
+
.boolean()
|
|
141
|
+
.optional()
|
|
142
|
+
.describe('Whether to open the page in the background without bringing it to the front. Default is false (foreground).'),
|
|
143
|
+
isolatedContext: zod
|
|
144
|
+
.string()
|
|
145
|
+
.optional()
|
|
146
|
+
.describe('If specified, the page is created in an isolated browser context with the given name. ' +
|
|
147
|
+
'Pages in the same browser context share cookies and storage. ' +
|
|
148
|
+
'Pages in different browser contexts are fully isolated.'),
|
|
149
|
+
...(args?.experimentalNavigationAllowlist
|
|
150
|
+
? {
|
|
151
|
+
allowList: zod
|
|
152
|
+
.string()
|
|
153
|
+
.optional()
|
|
154
|
+
.describe('Optional comma-separated list of URL patterns to allow. If provided, all other navigations will be blocked.'),
|
|
155
|
+
}
|
|
156
|
+
: {}),
|
|
157
|
+
...timeoutSchema,
|
|
158
|
+
},
|
|
159
|
+
blockedByDialog: false,
|
|
160
|
+
handler: async (request, response, context) => {
|
|
161
|
+
const page = await context.newPage(request.params.background, request.params.isolatedContext);
|
|
162
|
+
await navigateWithInterception(page, () => page.pptrPage.goto(request.params.url, {
|
|
106
163
|
timeout: request.params.timeout,
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
164
|
+
}), request.params.allowList, request.params.timeout);
|
|
165
|
+
response.setIncludePages(true);
|
|
166
|
+
response.setListInPageTools();
|
|
167
|
+
},
|
|
168
|
+
};
|
|
112
169
|
});
|
|
113
|
-
export const navigatePage = definePageTool({
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (!request.params.type && !request.params.url) {
|
|
146
|
-
throw new Error('Either URL or a type is required.');
|
|
147
|
-
}
|
|
148
|
-
if (!request.params.type) {
|
|
149
|
-
request.params.type = 'url';
|
|
150
|
-
}
|
|
151
|
-
const handleBeforeUnload = request.params.handleBeforeUnload ?? 'accept';
|
|
152
|
-
const dialogHandler = (dialog) => {
|
|
153
|
-
if (dialog.type() === 'beforeunload') {
|
|
154
|
-
if (handleBeforeUnload === 'accept') {
|
|
155
|
-
response.appendResponseLine(`Accepted a beforeunload dialog.`);
|
|
156
|
-
void dialog.accept();
|
|
170
|
+
export const navigatePage = definePageTool(args => {
|
|
171
|
+
return {
|
|
172
|
+
name: 'navigate_page',
|
|
173
|
+
description: `Go to a URL, or back, forward, or reload. Use project URL if not specified otherwise.`,
|
|
174
|
+
annotations: {
|
|
175
|
+
category: ToolCategory.NAVIGATION,
|
|
176
|
+
readOnlyHint: false,
|
|
177
|
+
},
|
|
178
|
+
schema: {
|
|
179
|
+
type: zod
|
|
180
|
+
.enum(['url', 'back', 'forward', 'reload'])
|
|
181
|
+
.optional()
|
|
182
|
+
.describe('Navigate the page by URL, back or forward in history, or reload.'),
|
|
183
|
+
url: zod.string().optional().describe('Target URL (only type=url)'),
|
|
184
|
+
ignoreCache: zod
|
|
185
|
+
.boolean()
|
|
186
|
+
.optional()
|
|
187
|
+
.describe('Whether to ignore cache on reload.'),
|
|
188
|
+
handleBeforeUnload: zod
|
|
189
|
+
.enum(['accept', 'decline'])
|
|
190
|
+
.optional()
|
|
191
|
+
.describe('Whether to auto accept or beforeunload dialogs triggered by this navigation. Default is accept.'),
|
|
192
|
+
initScript: zod
|
|
193
|
+
.string()
|
|
194
|
+
.optional()
|
|
195
|
+
.describe('A JavaScript script to be executed on each new document before any other scripts for the next navigation.'),
|
|
196
|
+
...(args?.experimentalNavigationAllowlist
|
|
197
|
+
? {
|
|
198
|
+
allowList: zod
|
|
199
|
+
.string()
|
|
200
|
+
.optional()
|
|
201
|
+
.describe('Optional comma-separated list of URL patterns to allow. If provided, all other navigations will be blocked.'),
|
|
157
202
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
203
|
+
: {}),
|
|
204
|
+
...timeoutSchema,
|
|
205
|
+
},
|
|
206
|
+
blockedByDialog: false,
|
|
207
|
+
handler: async (request, response) => {
|
|
208
|
+
const page = request.page;
|
|
209
|
+
const options = {
|
|
210
|
+
timeout: request.params.timeout,
|
|
211
|
+
};
|
|
212
|
+
if (!request.params.type && !request.params.url) {
|
|
213
|
+
throw new Error('Either URL or a type is required.');
|
|
214
|
+
}
|
|
215
|
+
if (!request.params.type) {
|
|
216
|
+
request.params.type = 'url';
|
|
217
|
+
}
|
|
218
|
+
const handleBeforeUnload = request.params.handleBeforeUnload ?? 'accept';
|
|
219
|
+
const dialogHandler = (dialog) => {
|
|
220
|
+
if (dialog.type() === 'beforeunload') {
|
|
221
|
+
if (handleBeforeUnload === 'accept') {
|
|
222
|
+
response.appendResponseLine(`Accepted a beforeunload dialog.`);
|
|
223
|
+
void dialog.accept();
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
response.appendResponseLine(`Declined a beforeunload dialog.`);
|
|
227
|
+
void dialog.dismiss();
|
|
228
|
+
}
|
|
229
|
+
// We are not going to report the dialog like regular dialogs.
|
|
230
|
+
page.clearDialog();
|
|
161
231
|
}
|
|
162
|
-
|
|
163
|
-
|
|
232
|
+
};
|
|
233
|
+
let initScriptId;
|
|
234
|
+
if (request.params.initScript) {
|
|
235
|
+
const { identifier } = await page.pptrPage.evaluateOnNewDocument(request.params.initScript);
|
|
236
|
+
initScriptId = identifier;
|
|
164
237
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
238
|
+
page.pptrPage.on('dialog', dialogHandler);
|
|
239
|
+
try {
|
|
240
|
+
await navigateWithInterception(page, async () => {
|
|
241
|
+
switch (request.params.type) {
|
|
242
|
+
case 'url':
|
|
243
|
+
if (!request.params.url) {
|
|
244
|
+
throw new Error('A URL is required for navigation of type=url.');
|
|
245
|
+
}
|
|
246
|
+
try {
|
|
247
|
+
await page.pptrPage.goto(request.params.url, options);
|
|
248
|
+
response.appendResponseLine(`Successfully navigated to ${request.params.url}.`);
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
response.appendResponseLine(`Unable to navigate in the selected page: ${error.message}.`);
|
|
252
|
+
}
|
|
253
|
+
break;
|
|
254
|
+
case 'back':
|
|
255
|
+
try {
|
|
256
|
+
await page.pptrPage.goBack(options);
|
|
257
|
+
response.appendResponseLine(`Successfully navigated back to ${page.pptrPage.url()}.`);
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
response.appendResponseLine(`Unable to navigate back in the selected page: ${error.message}.`);
|
|
261
|
+
}
|
|
262
|
+
break;
|
|
263
|
+
case 'forward':
|
|
264
|
+
try {
|
|
265
|
+
await page.pptrPage.goForward(options);
|
|
266
|
+
response.appendResponseLine(`Successfully navigated forward to ${page.pptrPage.url()}.`);
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
response.appendResponseLine(`Unable to navigate forward in the selected page: ${error.message}.`);
|
|
270
|
+
}
|
|
271
|
+
break;
|
|
272
|
+
case 'reload':
|
|
273
|
+
try {
|
|
274
|
+
await page.pptrPage.reload({
|
|
275
|
+
...options,
|
|
276
|
+
ignoreCache: request.params.ignoreCache,
|
|
277
|
+
});
|
|
278
|
+
response.appendResponseLine(`Successfully reloaded the page.`);
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
response.appendResponseLine(`Unable to reload the selected page: ${error.message}.`);
|
|
282
|
+
}
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
}, request.params.allowList, request.params.timeout);
|
|
286
|
+
}
|
|
287
|
+
finally {
|
|
288
|
+
page.pptrPage.off('dialog', dialogHandler);
|
|
289
|
+
if (initScriptId) {
|
|
290
|
+
await page.pptrPage
|
|
291
|
+
.removeScriptToEvaluateOnNewDocument(initScriptId)
|
|
292
|
+
.catch(error => {
|
|
293
|
+
logger(`Failed to remove init script`, error);
|
|
294
|
+
});
|
|
217
295
|
}
|
|
218
|
-
}, { timeout: request.params.timeout });
|
|
219
|
-
}
|
|
220
|
-
finally {
|
|
221
|
-
page.pptrPage.off('dialog', dialogHandler);
|
|
222
|
-
if (initScriptId) {
|
|
223
|
-
await page.pptrPage
|
|
224
|
-
.removeScriptToEvaluateOnNewDocument(initScriptId)
|
|
225
|
-
.catch(error => {
|
|
226
|
-
logger(`Failed to remove init script`, error);
|
|
227
|
-
});
|
|
228
296
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
297
|
+
response.setIncludePages(true);
|
|
298
|
+
response.setListInPageTools();
|
|
299
|
+
response.setListWebMcpTools();
|
|
300
|
+
},
|
|
301
|
+
};
|
|
234
302
|
});
|
|
235
303
|
export const resizePage = definePageTool({
|
|
236
304
|
name: 'resize_page',
|
|
@@ -243,6 +311,7 @@ export const resizePage = definePageTool({
|
|
|
243
311
|
width: zod.number().describe('Page width'),
|
|
244
312
|
height: zod.number().describe('Page height'),
|
|
245
313
|
},
|
|
314
|
+
blockedByDialog: false,
|
|
246
315
|
handler: async (request, response, _context) => {
|
|
247
316
|
const page = request.page;
|
|
248
317
|
try {
|
|
@@ -284,6 +353,7 @@ export const handleDialog = definePageTool({
|
|
|
284
353
|
.optional()
|
|
285
354
|
.describe('Optional prompt text to enter into the dialog.'),
|
|
286
355
|
},
|
|
356
|
+
blockedByDialog: false,
|
|
287
357
|
handler: async (request, response, _context) => {
|
|
288
358
|
const page = request.page;
|
|
289
359
|
const dialog = page.getDialog();
|
|
@@ -331,9 +401,11 @@ export const getTabId = definePageTool({
|
|
|
331
401
|
.number()
|
|
332
402
|
.describe(`The ID of the page to get the tab ID for. Call ${listPages().name} to get available pages.`),
|
|
333
403
|
},
|
|
404
|
+
blockedByDialog: false,
|
|
334
405
|
handler: async (request, response, context) => {
|
|
335
406
|
const page = context.getPageById(request.params.pageId);
|
|
336
407
|
const tabId = page.pptrPage._tabId;
|
|
337
408
|
response.setTabId(tabId);
|
|
338
409
|
},
|
|
339
410
|
});
|
|
411
|
+
//# sourceMappingURL=pages.js.map
|
|
@@ -31,7 +31,9 @@ export const startTrace = definePageTool({
|
|
|
31
31
|
.describe('Determines if the trace recording should be automatically stopped.'),
|
|
32
32
|
filePath: filePathSchema,
|
|
33
33
|
},
|
|
34
|
+
blockedByDialog: true,
|
|
34
35
|
handler: async (request, response, context) => {
|
|
36
|
+
context.validatePath(request.params.filePath);
|
|
35
37
|
if (context.isRunningPerformanceTrace()) {
|
|
36
38
|
response.appendResponseLine('Error: a performance trace is already running. Use performance_stop_trace to stop it. Only one trace can be running at any given time.');
|
|
37
39
|
return;
|
|
@@ -93,7 +95,9 @@ export const stopTrace = definePageTool({
|
|
|
93
95
|
schema: {
|
|
94
96
|
filePath: filePathSchema,
|
|
95
97
|
},
|
|
98
|
+
blockedByDialog: true,
|
|
96
99
|
handler: async (request, response, context) => {
|
|
100
|
+
context.validatePath(request.params.filePath);
|
|
97
101
|
if (!context.isRunningPerformanceTrace()) {
|
|
98
102
|
return;
|
|
99
103
|
}
|
|
@@ -116,6 +120,7 @@ export const analyzeInsight = definePageTool({
|
|
|
116
120
|
.string()
|
|
117
121
|
.describe('The name of the Insight you want more information on. For example: "DocumentLatency" or "LCPBreakdown"'),
|
|
118
122
|
},
|
|
123
|
+
blockedByDialog: false,
|
|
119
124
|
handler: async (request, response, context) => {
|
|
120
125
|
const lastRecording = context.recordedTraces().at(-1);
|
|
121
126
|
if (!lastRecording) {
|
|
@@ -188,3 +193,4 @@ async function populateCruxData(result) {
|
|
|
188
193
|
}));
|
|
189
194
|
result.parsedTrace.metadata.cruxFieldData = cruxData;
|
|
190
195
|
}
|
|
196
|
+
//# sourceMappingURL=performance.js.map
|
|
@@ -14,33 +14,46 @@ async function generateTempFilePath() {
|
|
|
14
14
|
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'chrome-devtools-mcp-'));
|
|
15
15
|
return path.join(dir, `screencast.mp4`);
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
const supportedExtensions = ['.webm', '.mp4'];
|
|
18
|
+
export const startScreencast = definePageTool(args => ({
|
|
18
19
|
name: 'screencast_start',
|
|
19
|
-
description:
|
|
20
|
+
description: `Starts recording a screencast (video) of the selected page in specified format.`,
|
|
20
21
|
annotations: {
|
|
21
22
|
category: ToolCategory.DEBUGGING,
|
|
22
23
|
readOnlyHint: false,
|
|
23
|
-
conditions: ['
|
|
24
|
+
conditions: ['experimentalScreencast'],
|
|
24
25
|
},
|
|
25
26
|
schema: {
|
|
26
|
-
|
|
27
|
+
filePath: zod
|
|
27
28
|
.string()
|
|
28
29
|
.optional()
|
|
29
|
-
.describe(
|
|
30
|
+
.describe(`Output file path (${supportedExtensions.join(',')} are supported). Uses mkdtemp to generate a unique path if not provided.`),
|
|
30
31
|
},
|
|
32
|
+
blockedByDialog: false,
|
|
31
33
|
handler: async (request, response, context) => {
|
|
34
|
+
context.validatePath(request.params.filePath);
|
|
32
35
|
if (context.getScreenRecorder() !== null) {
|
|
33
36
|
response.appendResponseLine('Error: a screencast recording is already in progress. Use screencast_stop to stop it before starting a new one.');
|
|
34
37
|
return;
|
|
35
38
|
}
|
|
36
|
-
const filePath = request.params.
|
|
37
|
-
|
|
39
|
+
const filePath = request.params.filePath ?? (await generateTempFilePath());
|
|
40
|
+
let enforcedExtension = '.mp4';
|
|
41
|
+
let format = 'mp4';
|
|
42
|
+
for (const supportedExtension of supportedExtensions) {
|
|
43
|
+
if (filePath.endsWith(supportedExtension)) {
|
|
44
|
+
enforcedExtension = supportedExtension;
|
|
45
|
+
format = supportedExtension.substring(1);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const resolvedPath = ensureExtension(path.resolve(filePath), enforcedExtension);
|
|
38
50
|
const page = request.page;
|
|
39
51
|
let recorder;
|
|
40
52
|
try {
|
|
41
53
|
recorder = await page.pptrPage.screencast({
|
|
42
54
|
path: resolvedPath,
|
|
43
|
-
format:
|
|
55
|
+
format: format,
|
|
56
|
+
ffmpegPath: args?.experimentalFfmpegPath,
|
|
44
57
|
});
|
|
45
58
|
}
|
|
46
59
|
catch (err) {
|
|
@@ -54,16 +67,17 @@ export const startScreencast = definePageTool({
|
|
|
54
67
|
context.setScreenRecorder({ recorder, filePath: resolvedPath });
|
|
55
68
|
response.appendResponseLine(`Screencast recording started. The recording will be saved to ${resolvedPath}. Use ${stopScreencast.name} to stop recording.`);
|
|
56
69
|
},
|
|
57
|
-
});
|
|
70
|
+
}));
|
|
58
71
|
export const stopScreencast = definePageTool({
|
|
59
72
|
name: 'screencast_stop',
|
|
60
73
|
description: 'Stops the active screencast recording on the selected page.',
|
|
61
74
|
annotations: {
|
|
62
75
|
category: ToolCategory.DEBUGGING,
|
|
63
76
|
readOnlyHint: false,
|
|
64
|
-
conditions: ['
|
|
77
|
+
conditions: ['experimentalScreencast'],
|
|
65
78
|
},
|
|
66
79
|
schema: {},
|
|
80
|
+
blockedByDialog: false,
|
|
67
81
|
handler: async (_request, response, context) => {
|
|
68
82
|
const data = context.getScreenRecorder();
|
|
69
83
|
if (!data) {
|
|
@@ -78,3 +92,4 @@ export const stopScreencast = definePageTool({
|
|
|
78
92
|
}
|
|
79
93
|
},
|
|
80
94
|
});
|
|
95
|
+
//# sourceMappingURL=screencast.js.map
|
|
@@ -38,7 +38,9 @@ export const screenshot = definePageTool({
|
|
|
38
38
|
.optional()
|
|
39
39
|
.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.'),
|
|
40
40
|
},
|
|
41
|
+
blockedByDialog: true,
|
|
41
42
|
handler: async (request, response, context) => {
|
|
43
|
+
context.validatePath(request.params.filePath);
|
|
42
44
|
if (request.params.uid && request.params.fullPage) {
|
|
43
45
|
throw new Error('Providing both "uid" and "fullPage" is not allowed.');
|
|
44
46
|
}
|
|
@@ -82,3 +84,4 @@ export const screenshot = definePageTool({
|
|
|
82
84
|
}
|
|
83
85
|
},
|
|
84
86
|
});
|
|
87
|
+
//# sourceMappingURL=screenshot.js.map
|
|
@@ -46,6 +46,7 @@ Example with arguments: \`(el) => {
|
|
|
46
46
|
}
|
|
47
47
|
: {}),
|
|
48
48
|
},
|
|
49
|
+
blockedByDialog: true,
|
|
49
50
|
handler: async (request, response, context) => {
|
|
50
51
|
const { serviceWorkerId, args: uidArgs, function: fnString, pageId, dialogAction, } = request.params;
|
|
51
52
|
if (cliArgs?.categoryExtensions && serviceWorkerId) {
|
|
@@ -125,3 +126,4 @@ const getWebWorker = async (context, serviceWorkerId) => {
|
|
|
125
126
|
throw new Error('Service worker not found.');
|
|
126
127
|
}
|
|
127
128
|
};
|
|
129
|
+
//# sourceMappingURL=script.js.map
|
|
@@ -15,6 +15,7 @@ export const screenshot = definePageTool({
|
|
|
15
15
|
readOnlyHint: false,
|
|
16
16
|
},
|
|
17
17
|
schema: {},
|
|
18
|
+
blockedByDialog: true,
|
|
18
19
|
handler: async (request, response, context) => {
|
|
19
20
|
const page = request.page;
|
|
20
21
|
const screenshot = await page.pptrPage.screenshot({
|
|
@@ -35,6 +36,7 @@ export const navigate = definePageTool({
|
|
|
35
36
|
schema: {
|
|
36
37
|
url: zod.string().describe('URL to navigate to'),
|
|
37
38
|
},
|
|
39
|
+
blockedByDialog: false,
|
|
38
40
|
handler: async (request, response) => {
|
|
39
41
|
const page = request.page;
|
|
40
42
|
const options = {
|
|
@@ -68,6 +70,7 @@ export const evaluate = definePageTool({
|
|
|
68
70
|
schema: {
|
|
69
71
|
script: zod.string().describe(`JS script to run on the page`),
|
|
70
72
|
},
|
|
73
|
+
blockedByDialog: true,
|
|
71
74
|
handler: async (request, response) => {
|
|
72
75
|
const page = request.page;
|
|
73
76
|
try {
|
|
@@ -79,3 +82,4 @@ export const evaluate = definePageTool({
|
|
|
79
82
|
}
|
|
80
83
|
},
|
|
81
84
|
});
|
|
85
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -26,7 +26,9 @@ in the DevTools Elements panel (if any).`,
|
|
|
26
26
|
.optional()
|
|
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
|
+
handler: async (request, response, context) => {
|
|
31
|
+
context.validatePath(request.params.filePath);
|
|
30
32
|
response.includeSnapshot({
|
|
31
33
|
verbose: request.params.verbose ?? false,
|
|
32
34
|
filePath: request.params.filePath,
|
|
@@ -47,6 +49,7 @@ export const waitFor = definePageTool({
|
|
|
47
49
|
.describe('Non-empty list of texts. Resolves when any value appears on the page.'),
|
|
48
50
|
...timeoutSchema,
|
|
49
51
|
},
|
|
52
|
+
blockedByDialog: true,
|
|
50
53
|
handler: async (request, response, context) => {
|
|
51
54
|
const page = request.page;
|
|
52
55
|
await context.waitForTextOnPage(request.params.text, request.params.timeout, page.pptrPage);
|
|
@@ -54,3 +57,4 @@ export const waitFor = definePageTool({
|
|
|
54
57
|
response.includeSnapshot();
|
|
55
58
|
},
|
|
56
59
|
});
|
|
60
|
+
//# sourceMappingURL=snapshot.js.map
|
package/build/src/tools/tools.js
CHANGED
|
@@ -15,6 +15,7 @@ export const listWebMcpTools = definePageTool({
|
|
|
15
15
|
conditions: ['experimentalWebmcp'],
|
|
16
16
|
},
|
|
17
17
|
schema: {},
|
|
18
|
+
blockedByDialog: false,
|
|
18
19
|
handler: async (_request, response, _context) => {
|
|
19
20
|
response.setListWebMcpTools();
|
|
20
21
|
},
|
|
@@ -34,6 +35,7 @@ export const executeWebMcpTool = definePageTool({
|
|
|
34
35
|
.optional()
|
|
35
36
|
.describe('The JSON-stringified parameters to pass to the WebMCP tool'),
|
|
36
37
|
},
|
|
38
|
+
blockedByDialog: false,
|
|
37
39
|
handler: async (request, response) => {
|
|
38
40
|
const toolName = request.params.toolName;
|
|
39
41
|
let input = {};
|
|
@@ -61,3 +63,4 @@ export const executeWebMcpTool = definePageTool({
|
|
|
61
63
|
response.appendResponseLine(JSON.stringify({ status, output, errorText }, null, 2));
|
|
62
64
|
},
|
|
63
65
|
});
|
|
66
|
+
//# sourceMappingURL=webmcp.js.map
|
|
@@ -82,3 +82,4 @@ export function getInsightOutput(result, insightSetId, insightName) {
|
|
|
82
82
|
const formatter = new DevTools.PerformanceInsightFormatter(DevTools.AgentFocus.fromParsedTrace(result.parsedTrace), matchingInsight);
|
|
83
83
|
return { output: formatter.formatInsight() };
|
|
84
84
|
}
|
|
85
|
+
//# sourceMappingURL=parse.js.map
|