chrome-devtools-mcp 0.4.0 → 0.5.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 +18 -1
- package/build/src/McpContext.js +2 -1
- package/build/src/McpResponse.js +2 -1
- package/build/src/index.js +6 -2
- package/build/src/main.js +1 -0
- package/build/src/polyfill.js +7 -0
- package/build/src/tools/pages.js +15 -2
- package/build/src/tools/screenshot.js +8 -0
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ MCP clients.
|
|
|
27
27
|
|
|
28
28
|
## Requirements
|
|
29
29
|
|
|
30
|
-
- [Node.js
|
|
30
|
+
- [Node.js 20](https://nodejs.org/) or a newer [latest maintainance LTS](https://github.com/nodejs/Release#release-schedule) version.
|
|
31
31
|
- [Chrome](https://www.google.com/chrome/) current stable version or newer.
|
|
32
32
|
- [npm](https://www.npmjs.com/).
|
|
33
33
|
|
|
@@ -75,6 +75,23 @@ claude mcp add chrome-devtools npx chrome-devtools-mcp@latest
|
|
|
75
75
|
codex mcp add chrome-devtools -- npx chrome-devtools-mcp@latest
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
**On Windows 11**
|
|
79
|
+
|
|
80
|
+
Configure the Chrome install location and increase the startup timeout by updating `.codex/config.toml` and adding the following `env` and `startup_timeout_ms` parameters:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
[mcp_servers.chrome-devtools]
|
|
84
|
+
command = "cmd"
|
|
85
|
+
args = [
|
|
86
|
+
"/c",
|
|
87
|
+
"npx",
|
|
88
|
+
"-y",
|
|
89
|
+
"chrome-devtools-mcp@latest",
|
|
90
|
+
]
|
|
91
|
+
env = { SystemRoot="C:\\Windows", PROGRAMFILES="C:\\Program Files" }
|
|
92
|
+
startup_timeout_ms = 20_000
|
|
93
|
+
```
|
|
94
|
+
|
|
78
95
|
</details>
|
|
79
96
|
|
|
80
97
|
<details>
|
package/build/src/McpContext.js
CHANGED
|
@@ -8,6 +8,7 @@ import os from 'node:os';
|
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { NetworkCollector, PageCollector } from './PageCollector.js';
|
|
10
10
|
import { listPages } from './tools/pages.js';
|
|
11
|
+
import { takeSnapshot } from './tools/snapshot.js';
|
|
11
12
|
import { CLOSE_PAGE_ERROR } from './tools/ToolDefinition.js';
|
|
12
13
|
import { WaitForHelper } from './WaitForHelper.js';
|
|
13
14
|
const DEFAULT_TIMEOUT = 5_000;
|
|
@@ -191,7 +192,7 @@ export class McpContext {
|
|
|
191
192
|
}
|
|
192
193
|
async getElementByUid(uid) {
|
|
193
194
|
if (!this.#textSnapshot?.idToNode.size) {
|
|
194
|
-
throw new Error(
|
|
195
|
+
throw new Error(`No snapshot found. Use ${takeSnapshot.name} to capture one.`);
|
|
195
196
|
}
|
|
196
197
|
const [snapshotId] = uid.split('_');
|
|
197
198
|
if (this.#textSnapshot.snapshotId !== snapshotId) {
|
package/build/src/McpResponse.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { formatConsoleEvent } from './formatters/consoleFormatter.js';
|
|
2
2
|
import { getFormattedHeaderValue, getShortDescriptionForRequest, getStatusFromRequest, } from './formatters/networkFormatter.js';
|
|
3
3
|
import { formatA11ySnapshot } from './formatters/snapshotFormatter.js';
|
|
4
|
+
import { handleDialog } from './tools/pages.js';
|
|
4
5
|
import { paginate } from './utils/pagination.js';
|
|
5
6
|
export class McpResponse {
|
|
6
7
|
#includePages = false;
|
|
@@ -106,7 +107,7 @@ export class McpResponse {
|
|
|
106
107
|
if (dialog) {
|
|
107
108
|
response.push(`# Open dialog
|
|
108
109
|
${dialog.type()}: ${dialog.message()} (default value: ${dialog.message()}).
|
|
109
|
-
Call
|
|
110
|
+
Call ${handleDialog.name} to handle it before continuing.`);
|
|
110
111
|
}
|
|
111
112
|
if (this.#includePages) {
|
|
112
113
|
const parts = [`## Pages`];
|
package/build/src/index.js
CHANGED
|
@@ -6,8 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { version } from 'node:process';
|
|
8
8
|
const [major, minor] = version.substring(1).split('.').map(Number);
|
|
9
|
-
if (major
|
|
10
|
-
console.error(`ERROR: \`chrome-devtools-mcp\` does not support Node ${process.version}. Please upgrade to Node 22.12.0 or newer.`);
|
|
9
|
+
if (major === 22 && minor < 12) {
|
|
10
|
+
console.error(`ERROR: \`chrome-devtools-mcp\` does not support Node ${process.version}. Please upgrade to Node 22.12.0 LTS or a newer LTS.`);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
if (major < 20) {
|
|
14
|
+
console.error(`ERROR: \`chrome-devtools-mcp\` does not support Node ${process.version}. Please upgrade to Node 20 LTS or a newer LTS.`);
|
|
11
15
|
process.exit(1);
|
|
12
16
|
}
|
|
13
17
|
await import('./main.js');
|
package/build/src/main.js
CHANGED
package/build/src/tools/pages.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import z from 'zod';
|
|
7
|
+
import { logger } from '../logger.js';
|
|
7
8
|
import { ToolCategories } from './categories.js';
|
|
8
9
|
import { CLOSE_PAGE_ERROR, defineTool } from './ToolDefinition.js';
|
|
9
10
|
export const listPages = defineTool({
|
|
@@ -172,12 +173,24 @@ export const handleDialog = defineTool({
|
|
|
172
173
|
}
|
|
173
174
|
switch (request.params.action) {
|
|
174
175
|
case 'accept': {
|
|
175
|
-
|
|
176
|
+
try {
|
|
177
|
+
await dialog.accept(request.params.promptText);
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
// Likely already handled by the user outside of MCP.
|
|
181
|
+
logger(err);
|
|
182
|
+
}
|
|
176
183
|
response.appendResponseLine('Successfully accepted the dialog');
|
|
177
184
|
break;
|
|
178
185
|
}
|
|
179
186
|
case 'dismiss': {
|
|
180
|
-
|
|
187
|
+
try {
|
|
188
|
+
await dialog.dismiss();
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
// Likely already handled.
|
|
192
|
+
logger(err);
|
|
193
|
+
}
|
|
181
194
|
response.appendResponseLine('Successfully dismissed the dialog');
|
|
182
195
|
break;
|
|
183
196
|
}
|
|
@@ -18,6 +18,12 @@ export const screenshot = defineTool({
|
|
|
18
18
|
.enum(['png', 'jpeg'])
|
|
19
19
|
.default('png')
|
|
20
20
|
.describe('Type of format to save the screenshot as. Default is "png"'),
|
|
21
|
+
quality: z
|
|
22
|
+
.number()
|
|
23
|
+
.min(0)
|
|
24
|
+
.max(100)
|
|
25
|
+
.optional()
|
|
26
|
+
.describe('Compression quality for JPEG format (0-100). Higher values mean better quality but larger file sizes. Ignored for PNG format.'),
|
|
21
27
|
uid: z
|
|
22
28
|
.string()
|
|
23
29
|
.optional()
|
|
@@ -41,6 +47,8 @@ export const screenshot = defineTool({
|
|
|
41
47
|
const screenshot = await pageOrHandle.screenshot({
|
|
42
48
|
type: request.params.format,
|
|
43
49
|
fullPage: request.params.fullPage,
|
|
50
|
+
quality: request.params.quality,
|
|
51
|
+
optimizeForSpeed: true, // Bonus: optimize encoding for speed
|
|
44
52
|
});
|
|
45
53
|
if (request.params.uid) {
|
|
46
54
|
response.appendResponseLine(`Took a screenshot of node with uid "${request.params.uid}".`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chrome-devtools-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "MCP server for Chrome DevTools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "./build/src/index.js",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"docs:generate": "node --experimental-strip-types scripts/generate-docs.ts",
|
|
15
15
|
"start": "npm run build && node build/src/index.js",
|
|
16
16
|
"start-debug": "DEBUG=mcp:* DEBUG_COLORS=false npm run build && node build/src/index.js",
|
|
17
|
+
"test:node20": "node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test build/tests",
|
|
17
18
|
"test": "npm run build && node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test \"build/tests/**/*.test.js\"",
|
|
18
19
|
"test:only": "npm run build && node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
|
|
19
20
|
"test:only:no-build": "node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
|
|
@@ -36,7 +37,8 @@
|
|
|
36
37
|
"homepage": "https://github.com/ChromeDevTools/chrome-devtools-mcp#readme",
|
|
37
38
|
"mcpName": "io.github.ChromeDevTools/chrome-devtools-mcp",
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@modelcontextprotocol/sdk": "1.18.
|
|
40
|
+
"@modelcontextprotocol/sdk": "1.18.2",
|
|
41
|
+
"core-js": "3.45.1",
|
|
40
42
|
"debug": "4.4.3",
|
|
41
43
|
"puppeteer-core": "24.22.3",
|
|
42
44
|
"yargs": "18.0.0"
|
|
@@ -53,14 +55,14 @@
|
|
|
53
55
|
"@typescript-eslint/parser": "^8.43.0",
|
|
54
56
|
"chrome-devtools-frontend": "1.0.1520535",
|
|
55
57
|
"eslint": "^9.35.0",
|
|
56
|
-
"eslint-plugin-import": "^2.32.0",
|
|
57
58
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
59
|
+
"eslint-plugin-import": "^2.32.0",
|
|
58
60
|
"globals": "^16.4.0",
|
|
59
61
|
"prettier": "^3.6.2",
|
|
60
62
|
"puppeteer": "24.22.3",
|
|
61
63
|
"sinon": "^21.0.0",
|
|
62
|
-
"typescript
|
|
63
|
-
"typescript": "^
|
|
64
|
+
"typescript": "^5.9.2",
|
|
65
|
+
"typescript-eslint": "^8.43.0"
|
|
64
66
|
},
|
|
65
67
|
"engines": {
|
|
66
68
|
"node": ">=22.12.0"
|