microsoft/playwright · error · Error
Device emulation is not supported with cdpEndpoint.
Error message
Device emulation is not supported with cdpEndpoint.
What it means
Thrown by configFromCLIOptions() when a device preset is active (either --device or --mobile) and --cdpEndpoint is also set. Device emulation is applied as context options on a freshly created context, but a CDP endpoint connects to an already-running browser whose context Playwright does not own, so the emulation options cannot be honored reliably.
Source
Thrown at packages/playwright-core/src/tools/mcp/config.ts:316
headless: cliOptions.headless,
};
// --sandbox was passed, enable the sandbox
// --no-sandbox was passed, disable the sandbox
if (cliOptions.sandbox !== undefined)
launchOptions.chromiumSandbox = cliOptions.sandbox;
let device = cliOptions.device;
if (cliOptions.mobile) {
if (device)
throw new Error('Cannot use --mobile together with --device, pick one.');
if (browserName === 'firefox')
throw new Error('--mobile is not supported with the Firefox browser.');
device = browserName === 'webkit' ? 'iPhone 17' : 'Pixel 10';
}
if (device && cliOptions.cdpEndpoint)
throw new Error('Device emulation is not supported with cdpEndpoint.');
// Context options
const contextOptions: playwrightTypes.BrowserContextOptions = device ? playwright.devices[device] : {};
if (cliOptions.proxyServer) {
const proxy: playwrightTypes.LaunchOptions['proxy'] = { server: cliOptions.proxyServer };
if (cliOptions.proxyBypass)
proxy.bypass = cliOptions.proxyBypass;
// Set on both to ensure CLI takes precedence over any proxy set in the config file
// (launchOptions.proxy applies at browser launch, contextOptions.proxy at context creation).
launchOptions.proxy = proxy;
contextOptions.proxy = proxy;
}
if (cliOptions.storageState)
contextOptions.storageState = cliOptions.storageState;
if (cliOptions.userAgent)View on GitHub (pinned to c8fc3bf8d3)
Solutions
- Drop --device/--mobile when connecting via --cdp-endpoint, and configure emulation inside the target browser instead.
- If you need device emulation, remove --cdp-endpoint so Playwright launches and owns the browser context.
- If both are required, launch a browser with the device profile locally and expose its CDP endpoint yourself, then connect without --device.
Example fix
// before playwright mcp --device "Pixel 10" --cdp-endpoint ws://localhost:9222 // after (own the browser) playwright mcp --device "Pixel 10" // after (use existing browser, no emulation) playwright mcp --cdp-endpoint ws://localhost:9222
Defensive patterns
Strategy: validation
Validate before calling
if ((cliOptions.device || cliOptions.mobile) && cliOptions.cdpEndpoint) {
throw new Error('Device emulation cannot be combined with --cdp-endpoint.');
} Type guard
function deviceEmulationActive(opts: { device?: string; mobile?: boolean }): boolean {
return Boolean(opts.device) || Boolean(opts.mobile);
} Prevention
- Decide upfront whether you own the browser (launch + emulate) or connect to one (cdp).
- Validate CLI options in a wrapper to reject incompatible combinations before launch.
- Avoid templating device and cdp-endpoint from independent config sources.
When it happens
Trigger: Combining `--device "Pixel 10" --cdp-endpoint ws://host:9222` or `--mobile --cdp-endpoint ...` on the MCP CLI.
Common situations: Wanting to drive an existing Chrome instance (e.g. for debugging or a pre-launched browser) while also wanting mobile emulation; leftover --device from a previous run combined with a new --cdp-endpoint.
Related errors
- Cannot use --mobile together with --device, pick one.
- --mobile is not supported with the Firefox browser.
- Invalid resolution format: use ${name}="800x600"
- Invalid ${name}: ${value}. Valid values are: ${options.join(
- Init script file does not exist: ${script}
AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12).
Data as JSON: /api/errors/2164586497491412.
Report an issue: GitHub.