Skip to content

Chrome DevTools for coding agents

fix: change default screen size in headless (#299)

Alex Rudenko357db65d18f8
diff --git a/README.md b/README.md
index 4a9f6f5b..e083f1c8 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 d5a17e17..5387b3ef 100644
--- a/src/browser.ts
+++ b/src/browser.ts
@@ -99,6 +99,9 @@ export async function launch(options: McpLaunchOptions): Promise<Browser> {
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 85fcf839..909d1a21 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 3dc8eff0..b4811202 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();