chrome-devtools-mcp 1.9.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/build/src/BrowserManager.js +401 -0
- package/build/src/McpContext.js +5 -5
- package/build/src/McpPage.js +107 -3
- package/build/src/McpResponse.js +68 -3
- package/build/src/ToolHandler.js +172 -118
- package/build/src/bin/chrome-devtools-mcp-main.js +11 -6
- package/build/src/bin/chrome-devtools.js +6 -12
- package/build/src/collectors/PageCollector.js +66 -3
- package/build/src/config/browser-options.js +2 -0
- package/build/src/config/category-options.js +13 -4
- package/build/src/config/cli-commands.js +26 -0
- package/build/src/config/cli-options.js +32 -0
- package/build/src/config/mcp-options.js +40 -1
- package/build/src/devtools/DevToolsCommentBridge.js +91 -0
- package/build/src/formatters/CommentFormatter.js +82 -0
- package/build/src/formatters/CssFormatter.js +812 -0
- package/build/src/index.js +53 -72
- package/build/src/processors/ChunkedTraceParser.js +361 -0
- package/build/src/processors/PerformanceTrace.js +60 -13
- package/build/src/telemetry/ClearcutLogger.js +91 -34
- 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 +685 -131
- package/build/src/third_party/bundled-packages.json +6 -3
- package/build/src/third_party/devtools-formatter-worker.js +136 -5
- package/build/src/third_party/devtools-heap-snapshot-worker.js +567 -6
- package/build/src/third_party/index.js +54945 -35497
- 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 +13 -21
- 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 +4 -4
- package/build/src/tools/pages.js +14 -14
- package/build/src/tools/performance.js +6 -6
- package/build/src/tools/pwa.js +8 -8
- package/build/src/tools/screencast.js +4 -4
- package/build/src/tools/screenshot.js +2 -2
- package/build/src/tools/script.js +7 -7
- package/build/src/tools/slim/tools.js +5 -5
- 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 +14 -8
- package/build/src/utils/logger.js +7 -6
- package/build/src/version.js +1 -1
- package/package.json +8 -5
- package/skills/chrome-devtools/SKILL.md +2 -1
- package/skills/chrome-devtools-cli/SKILL.md +2 -0
- package/build/src/browser.js +0 -233
- package/build/src/third_party/issue-descriptions/cookieExcludeBlockedWithinRelatedWebsiteSet.md +0 -4
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"@modelcontextprotocol/
|
|
2
|
+
"@modelcontextprotocol/client": "2.0.0",
|
|
3
|
+
"@modelcontextprotocol/core": "2.0.0",
|
|
4
|
+
"@modelcontextprotocol/server": "2.0.0",
|
|
3
5
|
"core-js": "3.50.0",
|
|
4
6
|
"lighthouse": "13.4.1",
|
|
5
7
|
"semver": "7.8.5",
|
|
6
8
|
"yargs": "18.1.0",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
+
"zod": "4.6.2",
|
|
10
|
+
"puppeteer-core": "25.11.0",
|
|
11
|
+
"https://github.com/ChromeDevTools/devtools-frontend": "61277feec01840bfa7cffb21d90bed500f973c70"
|
|
9
12
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as Fs from 'node:fs';
|
|
2
|
+
import * as Url from 'node:url';
|
|
1
3
|
import * as WorkerThreads from 'node:worker_threads';
|
|
2
4
|
|
|
3
5
|
// Copyright 2020 The Chromium Authors
|
|
@@ -80,6 +82,55 @@ class WebWorker {
|
|
|
80
82
|
});
|
|
81
83
|
}
|
|
82
84
|
}
|
|
85
|
+
let lastScreenshotBlobUrl = null;
|
|
86
|
+
function revokeLastScreenshotUrl() {
|
|
87
|
+
if (lastScreenshotBlobUrl) {
|
|
88
|
+
URL.revokeObjectURL(lastScreenshotBlobUrl);
|
|
89
|
+
lastScreenshotBlobUrl = null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async function saveScreenshot(options) {
|
|
93
|
+
const pageImage = new Image();
|
|
94
|
+
await new Promise((resolve, reject) => {
|
|
95
|
+
pageImage.onload = () => resolve();
|
|
96
|
+
pageImage.onerror = () => reject(new Error('Failed to load image for screenshot'));
|
|
97
|
+
pageImage.src = 'data:image/png;base64,' + options.base64Png;
|
|
98
|
+
});
|
|
99
|
+
let canvas;
|
|
100
|
+
if (options.clip) {
|
|
101
|
+
const scale = pageImage.naturalWidth / options.clip.screenRectWidth;
|
|
102
|
+
const screenRectWidth = options.clip.screenRectWidth * scale;
|
|
103
|
+
const screenRectHeight = options.clip.screenRectHeight * scale;
|
|
104
|
+
const contentLeft = options.clip.visiblePageRectLeft * scale;
|
|
105
|
+
const contentTop = options.clip.visiblePageRectTop * scale;
|
|
106
|
+
canvas = new OffscreenCanvas(Math.floor(screenRectWidth),
|
|
107
|
+
Math.min(1 << 14, Math.floor(screenRectHeight)));
|
|
108
|
+
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
|
109
|
+
if (!ctx) {
|
|
110
|
+
throw new Error('Could not get 2d context from canvas.');
|
|
111
|
+
}
|
|
112
|
+
ctx.imageSmoothingEnabled = false;
|
|
113
|
+
ctx.drawImage(pageImage, Math.floor(contentLeft), Math.floor(contentTop));
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
canvas = new OffscreenCanvas(pageImage.naturalWidth, Math.min(1 << 14, Math.floor(pageImage.naturalHeight)));
|
|
117
|
+
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
|
118
|
+
if (!ctx) {
|
|
119
|
+
throw new Error('Could not get 2d context for base64 screenshot.');
|
|
120
|
+
}
|
|
121
|
+
ctx.imageSmoothingEnabled = false;
|
|
122
|
+
ctx.drawImage(pageImage, 0, 0);
|
|
123
|
+
}
|
|
124
|
+
revokeLastScreenshotUrl();
|
|
125
|
+
const link = document.createElement('a');
|
|
126
|
+
link.download = options.fileName + '.png';
|
|
127
|
+
const blob = await canvas.convertToBlob({ type: 'image/png' });
|
|
128
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
129
|
+
lastScreenshotBlobUrl = blobUrl;
|
|
130
|
+
link.href = blobUrl;
|
|
131
|
+
link.click();
|
|
132
|
+
}
|
|
133
|
+
let cssEvaluationElement = null;
|
|
83
134
|
const HOST_RUNTIME$2 = {
|
|
84
135
|
createWorker(url) {
|
|
85
136
|
return new WebWorker(url);
|
|
@@ -94,6 +145,44 @@ const HOST_RUNTIME$2 = {
|
|
|
94
145
|
getLocalStorage() {
|
|
95
146
|
return 'localStorage' in globalThis ? globalThis.localStorage : undefined;
|
|
96
147
|
},
|
|
148
|
+
getCacheStorage() {
|
|
149
|
+
return 'caches' in globalThis ? globalThis.caches : undefined;
|
|
150
|
+
},
|
|
151
|
+
getDevicePixelRatio() {
|
|
152
|
+
return window.devicePixelRatio;
|
|
153
|
+
},
|
|
154
|
+
saveScreenshot,
|
|
155
|
+
revokeLastScreenshotUrl,
|
|
156
|
+
async loadTextFile(url) {
|
|
157
|
+
const response = await fetch(url);
|
|
158
|
+
return await response.text();
|
|
159
|
+
},
|
|
160
|
+
evaluateCSS(dataValue, customExpr) {
|
|
161
|
+
if (!cssEvaluationElement || !cssEvaluationElement.isConnected) {
|
|
162
|
+
cssEvaluationElement = document.getElementById('css-evaluation-element');
|
|
163
|
+
if (!cssEvaluationElement) {
|
|
164
|
+
cssEvaluationElement = document.createElement('div');
|
|
165
|
+
cssEvaluationElement.id = 'css-evaluation-element';
|
|
166
|
+
cssEvaluationElement.setAttribute('style', 'hidden: true; --evaluation: attr(data-custom-expr type(*))');
|
|
167
|
+
document.body.appendChild(cssEvaluationElement);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (dataValue !== null) {
|
|
171
|
+
cssEvaluationElement.setAttribute('data-value', dataValue);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
cssEvaluationElement.removeAttribute('data-value');
|
|
175
|
+
}
|
|
176
|
+
cssEvaluationElement.setAttribute('data-custom-expr', customExpr);
|
|
177
|
+
return cssEvaluationElement.computedStyleMap().get('--evaluation')?.toString() ?? null;
|
|
178
|
+
},
|
|
179
|
+
removeCSSEvaluationElement() {
|
|
180
|
+
const element = cssEvaluationElement ?? document.getElementById('css-evaluation-element');
|
|
181
|
+
if (element) {
|
|
182
|
+
element.remove();
|
|
183
|
+
}
|
|
184
|
+
cssEvaluationElement = null;
|
|
185
|
+
},
|
|
97
186
|
};
|
|
98
187
|
|
|
99
188
|
var HostRuntime$1 = /*#__PURE__*/Object.freeze({
|
|
@@ -120,13 +209,15 @@ class NodeWorkerScope {
|
|
|
120
209
|
}
|
|
121
210
|
}
|
|
122
211
|
class NodeWorker {
|
|
212
|
+
#worker;
|
|
123
213
|
#workerPromise;
|
|
124
214
|
#disposed = false;
|
|
125
215
|
#rejectWorkerPromise;
|
|
126
216
|
constructor(url) {
|
|
217
|
+
const worker = new WorkerThreads.Worker(new URL(url));
|
|
218
|
+
this.#worker = worker;
|
|
127
219
|
this.#workerPromise = new Promise((resolve, reject) => {
|
|
128
220
|
this.#rejectWorkerPromise = reject;
|
|
129
|
-
const worker = new WorkerThreads.Worker(new URL(url));
|
|
130
221
|
worker.once('message', (message) => {
|
|
131
222
|
if (message === 'workerReady') {
|
|
132
223
|
resolve(worker);
|
|
@@ -134,6 +225,7 @@ class NodeWorker {
|
|
|
134
225
|
});
|
|
135
226
|
worker.on('error', reject);
|
|
136
227
|
});
|
|
228
|
+
this.#workerPromise.catch(() => { });
|
|
137
229
|
}
|
|
138
230
|
postMessage(message, transfer) {
|
|
139
231
|
void this.#workerPromise.then(worker => {
|
|
@@ -144,7 +236,7 @@ class NodeWorker {
|
|
|
144
236
|
}
|
|
145
237
|
dispose() {
|
|
146
238
|
this.#disposed = true;
|
|
147
|
-
void this.#
|
|
239
|
+
void this.#worker.terminate();
|
|
148
240
|
}
|
|
149
241
|
terminate(immediately) {
|
|
150
242
|
if (immediately) {
|
|
@@ -171,6 +263,30 @@ class NodeWorker {
|
|
|
171
263
|
});
|
|
172
264
|
}
|
|
173
265
|
}
|
|
266
|
+
class NodeCacheEntry {
|
|
267
|
+
#entries = new Map();
|
|
268
|
+
async put(url, response) {
|
|
269
|
+
this.#entries.set(url, response.clone());
|
|
270
|
+
}
|
|
271
|
+
async match(url) {
|
|
272
|
+
return this.#entries.get(url)?.clone();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
class NodeCacheStorage {
|
|
276
|
+
#caches = new Map();
|
|
277
|
+
async open(name) {
|
|
278
|
+
let cache = this.#caches.get(name);
|
|
279
|
+
if (!cache) {
|
|
280
|
+
cache = new NodeCacheEntry();
|
|
281
|
+
this.#caches.set(name, cache);
|
|
282
|
+
}
|
|
283
|
+
return cache;
|
|
284
|
+
}
|
|
285
|
+
async delete(name) {
|
|
286
|
+
return this.#caches.delete(name);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
const nodeCacheStorage = new NodeCacheStorage();
|
|
174
290
|
const HOST_RUNTIME$1 = {
|
|
175
291
|
createWorker(url) {
|
|
176
292
|
return new NodeWorker(url);
|
|
@@ -185,6 +301,21 @@ const HOST_RUNTIME$1 = {
|
|
|
185
301
|
getLocalStorage() {
|
|
186
302
|
return undefined;
|
|
187
303
|
},
|
|
304
|
+
getCacheStorage() {
|
|
305
|
+
return nodeCacheStorage;
|
|
306
|
+
},
|
|
307
|
+
getDevicePixelRatio() {
|
|
308
|
+
return 1;
|
|
309
|
+
},
|
|
310
|
+
async saveScreenshot(_options) { },
|
|
311
|
+
revokeLastScreenshotUrl() { },
|
|
312
|
+
async loadTextFile(url) {
|
|
313
|
+
return await Fs.promises.readFile(Url.fileURLToPath(url), 'utf-8');
|
|
314
|
+
},
|
|
315
|
+
evaluateCSS(_dataValue, _customExpr) {
|
|
316
|
+
return null;
|
|
317
|
+
},
|
|
318
|
+
removeCSSEvaluationElement() { },
|
|
188
319
|
};
|
|
189
320
|
|
|
190
321
|
var HostRuntime = /*#__PURE__*/Object.freeze({
|
|
@@ -8531,9 +8662,9 @@ class ColorConverter {
|
|
|
8531
8662
|
static xyzd65ToOklab(x, y, z) {
|
|
8532
8663
|
const xyzInput = new Vector3([x, y, z]);
|
|
8533
8664
|
const lmsIntermediate = XYZ_TO_LMS_MATRIX.multiply(xyzInput);
|
|
8534
|
-
lmsIntermediate.values[0] = Math.
|
|
8535
|
-
lmsIntermediate.values[1] = Math.
|
|
8536
|
-
lmsIntermediate.values[2] = Math.
|
|
8665
|
+
lmsIntermediate.values[0] = Math.cbrt(lmsIntermediate.values[0]);
|
|
8666
|
+
lmsIntermediate.values[1] = Math.cbrt(lmsIntermediate.values[1]);
|
|
8667
|
+
lmsIntermediate.values[2] = Math.cbrt(lmsIntermediate.values[2]);
|
|
8537
8668
|
const labOutput = LMS_TO_OKLAB_MATRIX.multiply(lmsIntermediate);
|
|
8538
8669
|
return [labOutput.values[0], labOutput.values[1], labOutput.values[2]];
|
|
8539
8670
|
}
|