diff --git a/src/cli.ts b/src/cli.ts index db2680587..be691dfb0 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -178,6 +178,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; export function parseArguments(version: string, argv = process.argv) { diff --git a/src/main.ts b/src/main.ts index 84bb6d9b5..0d3bf7e7a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -98,6 +98,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 1312e630b..e46dee64d 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 () => { @@ -222,4 +224,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); + }); });