Skip to content

Commit f394814

Browse files
committed
chore: support CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS env var
1 parent c7a8ae4 commit f394814

6 files changed

Lines changed: 55 additions & 22 deletions

File tree

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ Google handles this data in accordance with the [Google Privacy Policy](https://
5151

5252
Google's collection of usage statistics for Chrome DevTools MCP is independent from the Chrome browser's usage statistics. Opting out of Chrome metrics does not automatically opt you out of this tool, and vice-versa.
5353

54-
Collection is disabled if CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS or CI env variables are set.
54+
Collection is disabled if `CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS` or `CI` env variables are set.
55+
56+
## Update checks
57+
58+
By default, the server periodically checks the npm registry for updates and logs a notification when a newer version is available.
59+
You can disable these update checks by setting the `CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS` environment variable.
5560

5661
## Requirements
5762

@@ -74,7 +79,7 @@ Add the following config to your MCP client:
7479
}
7580
```
7681

77-
> [!NOTE]
82+
> [!NOTE]
7883
> Using `chrome-devtools-mcp@latest` ensures that your MCP client will always use the latest version of the Chrome DevTools MCP server.
7984
8085
If you are interested in doing only basic browser tasks, use the `--slim` mode:
@@ -143,7 +148,7 @@ claude mcp add chrome-devtools --scope user npx chrome-devtools-mcp@latest
143148

144149
**Install as a Plugin (MCP + Skills)**
145150

146-
> [!NOTE]
151+
> [!NOTE]
147152
> If you already had Chrome DevTools MCP installed previously for Claude Code, make sure to remove it first from your installation and configuration files.
148153
149154
To install Chrome DevTools MCP with skills, add the marketplace registry in Claude Code:
@@ -200,7 +205,7 @@ startup_timeout_ms = 20_000
200205

201206
<details>
202207
<summary>Command Code</summary>
203-
208+
204209
Use the Command Code CLI to add the Chrome DevTools MCP server (<a href="https://commandcode.ai/docs/mcp">MCP guide</a>):
205210

206211
```bash
@@ -402,10 +407,11 @@ qodercli mcp add -s user chrome-devtools -- npx chrome-devtools-mcp@latest
402407

403408
<details>
404409
<summary>Visual Studio</summary>
405-
406-
**Click the button to install:**
407-
408-
[<img src="https://img.shields.io/badge/Visual_Studio-Install-C16FDE?logo=visualstudio&logoColor=white" alt="Install in Visual Studio">](https://vs-open.link/mcp-install?%7B%22name%22%3A%22chrome-devtools%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22chrome-devtools-mcp%40latest%22%5D%7D)
410+
411+
**Click the button to install:**
412+
413+
[<img src="https://img.shields.io/badge/Visual_Studio-Install-C16FDE?logo=visualstudio&logoColor=white" alt="Install in Visual Studio">](https://vs-open.link/mcp-install?%7B%22name%22%3A%22chrome-devtools%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22chrome-devtools-mcp%40latest%22%5D%7D)
414+
409415
</details>
410416

411417
<details>
@@ -431,7 +437,7 @@ Check the performance of https://developers.chrome.com
431437

432438
Your MCP client should open the browser and record a performance trace.
433439

434-
> [!NOTE]
440+
> [!NOTE]
435441
> The MCP server will start the browser automatically once the MCP client uses a tool that requires a running browser instance. Connecting to the Chrome DevTools MCP server on its own will not automatically start the browser.
436442
437443
## Tools
@@ -572,7 +578,7 @@ The Chrome DevTools MCP server supports the following configuration option:
572578
- **Default:** `true`
573579

574580
- **`--usageStatistics`/ `--usage-statistics`**
575-
Set to false to opt-out of usage statistics collection. Google collects usage data to improve the tool, handled under the Google Privacy Policy (https://policies.google.com/privacy). This is independent from Chrome browser metrics. Disabled if CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS or CI env variables are set.
581+
Set to false to opt-out of usage statistics collection. Google collects usage data to improve the tool, handled under the Google Privacy Policy (https://policies.google.com/privacy). This is independent from Chrome browser metrics. Disabled if `CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS` or `CI` env variables are set.
576582
- **Type:** boolean
577583
- **Default:** `true`
578584

@@ -686,7 +692,7 @@ Make sure your browser is running. Open gemini-cli and run the following prompt:
686692
Check the performance of https://developers.chrome.com
687693
```
688694

689-
> [!NOTE]
695+
> [!NOTE]
690696
> The <code>autoConnect</code> option requires the user to start Chrome. If the user has multiple active profiles, the MCP server will connect to the default profile (as determined by Chrome). The MCP server has access to all open windows for the selected profile.
691697
692698
The Chrome DevTools MCP server will try to connect to your running Chrome
@@ -722,7 +728,7 @@ Add the `--browser-url` option to your MCP client configuration. The value of th
722728

723729
**Step 2: Start the Chrome browser**
724730

725-
> [!WARNING]
731+
> [!WARNING]
726732
> Enabling the remote debugging port opens up a debugging port on the running browser instance. Any application on your machine can connect to this port and control the browser. Make sure that you are not browsing any sensitive websites while the debugging port is open.
727733
728734
Start the Chrome browser with the remote debugging port enabled. Make sure to close any running Chrome instances before starting a new one with the debugging port enabled. The port number you choose must be the same as the one you specified in the `--browser-url` option in your MCP client configuration.

src/bin/check-latest-version.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ if (cachePath) {
2424
typeof data.version === 'string'
2525
) {
2626
await fs.mkdir(path.dirname(cachePath), {recursive: true});
27-
await fs.writeFile(
28-
cachePath,
29-
JSON.stringify({version: data.version}),
30-
);
27+
await fs.writeFile(cachePath, JSON.stringify({version: data.version}));
3128
}
3229
} catch {
3330
// Ignore errors.

src/bin/chrome-devtools-mcp-cli-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export const cliOptions = {
232232
type: 'boolean',
233233
default: true,
234234
describe:
235-
'Set to false to opt-out of usage statistics collection. Google collects usage data to improve the tool, handled under the Google Privacy Policy (https://policies.google.com/privacy). This is independent from Chrome browser metrics. Disabled if CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS or CI env variables are set.',
235+
'Set to false to opt-out of usage statistics collection. Google collects usage data to improve the tool, handled under the Google Privacy Policy (https://policies.google.com/privacy). This is independent from Chrome browser metrics. Disabled if `CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS` or `CI` env variables are set.',
236236
},
237237
clearcutEndpoint: {
238238
type: 'string',

src/bin/chrome-devtools-mcp-main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ import {VERSION} from '../version.js';
1717

1818
import {cliOptions, parseArguments} from './chrome-devtools-mcp-cli-options.js';
1919

20-
await checkForUpdates('Run `npm install chrome-devtools-mcp@latest` to update.');
20+
await checkForUpdates(
21+
'Run `npm install chrome-devtools-mcp@latest` to update.',
22+
);
2123

2224
export const args = parseArguments(VERSION);
2325

src/utils/check-for-updates.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ import {VERSION} from '../version.js';
1717
* @param message The message to display in the update notification.
1818
*/
1919
export async function checkForUpdates(message: string) {
20+
if (process.env['CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS']) {
21+
return;
22+
}
23+
2024
const cachePath = path.join(
2125
os.homedir(),
2226
'.cache',
@@ -47,7 +51,12 @@ export async function checkForUpdates(message: string) {
4751

4852
// In a separate process, check the latest available version number
4953
// and update the local snapshot accordingly.
50-
const scriptPath = path.join(import.meta.dirname, '..', 'bin', 'check-latest-version.js');
54+
const scriptPath = path.join(
55+
import.meta.dirname,
56+
'..',
57+
'bin',
58+
'check-latest-version.js',
59+
);
5160

5261
try {
5362
const child = child_process.spawn(

tests/check-for-updates.test.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import assert from 'node:assert';
88
import child_process from 'node:child_process';
9+
import type {Stats} from 'node:fs';
910
import fs from 'node:fs/promises';
1011
import os from 'node:os';
1112
import {afterEach, describe, it} from 'node:test';
@@ -20,9 +21,27 @@ describe('checkForUpdates', () => {
2021
sinon.restore();
2122
});
2223

24+
it('does nothing if CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS is set', async () => {
25+
process.env['CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS'] = 'true';
26+
27+
const warnStub = sinon.stub(console, 'warn');
28+
const spawnStub = sinon.stub(child_process, 'spawn');
29+
const readFileStub = sinon.stub(fs, 'readFile');
30+
const statStub = sinon.stub(fs, 'stat');
31+
32+
await checkForUpdates('Run `npm update` to update.');
33+
34+
assert.ok(warnStub.notCalled);
35+
assert.ok(spawnStub.notCalled);
36+
assert.ok(readFileStub.notCalled);
37+
assert.ok(statStub.notCalled);
38+
39+
delete process.env['CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS'];
40+
});
41+
2342
it('notifies if cache exists and version is different', async () => {
2443
sinon.stub(os, 'homedir').returns('/home/user');
25-
sinon.stub(fs, 'stat').resolves({mtimeMs: Date.now()} as any);
44+
sinon.stub(fs, 'stat').resolves({mtimeMs: Date.now()} as unknown as Stats);
2645
sinon.stub(fs, 'readFile').callsFake(async filePath => {
2746
if (filePath.toString().includes('latest.json')) {
2847
return JSON.stringify({
@@ -46,7 +65,7 @@ describe('checkForUpdates', () => {
4665

4766
it('does not spawn fetch process if cache is fresh', async () => {
4867
sinon.stub(os, 'homedir').returns('/home/user');
49-
sinon.stub(fs, 'stat').resolves({mtimeMs: Date.now()} as any);
68+
sinon.stub(fs, 'stat').resolves({mtimeMs: Date.now()} as unknown as Stats);
5069
sinon.stub(fs, 'readFile').callsFake(async filePath => {
5170
if (filePath.toString().includes('latest.json')) {
5271
return JSON.stringify({
@@ -66,7 +85,7 @@ describe('checkForUpdates', () => {
6685
sinon.stub(os, 'homedir').returns('/home/user');
6786
sinon.stub(fs, 'stat').resolves({
6887
mtimeMs: Date.now() - 25 * 60 * 60 * 1000, // 25 hours ago
69-
} as any);
88+
} as unknown as Stats);
7089
sinon.stub(fs, 'readFile').callsFake(async filePath => {
7190
if (filePath.toString().includes('latest.json')) {
7291
return JSON.stringify({

0 commit comments

Comments
 (0)