Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, YargsOptions>;

export function parseArguments(version: string, argv = process.argv) {
Expand Down
8 changes: 8 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
24 changes: 24 additions & 0 deletions tests/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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);
});
});