Skip to content

Chrome DevTools for coding agents

chore: add usage statistics CLI flag (#757)

Ergün Erdoğmuşe8c9192dbdea
diff --git a/src/cli.ts b/src/cli.ts
index 985ad66b..3915b190 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -193,6 +193,13 @@ export const cliOptions = {
default: true,
describe: 'Set to false to exclude tools related to network.',
},
+ usageStatistics: {
+ type: 'boolean',
+ // Marked as `false` until the feature is ready to be enabled by default.
+ default: false,
+ hidden: true,
+ describe: 'Set to false to opt-out of usage statistics collection.',
+ },
} satisfies Record<string, YargsOptions>;
export function parseArguments(version: string, argv = process.argv) {
diff --git a/src/main.ts b/src/main.ts
index 143c7a9a..c488419a 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -102,6 +102,14 @@ const logDisclaimers = () => {
debug, and modify any data in the browser or DevTools.
Avoid sharing sensitive or personal information that you do not want to share with MCP clients.`,
);
+
+ if (args.usageStatistics) {
+ console.error(
+ `
+Google collects usage statistics to improve Chrome DevTools MCP. To opt-out, run with --no-usage-statistics.
+For more details, visit: https://github.com/ChromeDevTools/chrome-devtools-mcp#usage-statistics`,
+ );
+ }
};
const toolMutex = new Mutex();
diff --git a/tests/cli.test.ts b/tests/cli.test.ts
index c5f966cf..ccbeac8c 100644
--- a/tests/cli.test.ts
+++ b/tests/cli.test.ts
@@ -19,6 +19,8 @@ describe('cli args parsing', () => {
categoryNetwork: true,
'auto-connect': undefined,
autoConnect: undefined,
+ 'usage-statistics': false,
+ usageStatistics: false,
};
it('parses with default args', async () => {
@@ -246,4 +248,26 @@ describe('cli args parsing', () => {
autoConnect: true,
});
});
+
+ it('parses usage statistics flag', async () => {
+ // Test default (should be false)
+ const defaultArgs = parseArguments('1.0.0', ['node', 'main.js']);
+ assert.strictEqual(defaultArgs.usageStatistics, false);
+
+ // Test enabling it
+ const enabledArgs = parseArguments('1.0.0', [
+ 'node',
+ 'main.js',
+ '--usage-statistics',
+ ]);
+ assert.strictEqual(enabledArgs.usageStatistics, true);
+
+ // Test disabling it
+ const disabledArgs = parseArguments('1.0.0', [
+ 'node',
+ 'main.js',
+ '--no-usage-statistics',
+ ]);
+ assert.strictEqual(disabledArgs.usageStatistics, false);
+ });
});