chrome-devtools-mcp 0.16.0 → 0.17.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 +11 -0
- package/build/src/DevtoolsUtils.js +113 -0
- package/build/src/McpContext.js +3 -0
- package/build/src/McpResponse.js +1 -8
- package/build/src/PageCollector.js +4 -9
- package/build/src/cli.js +9 -0
- package/build/src/formatters/ConsoleFormatter.js +144 -72
- package/build/src/main.js +5 -1
- package/build/src/third_party/THIRD_PARTY_NOTICES +4 -4
- package/build/src/third_party/bundled-packages.json +3 -3
- package/build/src/third_party/devtools-formatter-worker.js +0 -2
- package/build/src/third_party/index.js +349 -257
- package/build/src/tools/performance.js +31 -1
- package/package.json +4 -4
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import zlib from 'node:zlib';
|
|
7
|
-
import {
|
|
7
|
+
import { logger } from '../logger.js';
|
|
8
|
+
import { zod, DevTools } from '../third_party/index.js';
|
|
8
9
|
import { parseRawTraceBuffer, traceResultIsSuccess, } from '../trace-processing/parse.js';
|
|
9
10
|
import { ToolCategory } from './categories.js';
|
|
10
11
|
import { defineTool } from './ToolDefinition.js';
|
|
@@ -145,6 +146,9 @@ async function stopTracingAndAppendOutput(page, response, context, filePath) {
|
|
|
145
146
|
const result = await parseRawTraceBuffer(traceEventsBuffer);
|
|
146
147
|
response.appendResponseLine('The performance trace has been stopped.');
|
|
147
148
|
if (traceResultIsSuccess(result)) {
|
|
149
|
+
if (context.isCruxEnabled()) {
|
|
150
|
+
await populateCruxData(result);
|
|
151
|
+
}
|
|
148
152
|
context.storeTraceRecording(result);
|
|
149
153
|
response.attachTraceSummary(result);
|
|
150
154
|
}
|
|
@@ -156,3 +160,29 @@ async function stopTracingAndAppendOutput(page, response, context, filePath) {
|
|
|
156
160
|
context.setIsRunningPerformanceTrace(false);
|
|
157
161
|
}
|
|
158
162
|
}
|
|
163
|
+
/** We tell CrUXManager to fetch data so it's available when DevTools.PerformanceTraceFormatter is invoked */
|
|
164
|
+
async function populateCruxData(result) {
|
|
165
|
+
logger('populateCruxData called');
|
|
166
|
+
const cruxManager = DevTools.CrUXManager.instance();
|
|
167
|
+
// go/jtfbx. Yes, we're aware this API key is public. ;)
|
|
168
|
+
cruxManager.setEndpointForTesting('https://chromeuxreport.googleapis.com/v1/records:queryRecord?key=AIzaSyBn5gimNjhiEyA_euicSKko6IlD3HdgUfk');
|
|
169
|
+
const cruxSetting = DevTools.Common.Settings.Settings.instance().createSetting('field-data', {
|
|
170
|
+
enabled: true,
|
|
171
|
+
});
|
|
172
|
+
cruxSetting.set({ enabled: true });
|
|
173
|
+
// Gather URLs to fetch CrUX data for
|
|
174
|
+
const urls = [...(result.parsedTrace.insights?.values() ?? [])].map(c => c.url.toString());
|
|
175
|
+
urls.push(result.parsedTrace.data.Meta.mainFrameURL);
|
|
176
|
+
const urlSet = new Set(urls);
|
|
177
|
+
if (urlSet.size === 0) {
|
|
178
|
+
logger('No URLs found for CrUX data');
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
logger(`Fetching CrUX data for ${urlSet.size} URLs: ${Array.from(urlSet).join(', ')}`);
|
|
182
|
+
const cruxData = await Promise.all(Array.from(urlSet).map(async (url) => {
|
|
183
|
+
const data = await cruxManager.getFieldDataForPage(url);
|
|
184
|
+
logger(`CrUX data for ${url}: ${data ? 'found' : 'not found'}`);
|
|
185
|
+
return data;
|
|
186
|
+
}));
|
|
187
|
+
result.parsedTrace.metadata.cruxFieldData = cruxData;
|
|
188
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chrome-devtools-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "MCP server for Chrome DevTools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "./build/src/index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@eslint/js": "^9.35.0",
|
|
44
44
|
"@google/genai": "^1.37.0",
|
|
45
|
-
"@modelcontextprotocol/sdk": "1.
|
|
45
|
+
"@modelcontextprotocol/sdk": "1.26.0",
|
|
46
46
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
47
47
|
"@rollup/plugin-json": "^6.1.0",
|
|
48
48
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@types/yargs": "^17.0.33",
|
|
55
55
|
"@typescript-eslint/eslint-plugin": "^8.43.0",
|
|
56
56
|
"@typescript-eslint/parser": "^8.43.0",
|
|
57
|
-
"chrome-devtools-frontend": "1.0.
|
|
57
|
+
"chrome-devtools-frontend": "1.0.1581449",
|
|
58
58
|
"core-js": "3.48.0",
|
|
59
59
|
"debug": "4.4.3",
|
|
60
60
|
"eslint": "^9.35.0",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"eslint-plugin-import": "^2.32.0",
|
|
63
63
|
"globals": "^17.0.0",
|
|
64
64
|
"prettier": "^3.6.2",
|
|
65
|
-
"puppeteer": "24.
|
|
65
|
+
"puppeteer": "24.37.2",
|
|
66
66
|
"rollup": "4.57.1",
|
|
67
67
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
68
68
|
"rollup-plugin-license": "^3.6.0",
|