Skip to content

Commit 3ac5cd9

Browse files
authored
Merge branch 'main' into orkon/release-cli
2 parents 600829d + 013110b commit 3ac5cd9

17 files changed

Lines changed: 212 additions & 42 deletions

.github/workflows/presubmit.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ jobs:
5151
- name: Install dependencies
5252
run: npm ci
5353

54-
- name: Generate documents
55-
run: npm run docs
54+
- name: Generate
55+
run: npm run gen
5656

57-
- name: Check if autogenerated docs differ
57+
- name: Check if autogenerated code and docs are out of date
5858
run: |
5959
diff_file=$(mktemp doc_diff_XXXXXX)
6060
git diff --color > $diff_file
6161
if [[ -s $diff_file ]]; then
62-
echo "Please update the documentation by running 'npm run generate-docs'. The following was the diff"
62+
echo "Please update the documentation by running 'npm run gen'. The following was the diff"
6363
cat $diff_file
6464
rm $diff_file
6565
exit 1

CONTRIBUTING.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,22 @@ information on using pull requests.
3737
Please follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/)
3838
for PR and commit titles.
3939

40+
### Feature release checklist
41+
42+
Use `chore:` for commits containing incomplete features that are not available
43+
to users yet. Once the feature is ready to be released, create a PR with a
44+
`feat:` prefix that enables the feature. The following criteria need to be
45+
completed:
46+
47+
- Documentation for the feature is up to date. For example, README.md and tools
48+
reference are updated.
49+
- The feature can be used with Chrome stable or version restrictions are
50+
documented otherwise.
51+
- Corresponding skills are updated or new skills are added if needed.
52+
- The feature fulfills the use case by its own or in conjunction with existing
53+
features (we want to avoid features that offer some tools but cannot be used
54+
successfully to debug things).
55+
4056
## Installation
4157

4258
Check that you are using node version specified in .nvmrc, then run following commands:
@@ -86,7 +102,7 @@ You can use the `DEBUG` environment variable as usual to control categories that
86102

87103
### Updating documentation
88104

89-
When adding a new tool or updating a tool name or description, make sure to run `npm run docs` to generate the tool reference documentation.
105+
When adding a new tool or updating a tool name or description, make sure to run `npm run gen` to generate the tool reference documentation.
90106

91107
### Contributing to Evals
92108

docs/cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The CLI acts as a client to a background `chrome-devtools-mcp` daemon (uses Unix
1717

1818
- **Automatic Start**: The first time you call a tool (e.g., `list_pages`), the CLI automatically starts the MCP server and the browser in the background if they aren't already running.
1919
- **Persistence**: The same background instance is reused for subsequent commands, preserving the browser state (open pages, cookies, etc.).
20-
- **Manual Control**: You can explicitly manage the background process using `start`, `stop`, and `status`. The `start` command forwards all subsequent arguments to the underlying MCP server (e.g., `--headless`, `--userDataDir`).
20+
- **Manual Control**: You can explicitly manage the background process using `start`, `stop`, and `status`. The `start` command forwards all subsequent arguments to the underlying MCP server (e.g., `--headless`, `--userDataDir`) but not all args are supported. Run `chrome-devtools start --help` for supported args. Headless and isolated are enabled by default.
2121

2222
```sh
2323
# Check if the daemon is running

docs/slim-tool-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- AUTO GENERATED DO NOT EDIT - run 'npm run docs' to update-->
1+
<!-- AUTO GENERATED DO NOT EDIT - run 'npm run gen' to update-->
22

33
# Chrome DevTools MCP Slim Tool Reference (~359 cl100k_base tokens)
44

docs/tool-reference.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<!-- AUTO GENERATED DO NOT EDIT - run 'npm run docs' to update-->
1+
<!-- AUTO GENERATED DO NOT EDIT - run 'npm run gen' to update-->
22

3-
# Chrome DevTools MCP Tool Reference (~6927 cl100k_base tokens)
3+
# Chrome DevTools MCP Tool Reference (~6940 cl100k_base tokens)
44

55
- **[Input automation](#input-automation)** (9 tools)
66
- [`click`](#click)
@@ -348,7 +348,7 @@ so returned values have to be JSON-serializable.
348348

349349
### `lighthouse_audit`
350350

351-
**Description:** Get Lighthouse score and reports for accessibility, SEO and best practices.
351+
**Description:** Get Lighthouse score and reports for accessibility, SEO and best practices. This excludes performance. For performance audits, run [`performance_start_trace`](#performance_start_trace)
352352

353353
**Parameters:**
354354

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"typecheck": "tsc --noEmit",
1717
"format": "eslint --cache --fix . && prettier --write --cache .",
1818
"check-format": "eslint --cache . && prettier --check --cache .;",
19-
"docs": "npm run build && npm run docs:generate && npm run format",
19+
"gen": "npm run build && npm run docs:generate && npm run cli:generate && npm run format",
2020
"docs:generate": "node --experimental-strip-types scripts/generate-docs.ts",
2121
"start": "npm run build && node build/src/index.js",
2222
"start-debug": "DEBUG=mcp:* DEBUG_COLORS=false npm run build && node build/src/index.js",

release-please-config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
{"type": "fix", "section": "🛠️ Fixes", "hidden": false},
55
{"type": "docs", "section": "📄 Documentation", "hidden": false},
66

7-
{"type": "perf", "section": "♻️ Chores", "hidden": false},
8-
{"type": "refactor", "section": "♻️ Chores", "hidden": false},
7+
{"type": "perf", "section": "⚡ Performance", "hidden": false},
8+
{"type": "refactor", "section": "🏗️ Refactor", "hidden": false},
99
{"type": "chore", "section": "♻️ Chores", "hidden": true},
1010
{"type": "test", "section": "♻️ Chores", "hidden": true},
1111

scripts/generate-docs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ async function generateReference(
323323
console.log(`Found ${toolsWithAnnotations.length} tools`);
324324

325325
// Generate markdown documentation
326-
let markdown = `<!-- AUTO GENERATED DO NOT EDIT - run 'npm run docs' to update-->
326+
let markdown = `<!-- AUTO GENERATED DO NOT EDIT - run 'npm run gen' to update-->
327327
328328
# ${title} (~${(await measureServer(serverArgs)).tokenCount} cl100k_base tokens)
329329

src/bin/chrome-devtools.ts

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import process from 'node:process';
1010

1111
import type {Options, PositionalOptions} from 'yargs';
1212

13-
import {parseArguments} from '../cli.js';
13+
import {cliOptions, parseArguments} from '../cli.js';
1414
import {
1515
startDaemon,
1616
stopDaemon,
1717
sendCommand,
1818
handleResponse,
1919
} from '../daemon/client.js';
20-
import {isDaemonRunning} from '../daemon/utils.js';
20+
import {isDaemonRunning, serializeArgs} from '../daemon/utils.js';
2121
import {logDisclaimers} from '../server.js';
2222
import {hideBin, yargs, type CallToolResult} from '../third_party/index.js';
2323
import {VERSION} from '../version.js';
@@ -26,12 +26,41 @@ import {commands} from './cliDefinitions.js';
2626

2727
async function start(args: string[]) {
2828
const combinedArgs = [...args, ...defaultArgs];
29-
await startDaemon([...args, ...defaultArgs]);
29+
await startDaemon(combinedArgs);
3030
logDisclaimers(parseArguments(VERSION, combinedArgs));
3131
}
3232

3333
const defaultArgs = ['--viaCli', '--experimentalStructuredContent'];
3434

35+
const startCliOptions = {
36+
...cliOptions,
37+
} as Partial<typeof cliOptions>;
38+
39+
// Not supported in CLI on purpose.
40+
delete startCliOptions.autoConnect;
41+
// Missing CLI serialization.
42+
delete startCliOptions.viewport;
43+
// CLI is generated based on the default tool definitions. To enable conditional
44+
// tools, they needs to be enabled during CLI generation.
45+
delete startCliOptions.experimentalPageIdRouting;
46+
delete startCliOptions.experimentalVision;
47+
delete startCliOptions.experimentalInteropTools;
48+
delete startCliOptions.experimentalScreencast;
49+
delete startCliOptions.categoryEmulation;
50+
delete startCliOptions.categoryPerformance;
51+
delete startCliOptions.categoryNetwork;
52+
delete startCliOptions.categoryExtensions;
53+
// Always on in CLI.
54+
delete startCliOptions.experimentalStructuredContent;
55+
// Change the defaults.
56+
if (!('default' in cliOptions.headless)) {
57+
throw new Error('headless cli option unexpectedly does not have a default');
58+
}
59+
if ('default' in cliOptions.isolated) {
60+
throw new Error('headless cli option unexpectedly does not have a default');
61+
}
62+
startCliOptions.headless!.default = true;
63+
3564
const y = yargs(hideBin(process.argv))
3665
.scriptName('chrome-devtools')
3766
.showHelpOnFail(true)
@@ -50,19 +79,24 @@ y.command(
5079
'Start or restart chrome-devtools-mcp',
5180
y =>
5281
y
53-
.help(false) // Disable help for start command to avoid parsing issues with passed args.
82+
.options(startCliOptions)
5483
.example(
55-
'$0 start --port 8080 --url http://localhost:8080',
56-
'Start the server on port 8080 with a specific URL',
84+
'$0 start --browserUrl http://localhost:9222',
85+
'Start the server connecting to an existing browser',
5786
)
58-
.strict(false), // Don't validate arguments for start, as they are passed through to the daemon.
59-
async () => {
87+
.strict(),
88+
async argv => {
6089
if (isDaemonRunning()) {
6190
await stopDaemon();
6291
}
63-
// Extract args after 'start'
64-
const startIndex = process.argv.indexOf('start');
65-
const args = startIndex !== -1 ? process.argv.slice(startIndex + 1) : [];
92+
// Defaults but we do not want to affect the yargs conflict resolution.
93+
if (argv.isolated === undefined) {
94+
argv.isolated = true;
95+
}
96+
if (argv.headless === undefined) {
97+
argv.headless = true;
98+
}
99+
const args = serializeArgs(cliOptions, argv);
66100
await start(args);
67101
process.exit(0);
68102
},

src/bin/cliDefinitions.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ export const commands: Commands = {
287287
},
288288
lighthouse_audit: {
289289
description:
290-
'Get Lighthouse score and reports for accessibility, SEO and best practices.',
290+
'Get Lighthouse score and reports for accessibility, SEO and best practices. This excludes performance. For performance audits, run performance_start_trace',
291291
category: 'Debugging',
292292
args: {
293293
mode: {
@@ -393,7 +393,8 @@ export const commands: Commands = {
393393
args: {},
394394
},
395395
navigate_page: {
396-
description: 'Navigates the currently selected page to a URL.',
396+
description:
397+
'Go to a URL, or back, forward, or reload. Use project URL if not specified otherwise.',
397398
category: 'Navigation automation',
398399
args: {
399400
type: {
@@ -441,7 +442,8 @@ export const commands: Commands = {
441442
},
442443
},
443444
new_page: {
444-
description: 'Creates a new page',
445+
description:
446+
'Open a new tab and load a URL. Use project URL if not specified otherwise.',
445447
category: 'Navigation automation',
446448
args: {
447449
url: {
@@ -496,22 +498,24 @@ export const commands: Commands = {
496498
},
497499
performance_start_trace: {
498500
description:
499-
'Starts a performance trace recording on the selected page. This can be used to look for performance problems and insights to improve the performance of the page. It will also report Core Web Vital (CWV) scores for the page.',
501+
'Start a performance trace on the selected webpage. Use to find frontend performance issues, Core Web Vitals (LCP, INP, CLS), and improve page load speed.',
500502
category: 'Performance',
501503
args: {
502504
reload: {
503505
name: 'reload',
504506
type: 'boolean',
505507
description:
506508
'Determines if, once tracing has started, the current selected page should be automatically reloaded. Navigate the page to the right URL using the navigate_page tool BEFORE starting the trace if reload or autoStop is set to true.',
507-
required: true,
509+
required: false,
510+
default: true,
508511
},
509512
autoStop: {
510513
name: 'autoStop',
511514
type: 'boolean',
512515
description:
513516
'Determines if the trace recording should be automatically stopped.',
514-
required: true,
517+
required: false,
518+
default: true,
515519
},
516520
filePath: {
517521
name: 'filePath',
@@ -524,7 +528,7 @@ export const commands: Commands = {
524528
},
525529
performance_stop_trace: {
526530
description:
527-
'Stops the active performance trace recording on the selected page.',
531+
'Stop the active performance trace recording on the selected webpage.',
528532
category: 'Performance',
529533
args: {
530534
filePath: {

0 commit comments

Comments
 (0)