From bc22d1b80c0fa40c870eed42db48ed1985cd2eb6 Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Tue, 7 Oct 2025 15:23:08 +0200 Subject: [PATCH] fix: change default screen size in headless --- README.md | 2 +- src/browser.ts | 3 +++ src/cli.ts | 2 +- tests/browser.test.ts | 8 ++++---- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4a9f6f5bc..e083f1c8b 100644 --- a/README.md +++ b/README.md @@ -280,7 +280,7 @@ The Chrome DevTools MCP server supports the following configuration option: - **Type:** string - **`--viewport`** - Initial viewport size for the Chrome instances started by the server. For example, `1280x720` + Initial viewport size for the Chrome instances started by the server. For example, `1280x720`. In headless mode, max size is 3840x2160px. - **Type:** string - **`--proxyServer`** diff --git a/src/browser.ts b/src/browser.ts index d5a17e177..5387b3eff 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -99,6 +99,9 @@ export async function launch(options: McpLaunchOptions): Promise { if (customDevTools) { args.push(`--custom-devtools-frontend=file://${customDevTools}`); } + if (headless) { + args.push('--screen-info={3840x2160}'); + } let puppeteerChannel: ChromeReleaseChannel | undefined; if (!executablePath) { puppeteerChannel = diff --git a/src/cli.ts b/src/cli.ts index 85fcf839f..909d1a21e 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -65,7 +65,7 @@ export const cliOptions = { viewport: { type: 'string', describe: - 'Initial viewport size for the Chrome instances started by the server. For example, `1280x720`', + 'Initial viewport size for the Chrome instances started by the server. For example, `1280x720`. In headless mode, max size is 3840x2160px.', coerce: (arg: string | undefined) => { if (arg === undefined) { return; diff --git a/tests/browser.test.ts b/tests/browser.test.ts index 3dc8eff04..b4811202b 100644 --- a/tests/browser.test.ts +++ b/tests/browser.test.ts @@ -52,8 +52,8 @@ describe('browser', () => { userDataDir: folderPath, executablePath: executablePath(), viewport: { - width: 700, - height: 500, + width: 1501, + height: 801, }, }); try { @@ -62,8 +62,8 @@ describe('browser', () => { return {width: window.innerWidth, height: window.innerHeight}; }); assert.deepStrictEqual(result, { - width: 700, - height: 500, + width: 1501, + height: 801, }); } finally { await browser.close();