@mcp-b/chrome-devtools-mcp 2.3.0 → 2.3.1-beta.20260528050333
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/package.json +1 -1
- package/build/src/DevToolsConnectionAdapter.js +0 -70
- package/build/src/DevtoolsUtils.js +0 -290
- package/build/src/McpContext.js +0 -687
- package/build/src/McpPage.js +0 -95
- package/build/src/McpResponse.js +0 -588
- package/build/src/Mutex.js +0 -37
- package/build/src/PageCollector.js +0 -308
- package/build/src/SlimMcpResponse.js +0 -18
- package/build/src/WaitForHelper.js +0 -135
- package/build/src/bin/chrome-devtools-cli-options.js +0 -651
- package/build/src/bin/chrome-devtools-mcp-cli-options.js +0 -317
- package/build/src/bin/chrome-devtools-mcp-main.js +0 -35
- package/build/src/bin/chrome-devtools-mcp.js +0 -21
- package/build/src/bin/chrome-devtools.js +0 -185
- package/build/src/bin/cliDefinitions.js +0 -615
- package/build/src/browser.js +0 -198
- package/build/src/daemon/client.js +0 -152
- package/build/src/daemon/daemon.js +0 -206
- package/build/src/daemon/types.js +0 -6
- package/build/src/daemon/utils.js +0 -108
- package/build/src/formatters/ConsoleFormatter.js +0 -234
- package/build/src/formatters/IssueFormatter.js +0 -192
- package/build/src/formatters/NetworkFormatter.js +0 -215
- package/build/src/formatters/SnapshotFormatter.js +0 -131
- package/build/src/index.js +0 -202
- package/build/src/issue-descriptions.js +0 -39
- package/build/src/logger.js +0 -36
- package/build/src/polyfill.js +0 -7
- package/build/src/telemetry/ClearcutLogger.js +0 -102
- package/build/src/telemetry/WatchdogClient.js +0 -60
- package/build/src/telemetry/flagUtils.js +0 -45
- package/build/src/telemetry/metricUtils.js +0 -14
- package/build/src/telemetry/persistence.js +0 -53
- package/build/src/telemetry/types.js +0 -33
- package/build/src/telemetry/watchdog/ClearcutSender.js +0 -203
- package/build/src/telemetry/watchdog/main.js +0 -127
- package/build/src/third_party/devtools-formatter-worker.js +0 -7
- package/build/src/third_party/index.js +0 -26
- package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +0 -54183
- package/build/src/tools/ToolDefinition.js +0 -72
- package/build/src/tools/categories.js +0 -24
- package/build/src/tools/console.js +0 -85
- package/build/src/tools/emulation.js +0 -55
- package/build/src/tools/extensions.js +0 -96
- package/build/src/tools/input.js +0 -368
- package/build/src/tools/lighthouse.js +0 -123
- package/build/src/tools/memory.js +0 -28
- package/build/src/tools/network.js +0 -120
- package/build/src/tools/pages.js +0 -319
- package/build/src/tools/performance.js +0 -190
- package/build/src/tools/screencast.js +0 -79
- package/build/src/tools/screenshot.js +0 -84
- package/build/src/tools/script.js +0 -119
- package/build/src/tools/slim/tools.js +0 -81
- package/build/src/tools/snapshot.js +0 -56
- package/build/src/tools/tools.js +0 -52
- package/build/src/tools/webmcp.js +0 -416
- package/build/src/trace-processing/parse.js +0 -84
- package/build/src/types.js +0 -6
- package/build/src/utils/ExtensionRegistry.js +0 -35
- package/build/src/utils/files.js +0 -19
- package/build/src/utils/keyboard.js +0 -296
- package/build/src/utils/pagination.js +0 -49
- package/build/src/utils/string.js +0 -36
- package/build/src/utils/types.js +0 -6
- package/build/src/version.js +0 -9
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { zod } from '../third_party/index.js';
|
|
7
|
-
import { ToolCategory } from './categories.js';
|
|
8
|
-
import { defineTool, pageIdSchema } from './ToolDefinition.js';
|
|
9
|
-
export const evaluateScript = defineTool((cliArgs) => {
|
|
10
|
-
return {
|
|
11
|
-
name: 'evaluate_script',
|
|
12
|
-
description: `Evaluate a JavaScript function inside the currently selected page. Returns the response as JSON,
|
|
13
|
-
so returned values have to be JSON-serializable.`,
|
|
14
|
-
annotations: {
|
|
15
|
-
category: ToolCategory.DEBUGGING,
|
|
16
|
-
readOnlyHint: false,
|
|
17
|
-
},
|
|
18
|
-
schema: {
|
|
19
|
-
function: zod.string().describe(`A JavaScript function declaration to be executed by the tool in the currently selected page.
|
|
20
|
-
Example without arguments: \`() => {
|
|
21
|
-
return document.title
|
|
22
|
-
}\` or \`async () => {
|
|
23
|
-
return await fetch("example.com")
|
|
24
|
-
}\`.
|
|
25
|
-
Example with arguments: \`(el) => {
|
|
26
|
-
return el.innerText;
|
|
27
|
-
}\`
|
|
28
|
-
`),
|
|
29
|
-
args: zod
|
|
30
|
-
.array(zod.string().describe('The uid of an element on the page from the page content snapshot'))
|
|
31
|
-
.optional()
|
|
32
|
-
.describe(`An optional list of arguments to pass to the function.`),
|
|
33
|
-
...(cliArgs?.experimentalPageIdRouting ? pageIdSchema : {}),
|
|
34
|
-
...(cliArgs?.categoryExtensions
|
|
35
|
-
? {
|
|
36
|
-
serviceWorkerId: zod
|
|
37
|
-
.string()
|
|
38
|
-
.optional()
|
|
39
|
-
.describe(`An optional service worker id to evaluate the script in.`),
|
|
40
|
-
}
|
|
41
|
-
: {}),
|
|
42
|
-
},
|
|
43
|
-
handler: async (request, response, context) => {
|
|
44
|
-
const { serviceWorkerId, args: uidArgs, function: fnString, pageId } = request.params;
|
|
45
|
-
if (cliArgs?.categoryExtensions && serviceWorkerId) {
|
|
46
|
-
if (uidArgs && uidArgs.length > 0) {
|
|
47
|
-
throw new Error('args (element uids) cannot be used when evaluating in a service worker.');
|
|
48
|
-
}
|
|
49
|
-
if (pageId) {
|
|
50
|
-
throw new Error('specify either a pageId or a serviceWorkerId.');
|
|
51
|
-
}
|
|
52
|
-
const worker = await getWebWorker(context, serviceWorkerId);
|
|
53
|
-
await performEvaluation(worker, fnString, [], response, context);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const mcpPage = cliArgs?.experimentalPageIdRouting
|
|
57
|
-
? context.getPageById(request.params.pageId)
|
|
58
|
-
: context.getSelectedMcpPage();
|
|
59
|
-
const page = mcpPage.pptrPage;
|
|
60
|
-
const args = [];
|
|
61
|
-
try {
|
|
62
|
-
const frames = new Set();
|
|
63
|
-
for (const uid of uidArgs ?? []) {
|
|
64
|
-
const handle = await mcpPage.getElementByUid(uid);
|
|
65
|
-
frames.add(handle.frame);
|
|
66
|
-
args.push(handle);
|
|
67
|
-
}
|
|
68
|
-
const evaluatable = await getPageOrFrame(page, frames);
|
|
69
|
-
await performEvaluation(evaluatable, fnString, args, response, context);
|
|
70
|
-
}
|
|
71
|
-
finally {
|
|
72
|
-
void Promise.allSettled(args.map((arg) => arg.dispose()));
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
|
-
const performEvaluation = async (evaluatable, fnString, args, response, context) => {
|
|
78
|
-
const fn = await evaluatable.evaluateHandle(`(${fnString})`);
|
|
79
|
-
try {
|
|
80
|
-
await context.waitForEventsAfterAction(async () => {
|
|
81
|
-
const result = await evaluatable.evaluate(async (fn, ...args) => {
|
|
82
|
-
// @ts-expect-error no types for function fn
|
|
83
|
-
return JSON.stringify(await fn(...args));
|
|
84
|
-
}, fn, ...args);
|
|
85
|
-
response.appendResponseLine('Script ran on page and returned:');
|
|
86
|
-
response.appendResponseLine('```json');
|
|
87
|
-
response.appendResponseLine(`${result}`);
|
|
88
|
-
response.appendResponseLine('```');
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
finally {
|
|
92
|
-
void fn.dispose();
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
const getPageOrFrame = async (page, frames) => {
|
|
96
|
-
let pageOrFrame;
|
|
97
|
-
// We can't evaluate the element handle across frames
|
|
98
|
-
if (frames.size > 1) {
|
|
99
|
-
throw new Error("Elements from different frames can't be evaluated together.");
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
pageOrFrame = [...frames.values()][0] ?? page;
|
|
103
|
-
}
|
|
104
|
-
return pageOrFrame;
|
|
105
|
-
};
|
|
106
|
-
const getWebWorker = async (context, serviceWorkerId) => {
|
|
107
|
-
const serviceWorkers = context.getExtensionServiceWorkers();
|
|
108
|
-
const serviceWorker = serviceWorkers.find((sw) => context.getExtensionServiceWorkerId(sw) === serviceWorkerId);
|
|
109
|
-
if (serviceWorker && serviceWorker.target) {
|
|
110
|
-
const worker = await serviceWorker.target.worker();
|
|
111
|
-
if (!worker) {
|
|
112
|
-
throw new Error('Service worker target not found.');
|
|
113
|
-
}
|
|
114
|
-
return worker;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
throw new Error('Service worker not found.');
|
|
118
|
-
}
|
|
119
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2026 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { zod } from '../../third_party/index.js';
|
|
7
|
-
import { ToolCategory } from '../categories.js';
|
|
8
|
-
import { definePageTool } from '../ToolDefinition.js';
|
|
9
|
-
export const screenshot = definePageTool({
|
|
10
|
-
name: 'screenshot',
|
|
11
|
-
description: `Takes a screenshot`,
|
|
12
|
-
annotations: {
|
|
13
|
-
category: ToolCategory.DEBUGGING,
|
|
14
|
-
// Not read-only due to filePath param.
|
|
15
|
-
readOnlyHint: false,
|
|
16
|
-
},
|
|
17
|
-
schema: {},
|
|
18
|
-
handler: async (request, response, context) => {
|
|
19
|
-
const page = request.page;
|
|
20
|
-
const screenshot = await page.pptrPage.screenshot({
|
|
21
|
-
type: 'png',
|
|
22
|
-
optimizeForSpeed: true,
|
|
23
|
-
});
|
|
24
|
-
const { filepath } = await context.saveTemporaryFile(screenshot, `screenshot.png`);
|
|
25
|
-
response.appendResponseLine(filepath);
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
export const navigate = definePageTool({
|
|
29
|
-
name: 'navigate',
|
|
30
|
-
description: `Loads a URL`,
|
|
31
|
-
annotations: {
|
|
32
|
-
category: ToolCategory.NAVIGATION,
|
|
33
|
-
readOnlyHint: false,
|
|
34
|
-
},
|
|
35
|
-
schema: {
|
|
36
|
-
url: zod.string().describe('URL to navigate to'),
|
|
37
|
-
},
|
|
38
|
-
handler: async (request, response) => {
|
|
39
|
-
const page = request.page;
|
|
40
|
-
const options = {
|
|
41
|
-
timeout: 30_000,
|
|
42
|
-
};
|
|
43
|
-
const dialogHandler = (dialog) => {
|
|
44
|
-
if (dialog.type() === 'beforeunload') {
|
|
45
|
-
response.appendResponseLine(`Accepted a beforeunload dialog.`);
|
|
46
|
-
void dialog.accept();
|
|
47
|
-
// We are not going to report the dialog like regular dialogs.
|
|
48
|
-
page.clearDialog();
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
page.pptrPage.on('dialog', dialogHandler);
|
|
52
|
-
try {
|
|
53
|
-
await page.pptrPage.goto(request.params.url, options);
|
|
54
|
-
response.appendResponseLine(`Navigated to ${page.pptrPage.url()}.`);
|
|
55
|
-
}
|
|
56
|
-
finally {
|
|
57
|
-
page.pptrPage.off('dialog', dialogHandler);
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
export const evaluate = definePageTool({
|
|
62
|
-
name: 'evaluate',
|
|
63
|
-
description: `Evaluates a JavaScript script`,
|
|
64
|
-
annotations: {
|
|
65
|
-
category: ToolCategory.DEBUGGING,
|
|
66
|
-
readOnlyHint: false,
|
|
67
|
-
},
|
|
68
|
-
schema: {
|
|
69
|
-
script: zod.string().describe(`JS script to run on the page`),
|
|
70
|
-
},
|
|
71
|
-
handler: async (request, response) => {
|
|
72
|
-
const page = request.page;
|
|
73
|
-
try {
|
|
74
|
-
const result = await page.pptrPage.evaluate(request.params.script);
|
|
75
|
-
response.appendResponseLine(JSON.stringify(result));
|
|
76
|
-
}
|
|
77
|
-
catch (err) {
|
|
78
|
-
response.appendResponseLine(String(err.message));
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { zod } from '../third_party/index.js';
|
|
7
|
-
import { ToolCategory } from './categories.js';
|
|
8
|
-
import { definePageTool, timeoutSchema } from './ToolDefinition.js';
|
|
9
|
-
export const takeSnapshot = definePageTool({
|
|
10
|
-
name: 'take_snapshot',
|
|
11
|
-
description: `Take a text snapshot of the currently selected page based on the a11y tree. The snapshot lists page elements along with a unique
|
|
12
|
-
identifier (uid). Always use the latest snapshot. Prefer taking a snapshot over taking a screenshot. The snapshot indicates the element selected
|
|
13
|
-
in the DevTools Elements panel (if any).`,
|
|
14
|
-
annotations: {
|
|
15
|
-
category: ToolCategory.DEBUGGING,
|
|
16
|
-
// Not read-only due to filePath param.
|
|
17
|
-
readOnlyHint: false,
|
|
18
|
-
},
|
|
19
|
-
schema: {
|
|
20
|
-
verbose: zod
|
|
21
|
-
.boolean()
|
|
22
|
-
.optional()
|
|
23
|
-
.describe('Whether to include all possible information available in the full a11y tree. Default is false.'),
|
|
24
|
-
filePath: zod
|
|
25
|
-
.string()
|
|
26
|
-
.optional()
|
|
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
|
-
},
|
|
29
|
-
handler: async (request, response) => {
|
|
30
|
-
response.includeSnapshot({
|
|
31
|
-
verbose: request.params.verbose ?? false,
|
|
32
|
-
filePath: request.params.filePath,
|
|
33
|
-
});
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
export const waitFor = definePageTool({
|
|
37
|
-
name: 'wait_for',
|
|
38
|
-
description: `Wait for the specified text to appear on the selected page.`,
|
|
39
|
-
annotations: {
|
|
40
|
-
category: ToolCategory.NAVIGATION,
|
|
41
|
-
readOnlyHint: true,
|
|
42
|
-
},
|
|
43
|
-
schema: {
|
|
44
|
-
text: zod
|
|
45
|
-
.array(zod.string())
|
|
46
|
-
.min(1)
|
|
47
|
-
.describe('Non-empty list of texts. Resolves when any value appears on the page.'),
|
|
48
|
-
...timeoutSchema,
|
|
49
|
-
},
|
|
50
|
-
handler: async (request, response, context) => {
|
|
51
|
-
const page = request.page;
|
|
52
|
-
await context.waitForTextOnPage(request.params.text, request.params.timeout, page.pptrPage);
|
|
53
|
-
response.appendResponseLine(`Element matching one of ${JSON.stringify(request.params.text)} found.`);
|
|
54
|
-
response.includeSnapshot();
|
|
55
|
-
},
|
|
56
|
-
});
|
package/build/src/tools/tools.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import * as consoleTools from './console.js';
|
|
7
|
-
import * as emulationTools from './emulation.js';
|
|
8
|
-
import * as extensionTools from './extensions.js';
|
|
9
|
-
import * as inputTools from './input.js';
|
|
10
|
-
import * as lighthouseTools from './lighthouse.js';
|
|
11
|
-
import * as memoryTools from './memory.js';
|
|
12
|
-
import * as networkTools from './network.js';
|
|
13
|
-
import * as pagesTools from './pages.js';
|
|
14
|
-
import * as performanceTools from './performance.js';
|
|
15
|
-
import * as screencastTools from './screencast.js';
|
|
16
|
-
import * as screenshotTools from './screenshot.js';
|
|
17
|
-
import * as scriptTools from './script.js';
|
|
18
|
-
import * as slimTools from './slim/tools.js';
|
|
19
|
-
import * as snapshotTools from './snapshot.js';
|
|
20
|
-
export const createTools = (args) => {
|
|
21
|
-
const rawTools = args.slim
|
|
22
|
-
? Object.values(slimTools)
|
|
23
|
-
: [
|
|
24
|
-
...Object.values(consoleTools),
|
|
25
|
-
...Object.values(emulationTools),
|
|
26
|
-
...Object.values(extensionTools),
|
|
27
|
-
...Object.values(inputTools),
|
|
28
|
-
...Object.values(lighthouseTools),
|
|
29
|
-
...Object.values(memoryTools),
|
|
30
|
-
...Object.values(networkTools),
|
|
31
|
-
...Object.values(pagesTools),
|
|
32
|
-
...Object.values(performanceTools),
|
|
33
|
-
...Object.values(screencastTools),
|
|
34
|
-
...Object.values(screenshotTools),
|
|
35
|
-
...Object.values(scriptTools),
|
|
36
|
-
...Object.values(snapshotTools),
|
|
37
|
-
...Object.values(webmcpTools),
|
|
38
|
-
];
|
|
39
|
-
const tools = [];
|
|
40
|
-
for (const tool of rawTools) {
|
|
41
|
-
if (typeof tool === 'function') {
|
|
42
|
-
tools.push(tool(args));
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
tools.push(tool);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
tools.sort((a, b) => {
|
|
49
|
-
return a.name.localeCompare(b.name);
|
|
50
|
-
});
|
|
51
|
-
return tools;
|
|
52
|
-
};
|