Skip to content

Commit df770c7

Browse files
committed
chore: try snapshot
1 parent 3aed931 commit df770c7

21 files changed

+55196
-91
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Prettier-only ignores.
22
CHANGELOG.md
3+
src/third_party/lighthouse-devtools-mcp-bundle.js

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ If you run into any issues, checkout our [troubleshooting guide](./docs/troubles
353353

354354
<!-- BEGIN AUTO GENERATED TOOLS -->
355355

356+
- **Audits** (1 tools)
357+
- [`lighthouse_audit`](docs/tool-reference.md#lighthouse_audit)
356358
- **Input automation** (8 tools)
357359
- [`click`](docs/tool-reference.md#click)
358360
- [`drag`](docs/tool-reference.md#drag)

docs/tool-reference.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
# Chrome DevTools MCP Tool Reference
44

5+
- **[Audits](#audits)** (1 tools)
6+
- [`lighthouse_audit`](#lighthouse_audit)
57
- **[Input automation](#input-automation)** (8 tools)
68
- [`click`](#click)
79
- [`drag`](#drag)
@@ -35,6 +37,22 @@
3537
- [`take_screenshot`](#take_screenshot)
3638
- [`take_snapshot`](#take_snapshot)
3739

40+
## Audits
41+
42+
### `lighthouse_audit`
43+
44+
**Description:** Runs a Lighthouse audit on the currently selected page.
45+
46+
**Parameters:**
47+
48+
- **categories** (array) _(optional)_: The categories to audit. Defaults to all available categories.
49+
- **device** (enum: "desktop", "mobile") _(optional)_: The device to [`emulate`](#emulate). "desktop" is the default. "mobile" emulates a mobile device.
50+
- **formats** (array) _(optional)_: Report formats to produce.
51+
- **mode** (enum: "navigation", "snapshot") _(optional)_: The mode to run Lighthouse in. "navigation" is the default and will reload the current page. "snapshot" analyzes the page in its current state.
52+
- **outputDirPath** (string) _(optional)_: The directory to output the reports to. If not provided, temporary files will be created.
53+
54+
---
55+
3856
## Input automation
3957

4058
### `click`

eslint.config.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import tseslint from 'typescript-eslint';
1414
import localPlugin from './scripts/eslint_rules/local-plugin.js';
1515

1616
export default defineConfig([
17-
globalIgnores(['**/node_modules', '**/build/']),
17+
globalIgnores([
18+
'**/node_modules',
19+
'**/build/',
20+
'src/third_party/lighthouse-devtools-mcp-bundle.js',
21+
]),
1822
importPlugin.flatConfigs.typescript,
1923
{
2024
languageOptions: {

package-lock.json

Lines changed: 5 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"test:update-snapshots": "npm run build && node scripts/test.mjs --test-update-snapshots",
2323
"prepare": "node --experimental-strip-types scripts/prepare.ts",
2424
"verify-server-json-version": "node --experimental-strip-types scripts/verify-server-json-version.ts",
25+
"update-lighthouse": "node --experimental-strip-types scripts/update-lighthouse.ts",
2526
"eval": "npm run build && CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS=true node --experimental-strip-types scripts/eval_gemini.ts",
2627
"count-tokens": "node --experimental-strip-types scripts/count_tokens.ts"
2728
},
@@ -61,7 +62,7 @@
6162
"eslint-import-resolver-typescript": "^4.4.4",
6263
"eslint-plugin-import": "^2.32.0",
6364
"globals": "^17.0.0",
64-
"lighthouse": "^13.0.1",
65+
"lighthouse": "13.0.2",
6566
"prettier": "^3.6.2",
6667
"puppeteer": "24.37.2",
6768
"rollup": "4.57.1",

rollup.config.mjs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ function listBundledDeps() {
107107
Object.entries(devDependencies).filter(
108108
([name]) =>
109109
aggregatedStats.bundledPackages.has(name) ||
110-
name === 'chrome-devtools-frontend',
110+
name === 'chrome-devtools-frontend' ||
111+
name === 'lighthouse',
111112
),
112113
);
113114

@@ -260,11 +261,15 @@ export default [
260261
return true;
261262
}
262263

263-
const existingExternals = ['./bidi.js', '../bidi/bidi.js'];
264+
const existingExternals = [
265+
'./bidi.js',
266+
'../bidi/bidi.js',
267+
'./lighthouse-devtools-mcp-bundle.js',
268+
];
269+
264270
if (existingExternals.includes(source)) {
265271
return true;
266272
}
267-
268273
return false;
269274
},
270275
),

scripts/prepare.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ function removeConflictingGlobalDeclaration(): void {
2727
projectRoot,
2828
'node_modules/@paulirish/trace_engine/models/trace/ModelImpl.d.ts',
2929
);
30-
console.log('Removing conflicting global declaration from @paulirish/trace_engine...');
30+
console.log(
31+
'Removing conflicting global declaration from @paulirish/trace_engine...',
32+
);
3133
const content = readFileSync(filePath, 'utf-8');
3234
// Remove the declare global block using regex
3335
// Matches: declare global { ... interface HTMLElementEventMap { ... } ... }

scripts/update-lighthouse.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* @license
3+
* Copyright 2026 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import {execSync} from 'node:child_process';
8+
import fs from 'node:fs';
9+
import path from 'node:path';
10+
11+
const ROOT_DIR = process.cwd();
12+
const LIGHTHOUSE_DIR = path.resolve(ROOT_DIR, '../lighthouse');
13+
const DEST_PATH = path.join(
14+
ROOT_DIR,
15+
'src/third_party/lighthouse-devtools-mcp-bundle.js',
16+
);
17+
18+
function main() {
19+
if (!fs.existsSync(LIGHTHOUSE_DIR)) {
20+
console.error(`Lighthouse directory not found at ${LIGHTHOUSE_DIR}`);
21+
process.exit(1);
22+
}
23+
24+
console.log('Running yarn in lighthouse directory...');
25+
execSync('yarn', {cwd: LIGHTHOUSE_DIR, stdio: 'inherit'});
26+
27+
console.log('Building lighthouse-devtools-mcp bundle...');
28+
execSync('yarn build-devtools-mcp', {cwd: LIGHTHOUSE_DIR, stdio: 'inherit'});
29+
30+
// Look for the bundle in dist/ or root
31+
const potentialPaths = [
32+
path.join(LIGHTHOUSE_DIR, 'dist', 'lighthouse-devtools-mcp-bundle.js'),
33+
path.join(LIGHTHOUSE_DIR, 'lighthouse-devtools-mcp-bundle.js'),
34+
];
35+
36+
let bundlePath = '';
37+
for (const p of potentialPaths) {
38+
if (fs.existsSync(p)) {
39+
bundlePath = p;
40+
break;
41+
}
42+
}
43+
44+
if (!bundlePath) {
45+
console.error(
46+
`Could not find built bundle. Checked:\n${potentialPaths.join('\n')}`,
47+
);
48+
process.exit(1);
49+
}
50+
51+
console.log(`Copying bundle from ${bundlePath} to ${DEST_PATH}...`);
52+
fs.copyFileSync(bundlePath, DEST_PATH);
53+
54+
console.log('Done.');
55+
}
56+
57+
main();

0 commit comments

Comments
 (0)