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: 0 additions & 4 deletions packages/playwright-core/src/tools/mcp/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ export function decorateMCPCommand(command: Command) {
.option('--viewport-size <size>', 'specify browser viewport size in pixels, for example "1280x720"', resolutionParser.bind(null, '--viewport-size'))
.addOption(new ProgramOption('--vision', 'Legacy option, use --caps=vision instead').hideHelp())
.action(async options => {

// normalize the --no-sandbox option: sandbox = true => nothing was passed, sandbox = false => --no-sandbox was passed.
options.sandbox = options.sandbox === true ? undefined : false;

@pavelfeldman Pavel Feldman (pavelfeldman) Aug 17, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should erase options.sandbox if there is no 'sandbox' in the argv instead.

@yury-s Yury Semikhatsky (yury-s) Aug 17, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's true, missing --no-sandbox results in undefined:

yurys:~/playwright(main)$ node packages/playwright-core/lib/entry/mcp.js --no-sandbox
sandbox: false
yurys:~/playwright(main)$ node packages/playwright-core/lib/entry/mcp.js             
sandbox: undefined
yurys:~/playwright(main)$ node packages/playwright-core/lib/entry/mcp.js --sandbox   
sandbox: true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must have changed during the monorepo migration (minimist => commander)


setupExitWatchdog();

if (options.vision) {
Expand Down
37 changes: 37 additions & 0 deletions tests/mcp/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,40 @@ test('browser_get_config returns merged config from file, env and cli', async ({
// From CLI arg (--isolated).
expect(config.browser.isolated).toBe(true);
});

test.describe('chromiumSandbox', () => {
test.skip(({ mcpBrowser }) => mcpBrowser !== 'chrome', 'Channel-agnostic tests.');

test('config file value is respected', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright-mcp/issues/1716' } }, async ({ startClient }) => {
const { client } = await startClient({
config: {
capabilities: ['config'],
browser: { launchOptions: { chromiumSandbox: true } },
},
});
const config = JSON.parse(parseResponse(await client.callTool({ name: 'browser_get_config' })).result);
expect(config.browser.launchOptions.chromiumSandbox).toBe(true);
});

test('--no-sandbox overrides config file value', async ({ startClient }) => {
const { client } = await startClient({
config: {
capabilities: ['config'],
browser: { launchOptions: { chromiumSandbox: true } },
},
args: ['--no-sandbox'],
});
const config = JSON.parse(parseResponse(await client.callTool({ name: 'browser_get_config' })).result);
expect(config.browser.launchOptions.chromiumSandbox).toBe(false);
});

test('--sandbox enables the sandbox', async ({ startClient }) => {
const { client } = await startClient({
config: { capabilities: ['config'] },
args: ['--browser=chromium', '--sandbox'],
});
const config = JSON.parse(parseResponse(await client.callTool({ name: 'browser_get_config' })).result);
expect(config.browser.launchOptions.channel).toBe('chrome-for-testing');
expect(config.browser.launchOptions.chromiumSandbox).toBe(true);
});
});
Loading