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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ The Chrome DevTools MCP server supports the following configuration option:
If enabled, ignores errors relative to self-signed and expired certificates. Use with caution.
- **Type:** boolean

- **`--chromeArg`**
Additional arguments for Chrome. Only applies when Chrome is launched by chrome-devtools-mcp.
- **Type:** array

<!-- END AUTO GENERATED OPTIONS -->

Pass them via the `args` property in the JSON configuration. For example:
Expand Down
6 changes: 1 addition & 5 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export async function ensureBrowserConnected(options: {
interface McpLaunchOptions {
acceptInsecureCerts?: boolean;
executablePath?: string;
customDevTools?: string;
channel?: Channel;
userDataDir?: string;
headless: boolean;
Expand All @@ -75,7 +74,7 @@ interface McpLaunchOptions {
}

export async function launch(options: McpLaunchOptions): Promise<Browser> {
const {channel, executablePath, customDevTools, headless, isolated} = options;
const {channel, executablePath, headless, isolated} = options;
const profileDirName =
channel && channel !== 'stable'
? `chrome-profile-${channel}`
Expand All @@ -98,9 +97,6 @@ export async function launch(options: McpLaunchOptions): Promise<Browser> {
...(options.args ?? []),
'--hide-crash-restore-bubble',
];
if (customDevTools) {
args.push(`--custom-devtools-frontend=file://${customDevTools}`);
}
if (headless) {
args.push('--screen-info={3840x2160}');
}
Expand Down
18 changes: 10 additions & 8 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ export const cliOptions = {
'If specified, creates a temporary user-data-dir that is automatically cleaned up after the browser is closed.',
default: false,
},
customDevtools: {
type: 'string',
description: 'Path to custom DevTools.',
hidden: true,
conflicts: 'browserUrl',
alias: 'd',
},
channel: {
type: 'string',
description:
Expand Down Expand Up @@ -89,10 +82,15 @@ export const cliOptions = {
description: `If enabled, ignores errors relative to self-signed and expired certificates. Use with caution.`,
},
experimentalDevtools: {
type: 'boolean' as const,
type: 'boolean',
describe: 'Whether to enable automation over DevTools targets',
hidden: true,
},
chromeArg: {
type: 'array',
describe:
'Additional arguments for Chrome. Only applies when Chrome is launched by chrome-devtools-mcp.',
},
} satisfies Record<string, YargsOptions>;

export function parseArguments(version: string, argv = process.argv) {
Expand Down Expand Up @@ -122,6 +120,10 @@ export function parseArguments(version: string, argv = process.argv) {
'$0 --viewport 1280x720',
'Launch Chrome with the initial viewport size of 1280x720px',
],
[
`$0 --chrome-arg='--no-sandbox' --chrome-arg='--disable-setuid-sandbox'`,
'Launch Chrome without sandboxes. Use with caution.',
],
]);

return yargsInstance
Expand Down
3 changes: 1 addition & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ server.server.setRequestHandler(SetLevelRequestSchema, () => {

let context: McpContext;
async function getContext(): Promise<McpContext> {
const extraArgs: string[] = [];
const extraArgs: string[] = (args.chromeArg ?? []).map(String);
if (args.proxyServer) {
extraArgs.push(`--proxy-server=${args.proxyServer}`);
}
Expand All @@ -82,7 +82,6 @@ async function getContext(): Promise<McpContext> {
: await ensureBrowserLaunched({
headless: args.headless,
executablePath: args.executablePath,
customDevTools: args.customDevtools,
channel: args.channel as Channel,
isolated: args.isolated,
logFile,
Expand Down
18 changes: 18 additions & 0 deletions tests/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,22 @@ describe('cli args parsing', () => {
},
});
});

it('parses viewport', async () => {
const args = parseArguments('1.0.0', [
'node',
'main.js',
`--chrome-arg='--no-sandbox'`,
`--chrome-arg='--disable-setuid-sandbox'`,
]);
assert.deepStrictEqual(args, {
_: [],
headless: false,
isolated: false,
$0: 'npx chrome-devtools-mcp@latest',
channel: 'stable',
'chrome-arg': ['--no-sandbox', '--disable-setuid-sandbox'],
chromeArg: ['--no-sandbox', '--disable-setuid-sandbox'],
});
});
});