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.
- package/README.md +20 -908
- package/build/src/BrowserManager.js +401 -0
- package/build/src/McpContext.js +43 -26
- package/build/src/McpPage.js +112 -4
- package/build/src/McpResponse.js +68 -3
- package/build/src/ToolHandler.js +184 -160
- package/build/src/bin/chrome-devtools-mcp-main.js +12 -7
- package/build/src/bin/chrome-devtools.js +6 -12
- package/build/src/collectors/PageCollector.js +66 -3
- package/build/src/config/browser-options.js +125 -0
- package/build/src/config/category-options.js +89 -0
- package/build/src/config/cli-commands.js +26 -0
- package/build/src/config/cli-options.js +34 -2
- package/build/src/config/mcp-options.js +86 -147
- package/build/src/daemon/utils.js +6 -0
- package/build/src/devtools/DevToolsCommentBridge.js +91 -0
- package/build/src/devtools/DevtoolsUtils.js +27 -21
- package/build/src/formatters/CommentFormatter.js +82 -0
- package/build/src/formatters/CssFormatter.js +812 -0
- package/build/src/formatters/NetworkFormatter.js +5 -2
- package/build/src/index.js +175 -128
- package/build/src/processors/ChunkedTraceParser.js +361 -0
- package/build/src/processors/PerformanceTrace.js +60 -13
- package/build/src/telemetry/ClearcutLogger.js +95 -37
- package/build/src/telemetry/metricsRegistry.js +3 -0
- package/build/src/telemetry/persistence.js +17 -7
- package/build/src/telemetry/transformation.js +53 -4
- package/build/src/telemetry/types.js +1 -0
- package/build/src/third_party/THIRD_PARTY_NOTICES +687 -133
- package/build/src/third_party/bundled-packages.json +6 -3
- package/build/src/third_party/devtools-formatter-worker.js +158 -5
- package/build/src/third_party/devtools-heap-snapshot-worker.js +589 -6
- package/build/src/third_party/index.js +59173 -38013
- package/build/src/third_party/issue-descriptions/webInstallManifestMissingId.md +3 -0
- package/build/src/third_party/issue-descriptions/webInstallManifestMissingNameOrShortName.md +3 -0
- package/build/src/third_party/issue-descriptions/webInstallManifestParsingOrNetworkError.md +3 -0
- package/build/src/third_party/issue-descriptions/webInstallNoManifest.md +3 -0
- package/build/src/third_party/issue-descriptions/webInstallStartUrlInvalid.md +3 -0
- package/build/src/tools/ToolDefinition.js +28 -21
- package/build/src/tools/categories.js +0 -6
- package/build/src/tools/comments.js +169 -0
- package/build/src/tools/console.js +3 -3
- package/build/src/tools/css.js +45 -0
- package/build/src/tools/emulation.js +5 -5
- package/build/src/tools/extensions.js +10 -10
- package/build/src/tools/input.js +159 -87
- package/build/src/tools/lighthouse.js +18 -7
- package/build/src/tools/memory.js +26 -26
- package/build/src/tools/network.js +5 -5
- package/build/src/tools/pages.js +34 -19
- package/build/src/tools/performance.js +7 -6
- package/build/src/tools/pwa.js +8 -8
- package/build/src/tools/screencast.js +5 -4
- package/build/src/tools/screenshot.js +2 -2
- package/build/src/tools/script.js +8 -7
- package/build/src/tools/slim/tools.js +45 -37
- package/build/src/tools/snapshot.js +4 -4
- package/build/src/tools/thirdPartyDeveloper.js +4 -4
- package/build/src/tools/tools.js +6 -9
- package/build/src/tools/webmcp.js +4 -4
- package/build/src/types.js +4 -1
- package/build/src/utils/WaitForHelper.js +26 -9
- package/build/src/utils/logger.js +7 -6
- package/build/src/utils/url.js +73 -0
- package/build/src/version.js +1 -1
- package/package.json +9 -6
- package/skills/chrome-devtools/SKILL.md +2 -1
- package/skills/chrome-devtools-cli/SKILL.md +3 -7
- package/skills/cookie-debugging/SKILL.md +149 -0
- package/skills/memory-leak-debugging/SKILL.md +4 -0
- package/build/src/browser.js +0 -244
- package/build/src/third_party/issue-descriptions/cookieExcludeBlockedWithinRelatedWebsiteSet.md +0 -4
package/build/src/tools/pages.js
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { zod } from '../third_party/index.js';
|
|
7
7
|
import { logger } from '../utils/logger.js';
|
|
8
|
+
import { validateUrl } from '../utils/url.js';
|
|
8
9
|
import { ToolCategory } from './categories.js';
|
|
9
10
|
import { CLOSE_PAGE_ERROR, definePageTool, defineTool, timeoutSchema, } from './ToolDefinition.js';
|
|
10
|
-
export const listPages = defineTool(args => {
|
|
11
|
+
export const listPages = defineTool((args) => {
|
|
11
12
|
return {
|
|
12
13
|
name: 'list_pages',
|
|
13
14
|
description: `Get a list of pages${args?.categoryExtensions ? ' including extension service workers' : ''} open in the browser.`,
|
|
@@ -25,7 +26,7 @@ export const listPages = defineTool(args => {
|
|
|
25
26
|
},
|
|
26
27
|
};
|
|
27
28
|
});
|
|
28
|
-
export const selectPage = defineTool({
|
|
29
|
+
export const selectPage = defineTool((args) => ({
|
|
29
30
|
name: 'select_page',
|
|
30
31
|
description: `Select a page as a context for future tool calls.`,
|
|
31
32
|
annotations: {
|
|
@@ -35,7 +36,7 @@ export const selectPage = defineTool({
|
|
|
35
36
|
schema: {
|
|
36
37
|
pageId: zod
|
|
37
38
|
.number()
|
|
38
|
-
.describe(`The ID of the page to select. Call ${listPages().name} to get available pages.`),
|
|
39
|
+
.describe(`The ID of the page to select. Call ${listPages(args).name} to get available pages.`),
|
|
39
40
|
bringToFront: zod
|
|
40
41
|
.boolean()
|
|
41
42
|
.optional()
|
|
@@ -53,8 +54,8 @@ export const selectPage = defineTool({
|
|
|
53
54
|
await page.pptrPage.bringToFront();
|
|
54
55
|
}
|
|
55
56
|
},
|
|
56
|
-
});
|
|
57
|
-
export const closePage = defineTool({
|
|
57
|
+
}));
|
|
58
|
+
export const closePage = defineTool(() => ({
|
|
58
59
|
name: 'close_page',
|
|
59
60
|
description: `Closes the page by its index. The last open page cannot be closed.`,
|
|
60
61
|
annotations: {
|
|
@@ -83,8 +84,8 @@ export const closePage = defineTool({
|
|
|
83
84
|
response.setIncludePages(true);
|
|
84
85
|
response.setListThirdPartyDeveloperTools();
|
|
85
86
|
},
|
|
86
|
-
});
|
|
87
|
-
export const newPage = defineTool(() => {
|
|
87
|
+
}));
|
|
88
|
+
export const newPage = defineTool((args) => {
|
|
88
89
|
return {
|
|
89
90
|
name: 'new_page',
|
|
90
91
|
description: `Open a new tab and load a URL. Use project URL if not specified otherwise.`,
|
|
@@ -103,12 +104,16 @@ export const newPage = defineTool(() => {
|
|
|
103
104
|
.optional()
|
|
104
105
|
.describe('If specified, the page is created in an isolated browser context with the given name. ' +
|
|
105
106
|
'Pages in the same browser context share cookies and storage. ' +
|
|
106
|
-
'Pages in different browser contexts are fully isolated.'),
|
|
107
|
+
'Pages in different browser contexts are fully isolated (useful for clean-slate testing of cookies and authentication).'),
|
|
107
108
|
...timeoutSchema,
|
|
108
109
|
},
|
|
109
110
|
blockedByDialog: false,
|
|
110
111
|
verifyFilesSchema: {},
|
|
111
112
|
handler: async (request, response, context) => {
|
|
113
|
+
validateUrl(request.params.url, {
|
|
114
|
+
javascriptEvaluation: args?.javascriptEvaluation,
|
|
115
|
+
categoryExtensions: args?.categoryExtensions,
|
|
116
|
+
});
|
|
112
117
|
const page = await context.newPage(request.params.background, request.params.isolatedContext);
|
|
113
118
|
await page.waitForEventsAfterAction(async () => {
|
|
114
119
|
await page.pptrPage.goto(request.params.url, {
|
|
@@ -120,7 +125,7 @@ export const newPage = defineTool(() => {
|
|
|
120
125
|
},
|
|
121
126
|
};
|
|
122
127
|
});
|
|
123
|
-
export const navigatePage = definePageTool(() => {
|
|
128
|
+
export const navigatePage = definePageTool((args) => {
|
|
124
129
|
return {
|
|
125
130
|
name: 'navigate_page',
|
|
126
131
|
description: `Go to a URL, or back, forward, or reload. Use project URL if not specified otherwise.`,
|
|
@@ -142,10 +147,14 @@ export const navigatePage = definePageTool(() => {
|
|
|
142
147
|
.enum(['accept', 'dismiss'])
|
|
143
148
|
.optional()
|
|
144
149
|
.describe('Whether to auto accept or beforeunload dialogs triggered by this navigation. Default is accept.'),
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
150
|
+
...(args?.javascriptEvaluation !== false
|
|
151
|
+
? {
|
|
152
|
+
initScript: zod
|
|
153
|
+
.string()
|
|
154
|
+
.optional()
|
|
155
|
+
.describe('A JavaScript script to be executed on each new document before any other scripts for the next navigation.'),
|
|
156
|
+
}
|
|
157
|
+
: {}),
|
|
149
158
|
...timeoutSchema,
|
|
150
159
|
},
|
|
151
160
|
blockedByDialog: false,
|
|
@@ -161,6 +170,12 @@ export const navigatePage = definePageTool(() => {
|
|
|
161
170
|
if (!request.params.type) {
|
|
162
171
|
request.params.type = 'url';
|
|
163
172
|
}
|
|
173
|
+
if (request.params.url) {
|
|
174
|
+
validateUrl(request.params.url, {
|
|
175
|
+
javascriptEvaluation: args?.javascriptEvaluation,
|
|
176
|
+
categoryExtensions: args?.categoryExtensions,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
164
179
|
let initScriptId;
|
|
165
180
|
if (request.params.initScript) {
|
|
166
181
|
const { identifier } = await page.pptrPage.evaluateOnNewDocument(request.params.initScript);
|
|
@@ -237,7 +252,7 @@ export const navigatePage = definePageTool(() => {
|
|
|
237
252
|
},
|
|
238
253
|
};
|
|
239
254
|
});
|
|
240
|
-
export const resizePage = definePageTool({
|
|
255
|
+
export const resizePage = definePageTool(() => ({
|
|
241
256
|
name: 'resize_page',
|
|
242
257
|
description: `Resizes the page's window so that the page has specified dimension`,
|
|
243
258
|
annotations: {
|
|
@@ -274,8 +289,8 @@ export const resizePage = definePageTool({
|
|
|
274
289
|
});
|
|
275
290
|
response.setIncludePages(true);
|
|
276
291
|
},
|
|
277
|
-
});
|
|
278
|
-
export const handleDialog = definePageTool({
|
|
292
|
+
}));
|
|
293
|
+
export const handleDialog = definePageTool(() => ({
|
|
279
294
|
name: 'handle_dialog',
|
|
280
295
|
description: `If a browser dialog was opened, use this command to handle it`,
|
|
281
296
|
annotations: {
|
|
@@ -326,8 +341,8 @@ export const handleDialog = definePageTool({
|
|
|
326
341
|
page.clearDialog();
|
|
327
342
|
response.setIncludePages(true);
|
|
328
343
|
},
|
|
329
|
-
});
|
|
330
|
-
export const getTabId = definePageTool({
|
|
344
|
+
}));
|
|
345
|
+
export const getTabId = definePageTool(() => ({
|
|
331
346
|
name: 'get_tab_id',
|
|
332
347
|
description: `Get the tab ID of the page`,
|
|
333
348
|
annotations: {
|
|
@@ -344,5 +359,5 @@ export const getTabId = definePageTool({
|
|
|
344
359
|
response.setTabId(tabId);
|
|
345
360
|
response.appendResponseLine(`Tab ID: ${tabId}`);
|
|
346
361
|
},
|
|
347
|
-
});
|
|
362
|
+
}));
|
|
348
363
|
//# sourceMappingURL=pages.js.map
|
|
@@ -13,7 +13,7 @@ const filePathSchema = zod
|
|
|
13
13
|
.string()
|
|
14
14
|
.optional()
|
|
15
15
|
.describe('The absolute file path, or a file path relative to the current working directory, to save the raw trace data. For example, trace.json.gz (compressed) or trace.json (uncompressed).');
|
|
16
|
-
export const startTrace = definePageTool({
|
|
16
|
+
export const startTrace = definePageTool(() => ({
|
|
17
17
|
name: 'performance_start_trace',
|
|
18
18
|
description: `Start a performance trace on the target webpage. Use to find frontend performance issues, Core Web Vitals (LCP, INP, CLS), and improve page load speed.`,
|
|
19
19
|
annotations: {
|
|
@@ -60,6 +60,7 @@ export const startTrace = definePageTool({
|
|
|
60
60
|
];
|
|
61
61
|
await page.pptrPage.tracing.start({
|
|
62
62
|
categories,
|
|
63
|
+
bufferSize: 1200 * 1000,
|
|
63
64
|
});
|
|
64
65
|
if (request.params.reload) {
|
|
65
66
|
await page.pptrPage.goto(pageUrlForTracing, {
|
|
@@ -93,8 +94,8 @@ export const startTrace = definePageTool({
|
|
|
93
94
|
throw error;
|
|
94
95
|
}
|
|
95
96
|
},
|
|
96
|
-
});
|
|
97
|
-
export const stopTrace = definePageTool({
|
|
97
|
+
}));
|
|
98
|
+
export const stopTrace = definePageTool(() => ({
|
|
98
99
|
name: 'performance_stop_trace',
|
|
99
100
|
description: 'Stop the active performance trace recording on the target webpage.',
|
|
100
101
|
annotations: {
|
|
@@ -115,8 +116,8 @@ export const stopTrace = definePageTool({
|
|
|
115
116
|
const page = request.page;
|
|
116
117
|
await stopTracingAndAppendOutput(page, response, context, request.params.filePath);
|
|
117
118
|
},
|
|
118
|
-
});
|
|
119
|
-
export const analyzeInsight = definePageTool({
|
|
119
|
+
}));
|
|
120
|
+
export const analyzeInsight = definePageTool(() => ({
|
|
120
121
|
name: 'performance_analyze_insight',
|
|
121
122
|
description: 'Provides more detailed information on a specific Performance Insight of an insight set that was highlighted in the results of a trace recording.',
|
|
122
123
|
annotations: {
|
|
@@ -141,7 +142,7 @@ export const analyzeInsight = definePageTool({
|
|
|
141
142
|
}
|
|
142
143
|
response.attachTraceInsight(lastRecording, request.params.insightSetId, request.params.insightName);
|
|
143
144
|
},
|
|
144
|
-
});
|
|
145
|
+
}));
|
|
145
146
|
async function stopTracingAndAppendOutput(page, response, context, filePath) {
|
|
146
147
|
try {
|
|
147
148
|
const traceEventsBuffer = await page.pptrPage.tracing.stop();
|
package/build/src/tools/pwa.js
CHANGED
|
@@ -19,7 +19,7 @@ const displayModeSchema = zod
|
|
|
19
19
|
'tab. Installs via the PWA CDP domain default to "browser" because they ' +
|
|
20
20
|
'do not simulate the install dialog, so pass "standalone" to get an ' +
|
|
21
21
|
'app-window experience.');
|
|
22
|
-
export const installPwa = defineTool({
|
|
22
|
+
export const installPwa = defineTool(() => ({
|
|
23
23
|
name: 'install_pwa',
|
|
24
24
|
description: 'Installs a Progressive Web App (PWA) identified by its manifest ID. ' +
|
|
25
25
|
'This installs through the PWA CDP domain without a user gesture or install ' +
|
|
@@ -58,8 +58,8 @@ export const installPwa = defineTool({
|
|
|
58
58
|
response.appendResponseLine(`Display mode set to: ${displayMode}`);
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
|
-
});
|
|
62
|
-
export const uninstallPwa = defineTool({
|
|
61
|
+
}));
|
|
62
|
+
export const uninstallPwa = defineTool(() => ({
|
|
63
63
|
name: 'uninstall_pwa',
|
|
64
64
|
description: 'Uninstalls a Progressive Web App identified by its manifest ID and ' +
|
|
65
65
|
'closes any open app windows.',
|
|
@@ -78,8 +78,8 @@ export const uninstallPwa = defineTool({
|
|
|
78
78
|
response.appendResponseLine(`Uninstalled PWA with manifest ID: ${manifestId}`);
|
|
79
79
|
response.setIncludePages(true);
|
|
80
80
|
},
|
|
81
|
-
});
|
|
82
|
-
export const launchPwa = defineTool({
|
|
81
|
+
}));
|
|
82
|
+
export const launchPwa = defineTool(() => ({
|
|
83
83
|
name: 'launch_pwa',
|
|
84
84
|
description: 'Launches an installed Progressive Web App using its saved display mode. ' +
|
|
85
85
|
'Optionally opens a specific URL within the same app instead of the default ' +
|
|
@@ -103,8 +103,8 @@ export const launchPwa = defineTool({
|
|
|
103
103
|
response.appendResponseLine(`Launched PWA with manifest ID: ${manifestId} (${page.url()})`);
|
|
104
104
|
response.setIncludePages(true);
|
|
105
105
|
},
|
|
106
|
-
});
|
|
107
|
-
export const getOsAppState = defineTool({
|
|
106
|
+
}));
|
|
107
|
+
export const getOsAppState = defineTool(() => ({
|
|
108
108
|
name: 'get_os_app_state',
|
|
109
109
|
description: 'Returns the OS integration state (badge count and registered file ' +
|
|
110
110
|
'handlers) for an installed web app, identified by its manifest ID.',
|
|
@@ -124,5 +124,5 @@ export const getOsAppState = defineTool({
|
|
|
124
124
|
response.appendResponseLine(`Badge count: ${state.badgeCount}`);
|
|
125
125
|
response.appendResponseLine(`File handlers: ${JSON.stringify(state.fileHandlers)}`);
|
|
126
126
|
},
|
|
127
|
-
});
|
|
127
|
+
}));
|
|
128
128
|
//# sourceMappingURL=pwa.js.map
|
|
@@ -14,7 +14,7 @@ async function generateTempFilePath() {
|
|
|
14
14
|
return path.join(dir, `screencast.mp4`);
|
|
15
15
|
}
|
|
16
16
|
const supportedExtensions = ['.webm', '.mp4'];
|
|
17
|
-
export const startScreencast = definePageTool(args => ({
|
|
17
|
+
export const startScreencast = definePageTool((args) => ({
|
|
18
18
|
name: 'screencast_start',
|
|
19
19
|
description: `Starts recording a screencast (video) of the target page in specified format.`,
|
|
20
20
|
annotations: {
|
|
@@ -62,6 +62,7 @@ export const startScreencast = definePageTool(args => ({
|
|
|
62
62
|
path: resolvedPath,
|
|
63
63
|
format: format,
|
|
64
64
|
ffmpegPath: args?.experimentalFfmpegPath,
|
|
65
|
+
fps: args?.experimentalScreencastFps,
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
catch (err) {
|
|
@@ -86,10 +87,10 @@ export const startScreencast = definePageTool(args => ({
|
|
|
86
87
|
throw err;
|
|
87
88
|
}
|
|
88
89
|
context.setScreenRecorder({ recorder, filePath: resolvedPath });
|
|
89
|
-
response.appendResponseLine(`Screencast recording started. The recording will be saved to ${resolvedPath}. Use ${stopScreencast.name} to stop recording.`);
|
|
90
|
+
response.appendResponseLine(`Screencast recording started. The recording will be saved to ${resolvedPath}. Use ${stopScreencast(args).name} to stop recording.`);
|
|
90
91
|
},
|
|
91
92
|
}));
|
|
92
|
-
export const stopScreencast = definePageTool({
|
|
93
|
+
export const stopScreencast = definePageTool(() => ({
|
|
93
94
|
name: 'screencast_stop',
|
|
94
95
|
description: 'Stops the active screencast recording on the target page.',
|
|
95
96
|
annotations: {
|
|
@@ -114,5 +115,5 @@ export const stopScreencast = definePageTool({
|
|
|
114
115
|
context.setScreenRecorder(null);
|
|
115
116
|
}
|
|
116
117
|
},
|
|
117
|
-
});
|
|
118
|
+
}));
|
|
118
119
|
//# sourceMappingURL=screencast.js.map
|
|
@@ -139,8 +139,8 @@ function computeDownscaleClip(box, maxWidth, maxHeight) {
|
|
|
139
139
|
scale,
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
|
-
export const screenshot = definePageTool(args => {
|
|
143
|
-
const { screenshotFormat, screenshotQuality, screenshotMaxWidth, screenshotMaxHeight, } = args
|
|
142
|
+
export const screenshot = definePageTool((args) => {
|
|
143
|
+
const { screenshotFormat, screenshotQuality, screenshotMaxWidth, screenshotMaxHeight, } = args;
|
|
144
144
|
const defaultFormat = screenshotFormat ?? 'png';
|
|
145
145
|
return {
|
|
146
146
|
name: 'take_screenshot',
|
|
@@ -58,16 +58,17 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
58
58
|
import { zod } from '../third_party/index.js';
|
|
59
59
|
import { ToolCategory } from './categories.js';
|
|
60
60
|
import { defineTool, pageIdSchema } from './ToolDefinition.js';
|
|
61
|
-
export const evaluateScript = defineTool(cliArgs => {
|
|
61
|
+
export const evaluateScript = defineTool((cliArgs) => {
|
|
62
62
|
return {
|
|
63
63
|
name: 'evaluate_script',
|
|
64
|
-
description: `Evaluate a JavaScript function inside the target page${cliArgs
|
|
64
|
+
description: `Evaluate a JavaScript function inside the target page${cliArgs.categoryExtensions ? ' or service worker' : ''}. Returns the response as JSON, so returned values have to be JSON-serializable.`,
|
|
65
65
|
annotations: {
|
|
66
66
|
category: ToolCategory.DEBUGGING,
|
|
67
67
|
readOnlyHint: false,
|
|
68
|
+
conditions: ['javascriptEvaluation'],
|
|
68
69
|
},
|
|
69
70
|
schema: {
|
|
70
|
-
...(cliArgs
|
|
71
|
+
...(cliArgs.pageIdRouting
|
|
71
72
|
? cliArgs.categoryExtensions
|
|
72
73
|
? {
|
|
73
74
|
pageId: zod
|
|
@@ -99,7 +100,7 @@ Example with arguments: \`(el) => el.innerText\`
|
|
|
99
100
|
.boolean()
|
|
100
101
|
.optional()
|
|
101
102
|
.describe('Whether to wait for the DOM to settle. Pass false if the script only reads data. Defaults to true.'),
|
|
102
|
-
...(cliArgs
|
|
103
|
+
...(cliArgs.categoryExtensions
|
|
103
104
|
? {
|
|
104
105
|
serviceWorkerId: zod
|
|
105
106
|
.string()
|
|
@@ -116,7 +117,7 @@ Example with arguments: \`(el) => el.innerText\`
|
|
|
116
117
|
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
117
118
|
try {
|
|
118
119
|
const { serviceWorkerId, args: uidArgs, function: fnString, pageId, dialogAction, filePath, waitForStableDom, } = request.params;
|
|
119
|
-
if (cliArgs
|
|
120
|
+
if (cliArgs.categoryExtensions && serviceWorkerId) {
|
|
120
121
|
if (uidArgs && uidArgs.length > 0) {
|
|
121
122
|
throw new Error('args (element uids) cannot be used when evaluating in a service worker.');
|
|
122
123
|
}
|
|
@@ -140,10 +141,10 @@ Example with arguments: \`(el) => el.innerText\`
|
|
|
140
141
|
response.attachWaitForResult(result);
|
|
141
142
|
return;
|
|
142
143
|
}
|
|
143
|
-
if (cliArgs
|
|
144
|
+
if (cliArgs.categoryExtensions && cliArgs.pageIdRouting && !pageId) {
|
|
144
145
|
throw new Error('specify either a pageId or a serviceWorkerId.');
|
|
145
146
|
}
|
|
146
|
-
const mcpPage = cliArgs
|
|
147
|
+
const mcpPage = cliArgs.pageIdRouting && request.params.pageId
|
|
147
148
|
? context.getPageById(request.params.pageId)
|
|
148
149
|
: context.getSelectedMcpPage();
|
|
149
150
|
const page = mcpPage.pptrPage;
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
import { zod } from '../../third_party/index.js';
|
|
7
7
|
import { ToolCategory } from '../categories.js';
|
|
8
8
|
import { definePageTool } from '../ToolDefinition.js';
|
|
9
|
-
|
|
9
|
+
import { validateUrl } from '../../utils/url.js';
|
|
10
|
+
export const screenshot = definePageTool(() => ({
|
|
10
11
|
name: 'screenshot',
|
|
11
12
|
description: `Takes a screenshot`,
|
|
12
13
|
annotations: {
|
|
@@ -26,48 +27,55 @@ export const screenshot = definePageTool({
|
|
|
26
27
|
const { filepath } = await context.saveTemporaryFile(screenshot, `screenshot.png`);
|
|
27
28
|
response.appendResponseLine(filepath);
|
|
28
29
|
},
|
|
29
|
-
});
|
|
30
|
-
export const navigate = definePageTool({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
30
|
+
}));
|
|
31
|
+
export const navigate = definePageTool((args) => {
|
|
32
|
+
return {
|
|
33
|
+
name: 'navigate',
|
|
34
|
+
description: `Loads a URL`,
|
|
35
|
+
annotations: {
|
|
36
|
+
category: ToolCategory.NAVIGATION,
|
|
37
|
+
readOnlyHint: false,
|
|
38
|
+
},
|
|
39
|
+
schema: {
|
|
40
|
+
url: zod.string().describe('URL to navigate to'),
|
|
41
|
+
},
|
|
42
|
+
blockedByDialog: false,
|
|
43
|
+
verifyFilesSchema: {},
|
|
44
|
+
handler: async (request, response) => {
|
|
45
|
+
validateUrl(request.params.url, {
|
|
46
|
+
javascriptEvaluation: args?.javascriptEvaluation,
|
|
47
|
+
categoryExtensions: args?.categoryExtensions,
|
|
48
|
+
});
|
|
49
|
+
const page = request.page;
|
|
50
|
+
const options = {
|
|
51
|
+
timeout: 30_000,
|
|
52
|
+
};
|
|
53
|
+
const dialogHandler = (dialog) => {
|
|
54
|
+
if (dialog.type() === 'beforeunload') {
|
|
55
|
+
response.appendResponseLine(`Accepted a beforeunload dialog.`);
|
|
56
|
+
void dialog.accept();
|
|
57
|
+
// We are not going to report the dialog like regular dialogs.
|
|
58
|
+
page.clearDialog();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
page.pptrPage.on('dialog', dialogHandler);
|
|
62
|
+
try {
|
|
63
|
+
await page.pptrPage.goto(request.params.url, options);
|
|
64
|
+
response.appendResponseLine(`Navigated to ${page.pptrPage.url()}.`);
|
|
53
65
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
finally {
|
|
61
|
-
page.pptrPage.off('dialog', dialogHandler);
|
|
62
|
-
}
|
|
63
|
-
},
|
|
66
|
+
finally {
|
|
67
|
+
page.pptrPage.off('dialog', dialogHandler);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
};
|
|
64
71
|
});
|
|
65
|
-
export const evaluate = definePageTool({
|
|
72
|
+
export const evaluate = definePageTool(() => ({
|
|
66
73
|
name: 'evaluate',
|
|
67
74
|
description: `Evaluates a JavaScript script`,
|
|
68
75
|
annotations: {
|
|
69
76
|
category: ToolCategory.DEBUGGING,
|
|
70
77
|
readOnlyHint: false,
|
|
78
|
+
conditions: ['javascriptEvaluation'],
|
|
71
79
|
},
|
|
72
80
|
schema: {
|
|
73
81
|
script: zod.string().describe(`JS script to run on the page`),
|
|
@@ -84,5 +92,5 @@ export const evaluate = definePageTool({
|
|
|
84
92
|
response.appendResponseLine(String(err.message));
|
|
85
93
|
}
|
|
86
94
|
},
|
|
87
|
-
});
|
|
95
|
+
}));
|
|
88
96
|
//# sourceMappingURL=tools.js.map
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { zod } from '../third_party/index.js';
|
|
7
7
|
import { ToolCategory } from './categories.js';
|
|
8
8
|
import { definePageTool, timeoutSchema } from './ToolDefinition.js';
|
|
9
|
-
export const takeSnapshot = definePageTool({
|
|
9
|
+
export const takeSnapshot = definePageTool(() => ({
|
|
10
10
|
name: 'take_snapshot',
|
|
11
11
|
description: `Take a text snapshot of the target page based on the a11y tree. The snapshot lists page elements along with a unique
|
|
12
12
|
identifier (uid). Always use the latest snapshot. Prefer taking a snapshot over taking a screenshot. The snapshot indicates the element selected
|
|
@@ -36,8 +36,8 @@ in the DevTools Elements panel (if any).`,
|
|
|
36
36
|
filePath: request.params.filePath,
|
|
37
37
|
});
|
|
38
38
|
},
|
|
39
|
-
});
|
|
40
|
-
export const waitFor = definePageTool({
|
|
39
|
+
}));
|
|
40
|
+
export const waitFor = definePageTool(() => ({
|
|
41
41
|
name: 'wait_for',
|
|
42
42
|
description: `Wait for the specified text to appear on the selected page.`,
|
|
43
43
|
annotations: {
|
|
@@ -59,5 +59,5 @@ export const waitFor = definePageTool({
|
|
|
59
59
|
response.appendResponseLine(`Element matching one of ${JSON.stringify(request.params.text)} found.`);
|
|
60
60
|
response.includeSnapshot();
|
|
61
61
|
},
|
|
62
|
-
});
|
|
62
|
+
}));
|
|
63
63
|
//# sourceMappingURL=snapshot.js.map
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { zod, ajv } from '../third_party/index.js';
|
|
7
7
|
import { ToolCategory } from './categories.js';
|
|
8
8
|
import { definePageTool } from './ToolDefinition.js';
|
|
9
|
-
export const listThirdPartyDeveloperTools = definePageTool({
|
|
9
|
+
export const listThirdPartyDeveloperTools = definePageTool(() => ({
|
|
10
10
|
name: 'list_3p_developer_tools',
|
|
11
11
|
description: `Lists all third-party developer tools the page exposes for providing runtime information.
|
|
12
12
|
Third-party developer tools can be called via the 'execute_3p_developer_tool()' MCP tool.
|
|
@@ -25,8 +25,8 @@ third-party developer tools with additional functionality.`,
|
|
|
25
25
|
handler: async (_request, response) => {
|
|
26
26
|
response.setListThirdPartyDeveloperTools();
|
|
27
27
|
},
|
|
28
|
-
});
|
|
29
|
-
export const executeThirdPartyDeveloperTool = definePageTool({
|
|
28
|
+
}));
|
|
29
|
+
export const executeThirdPartyDeveloperTool = definePageTool(() => ({
|
|
30
30
|
name: 'execute_3p_developer_tool',
|
|
31
31
|
description: `Executes a tool exposed by the page.`,
|
|
32
32
|
annotations: {
|
|
@@ -81,5 +81,5 @@ export const executeThirdPartyDeveloperTool = definePageTool({
|
|
|
81
81
|
}
|
|
82
82
|
await request.page.executeThirdPartyDeveloperTool(toolName, params, response);
|
|
83
83
|
},
|
|
84
|
-
});
|
|
84
|
+
}));
|
|
85
85
|
//# sourceMappingURL=thirdPartyDeveloper.js.map
|
package/build/src/tools/tools.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import * as commentsTools from './comments.js';
|
|
6
7
|
import * as consoleTools from './console.js';
|
|
8
|
+
import * as cssTools from './css.js';
|
|
7
9
|
import * as emulationTools from './emulation.js';
|
|
8
10
|
import * as extensionTools from './extensions.js';
|
|
9
11
|
import * as inputTools from './input.js';
|
|
@@ -24,7 +26,9 @@ export const createTools = (args) => {
|
|
|
24
26
|
const rawTools = args.slim
|
|
25
27
|
? Object.values(slimTools)
|
|
26
28
|
: [
|
|
29
|
+
...(args.devtoolsComments ? Object.values(commentsTools) : []),
|
|
27
30
|
...Object.values(consoleTools),
|
|
31
|
+
...Object.values(cssTools),
|
|
28
32
|
...Object.values(emulationTools),
|
|
29
33
|
...Object.values(extensionTools),
|
|
30
34
|
...Object.values(inputTools),
|
|
@@ -43,16 +47,9 @@ export const createTools = (args) => {
|
|
|
43
47
|
];
|
|
44
48
|
const tools = [];
|
|
45
49
|
for (const tool of rawTools) {
|
|
46
|
-
|
|
47
|
-
tools.push(tool(args));
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
tools.push(tool);
|
|
51
|
-
}
|
|
50
|
+
tools.push(tool(args));
|
|
52
51
|
}
|
|
53
|
-
tools.sort((a, b) =>
|
|
54
|
-
return a.name.localeCompare(b.name);
|
|
55
|
-
});
|
|
52
|
+
tools.sort((a, b) => a.name.localeCompare(b.name));
|
|
56
53
|
return tools;
|
|
57
54
|
};
|
|
58
55
|
//# sourceMappingURL=tools.js.map
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { zod } from '../third_party/index.js';
|
|
7
7
|
import { ToolCategory } from './categories.js';
|
|
8
8
|
import { definePageTool } from './ToolDefinition.js';
|
|
9
|
-
export const listWebMcpTools = definePageTool({
|
|
9
|
+
export const listWebMcpTools = definePageTool(() => ({
|
|
10
10
|
name: 'list_webmcp_tools',
|
|
11
11
|
description: `Lists all WebMCP tools the page exposes.`,
|
|
12
12
|
annotations: {
|
|
@@ -19,8 +19,8 @@ export const listWebMcpTools = definePageTool({
|
|
|
19
19
|
handler: async (_request, response) => {
|
|
20
20
|
response.setListWebMcpTools();
|
|
21
21
|
},
|
|
22
|
-
});
|
|
23
|
-
export const executeWebMcpTool = definePageTool({
|
|
22
|
+
}));
|
|
23
|
+
export const executeWebMcpTool = definePageTool(() => ({
|
|
24
24
|
name: 'execute_webmcp_tool',
|
|
25
25
|
description: `Executes a WebMCP tool exposed by the page.`,
|
|
26
26
|
annotations: {
|
|
@@ -62,5 +62,5 @@ export const executeWebMcpTool = definePageTool({
|
|
|
62
62
|
const { status, output, errorText } = await tool.execute(input);
|
|
63
63
|
response.appendResponseLine(JSON.stringify({ status, output, errorText }, null, 2));
|
|
64
64
|
},
|
|
65
|
-
});
|
|
65
|
+
}));
|
|
66
66
|
//# sourceMappingURL=webmcp.js.map
|
package/build/src/types.js
CHANGED
|
@@ -3,5 +3,8 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export var CD4ABridgeEvents;
|
|
7
|
+
(function (CD4ABridgeEvents) {
|
|
8
|
+
CD4ABridgeEvents["COMMENT_THREADS_CHANGED"] = "CommentThreadsChanged";
|
|
9
|
+
})(CD4ABridgeEvents || (CD4ABridgeEvents = {}));
|
|
7
10
|
//# sourceMappingURL=types.js.map
|