Skip to content

Commit 574b5fe

Browse files
committed
Polish readme
* add configuration section * remove existing --help output * move user-data-dir to new concepts section * fix small spelling issues in the readme
1 parent 732267d commit 574b5fe

File tree

3 files changed

+137
-82
lines changed

3 files changed

+137
-82
lines changed

README.md

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ prototype!
88

99
`chrome-devtools-mcp` exposes content of the browser instance to the MCP clients
1010
allowing them to inspect, debug, and modify any data in the browser or DevTools.
11-
Avoid sharing sensitive or personal information that you do want to share with
11+
Avoid sharing sensitive or personal information that you don't want to share with
1212
MCP clients.
1313

1414
## Requirements
@@ -33,7 +33,7 @@ Add the following config to your MCP client:
3333
```
3434

3535
> [!NOTE]
36-
> `Using `chrome-devtools-mcp@latest` ensures that your MCP client will always use the latest version of the Chrome DevTools MCP server.
36+
> Using `chrome-devtools-mcp@latest` ensures that your MCP client will always use the latest version of the Chrome DevTools MCP server.
3737
3838
### MCP Client specific configuration
3939

@@ -119,7 +119,41 @@ claude mcp add chrome-devtools-mcp npx chrome-devtools-mcp@latest
119119

120120
## Configuration
121121

122-
For example, to launch the system-installed Chrome Canary pass `--channel=canary` as an argument:
122+
The Chrome DevTools MCP server supports the following configuration option:
123+
124+
<!-- BEGIN AUTO GENERATED OPTIONS -->
125+
126+
- **`--browserUrl`, `-u`**
127+
Connect to a running Chrome instance using port forwarding. For more details see: https://developer.chrome.com/docs/devtools/remote-debugging/local-server.
128+
129+
- **Type:** string
130+
131+
- **`--headless`**
132+
Whether to run in headless (no UI) mode.
133+
134+
- **Type:** boolean
135+
- **Default:** `false`
136+
137+
- **`--executablePath`, `-e`**
138+
Path to custom Chrome executable.
139+
140+
- **Type:** string
141+
142+
- **`--isolated`**
143+
If specified, creates a temporary user-data-dir that is automatically cleaned up after the browser is closed.
144+
145+
- **Type:** boolean
146+
- **Default:** `false`
147+
148+
- **`--channel`**
149+
Specify a different Chrome channel that should be used.
150+
- **Type:** string
151+
- **Choices:** `stable`, `canary`, `beta`, `dev`
152+
- **Default:** `stable`
153+
154+
<!-- END AUTO GENERATED OPTIONS -->
155+
156+
Pass them via the `args` property in the JSON configuration. For example:
123157

124158
```json
125159
{
@@ -129,44 +163,27 @@ For example, to launch the system-installed Chrome Canary pass `--channel=canary
129163
"args": [
130164
"chrome-devtools-mcp@latest"
131165
"--channel=canary",
166+
"--headless=true",
167+
"--isolated=true",
132168
]
133169
}
134170
}
135171
}
136172
```
137173

174+
You can also run `npx chrome-devtools-mcp@latest --help` to see all available configuration options.
175+
176+
## Concepts
177+
138178
### User data directory
139179

140-
`chrome-devtools-mcp` starts a Chrome's stable channel instance using the user
141-
data directory at `$HOME/.cache/chrome-devtools-mcp/mcp-profile-$CHANNEL` on
142-
Linux/MacOS and `%HOMEPATH%/.cache/chrome-devtools-mcp/mcp-profile-$CHANNEL` in
143-
Windows. The user data directory is not cleared between runs and shared across
144-
all instances of `chrome-devtools-mcp`.
145-
146-
## CLI
147-
148-
Run `npx chrome-devtools-mcp@latest --help` to see all available configuration options:
149-
150-
<!-- BEGIN AUTO GENERATED CLI -->
151-
152-
```sh
153-
Options:
154-
--version Show version number [boolean]
155-
-u, --browserUrl The browser URL to connect to [string]
156-
--headless Whether to run in headless (no UI) mode [boolean] [default: false]
157-
-e, --executablePath Path to custom Chrome executable [string]
158-
--isolated If specified, creates a temporary user-data-dir that is automatically cleaned up after the browser is closed. [boolean] [default: false]
159-
--channel System installed browser channel to use. [string] [choices: "stable", "canary", "beta", "dev"]
160-
--help Show help [boolean]
161-
162-
Examples:
163-
npx chrome-devtools-mcp@latest --browserUrl http://127.0.0.1:9222 Connect to an existing browser instance
164-
npx chrome-devtools-mcp@latest --channel beta Use Chrome Beta installed on this system
165-
npx chrome-devtools-mcp@latest --channel canary Use Chrome Canary installed on this system
166-
npx chrome-devtools-mcp@latest --channel dev Use Chrome Dev installed on this system
167-
npx chrome-devtools-mcp@latest --channel stable Use stable Chrome installed on this system
168-
npx chrome-devtools-mcp@latest --logFile /tmp/log.txt Save logs to a file
169-
npx chrome-devtools-mcp@latest --help Print CLI options
170-
```
180+
`chrome-devtools-mcp` starts a Chrome's stable channel instance using the following user
181+
data directory:
182+
183+
- Linux / MacOS: `$HOME/.cache/chrome-devtools-mcp/mcp-profile-$CHANNEL`
184+
- Window: `%HOMEPATH%/.cache/chrome-devtools-mcp/mcp-profile-$CHANNEL`
171185

172-
<!-- END AUTO GENERATED CLI -->
186+
The user data directory is not cleared between runs and shared across
187+
all instances of `chrome-devtools-mcp`. Set the `isolated` option to `true`
188+
to use a temporary user data dir instead which will be cleared automatically after
189+
the browser is closed.

scripts/generate-docs.ts

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {Client} from '@modelcontextprotocol/sdk/client/index.js';
88
import {StdioClientTransport} from '@modelcontextprotocol/sdk/client/stdio.js';
99
import type {Tool} from '@modelcontextprotocol/sdk/types.js';
1010
import {ToolCategories} from '../build/src/tools/categories.js';
11+
import {cliOptions} from '../build/src/index.js';
1112
import fs from 'fs';
12-
import {spawnSync} from 'child_process';
1313

1414
const MCP_SERVER_PATH = 'build/src/index.js';
1515
const OUTPUT_PATH = './docs/tool-reference.md';
@@ -102,27 +102,62 @@ function updateReadmeWithToolsTOC(toolsTOC: string): void {
102102
console.log('Updated README.md with tools table of contents');
103103
}
104104

105-
function updateReadmeWithConfigOptions(help: string): void {
105+
function generateConfigOptionsMarkdown(): string {
106+
let markdown = '';
107+
108+
for (const [optionName, optionConfig] of Object.entries(cliOptions)) {
109+
// Skip hidden options
110+
if (optionConfig.hidden) {
111+
continue;
112+
}
113+
114+
const aliasText = optionConfig.alias ? `, \`-${optionConfig.alias}\`` : '';
115+
const description = optionConfig.description || optionConfig.describe || '';
116+
117+
// Start with option name and description
118+
markdown += `- **\`--${optionName}\`${aliasText}**\n`;
119+
markdown += ` ${description}\n`;
120+
121+
// Add type information
122+
markdown += ` - **Type:** ${optionConfig.type}\n`;
123+
124+
// Add choices if available
125+
if (optionConfig.choices) {
126+
markdown += ` - **Choices:** ${optionConfig.choices.map(c => `\`${c}\``).join(', ')}\n`;
127+
}
128+
129+
// Add default if available
130+
if (optionConfig.default !== undefined) {
131+
markdown += ` - **Default:** \`${optionConfig.default}\`\n`;
132+
}
133+
134+
markdown += '\n';
135+
}
136+
137+
return markdown;
138+
}
139+
140+
function updateReadmeWithOptionsMarkdown(optionsMarkdown: string): void {
106141
const readmeContent = fs.readFileSync(README_PATH, 'utf8');
107142

108-
const beginMarker = '<!-- BEGIN AUTO GENERATED CLI -->';
109-
const endMarker = '<!-- END AUTO GENERATED CLI -->';
143+
const beginMarker = '<!-- BEGIN AUTO GENERATED OPTIONS -->';
144+
const endMarker = '<!-- END AUTO GENERATED OPTIONS -->';
110145

111146
const beginIndex = readmeContent.indexOf(beginMarker);
112147
const endIndex = readmeContent.indexOf(endMarker);
113148

114149
if (beginIndex === -1 || endIndex === -1) {
115-
console.warn('Could not find auto-generated config markers in README.md');
150+
console.warn('Could not find auto-generated options markers in README.md');
116151
return;
117152
}
118153

119154
const before = readmeContent.substring(0, beginIndex + beginMarker.length);
120155
const after = readmeContent.substring(endIndex);
121156

122-
const updatedContent = before + '\n\n```sh\n' + help + '```\n\n' + after;
157+
const updatedContent = before + '\n\n' + optionsMarkdown + '\n' + after;
123158

124159
fs.writeFileSync(README_PATH, updatedContent);
125-
console.log('Updated README.md with config options');
160+
console.log('Updated README.md with options markdown');
126161
}
127162

128163
async function generateToolDocumentation(): Promise<void> {
@@ -280,15 +315,12 @@ async function generateToolDocumentation(): Promise<void> {
280315
const toolsTOC = generateToolsTOC(categories, sortedCategories);
281316
updateReadmeWithToolsTOC(toolsTOC);
282317

283-
const helpResult = spawnSync('npx chrome-devtools-mcp --help', {
284-
shell: true,
285-
cwd: process.cwd(),
286-
env: process.env,
287-
});
288-
updateReadmeWithConfigOptions(helpResult.stdout.toString('utf-8'));
289-
318+
// Generate and update configuration options
319+
const optionsMarkdown = generateConfigOptionsMarkdown();
320+
updateReadmeWithOptionsMarkdown(optionsMarkdown);
290321
// Clean up
291322
await client.close();
323+
process.exit(0);
292324
} catch (error) {
293325
console.error('Error generating documentation:', error);
294326
process.exit(1);

src/index.ts

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,52 +34,58 @@ import path from 'node:path';
3434
import fs from 'node:fs';
3535
import assert from 'node:assert';
3636

37-
export const yargsInstance = yargs(hideBin(process.argv))
38-
.scriptName('npx chrome-devtools-mcp@latest')
39-
.option('browserUrl', {
40-
type: 'string',
41-
description: 'The browser URL to connect to',
37+
export const cliOptions = {
38+
browserUrl: {
39+
type: 'string' as const,
40+
description:
41+
'Connect to a running Chrome instance using port forwarding. For more details see: https://developer.chrome.com/docs/devtools/remote-debugging/local-server.',
4242
alias: 'u',
43-
coerce: url => {
43+
coerce: (url: string) => {
4444
new URL(url);
4545
return url;
4646
},
47-
})
48-
.option('headless', {
49-
type: 'boolean',
50-
description: 'Whether to run in headless (no UI) mode',
47+
},
48+
headless: {
49+
type: 'boolean' as const,
50+
description: 'Whether to run in headless (no UI) mode.',
5151
default: false,
52-
})
53-
.option('executablePath', {
54-
type: 'string',
55-
description: 'Path to custom Chrome executable',
52+
},
53+
executablePath: {
54+
type: 'string' as const,
55+
description: 'Path to custom Chrome executable.',
5656
conflicts: 'browserUrl',
5757
alias: 'e',
58-
})
59-
.option('isolated', {
60-
type: 'boolean',
58+
},
59+
isolated: {
60+
type: 'boolean' as const,
6161
description:
6262
'If specified, creates a temporary user-data-dir that is automatically cleaned up after the browser is closed.',
6363
default: false,
64-
})
65-
.option('customDevtools', {
66-
type: 'string',
67-
description: 'Path to custom DevTools',
64+
},
65+
customDevtools: {
66+
type: 'string' as const,
67+
description: 'Path to custom DevTools.',
6868
hidden: true,
6969
conflicts: 'browserUrl',
7070
alias: 'd',
71-
})
72-
.option('channel', {
73-
type: 'string',
74-
description: 'System installed browser channel to use.',
75-
choices: ['stable', 'canary', 'beta', 'dev'],
71+
},
72+
channel: {
73+
type: 'string' as const,
74+
description: 'Specify a different Chrome channel that should be used.',
75+
choices: ['stable', 'canary', 'beta', 'dev'] as const,
7676
conflicts: ['browserUrl', 'executablePath'],
77-
})
78-
.option('logFile', {
79-
type: 'string',
80-
describe: 'Save the logs to file',
77+
default: 'stable',
78+
},
79+
logFile: {
80+
type: 'string' as const,
81+
describe: 'Save the logs to file.',
8182
hidden: true,
82-
})
83+
},
84+
};
85+
86+
const yargsInstance = yargs(hideBin(process.argv))
87+
.scriptName('npx chrome-devtools-mcp@latest')
88+
.options(cliOptions)
8389
.check(args => {
8490
// We can't set default in the options else
8591
// Yargs will complain
@@ -99,11 +105,11 @@ export const yargsInstance = yargs(hideBin(process.argv))
99105
['$0 --channel stable', 'Use stable Chrome installed on this system'],
100106
['$0 --logFile /tmp/log.txt', 'Save logs to a file'],
101107
['$0 --help', 'Print CLI options'],
102-
])
108+
]);
103109

104-
.help();
105110
export const args = yargsInstance
106111
.wrap(Math.min(120, yargsInstance.terminalWidth()))
112+
.help()
107113
.parseSync();
108114

109115
if (args.logFile) {

0 commit comments

Comments
 (0)