{"record":{"id":"9700a4ab2116e688","repo":"microsoft/playwright","slug":"cannot-use-mobile-together-with-device-pick-o","errorCode":null,"errorMessage":"Cannot use --mobile together with --device, pick one.","messagePattern":"Cannot use --mobile together with --device, pick one\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/tools/mcp/config.ts","lineNumber":309,"sourceCode":"function configFromCLIOptions(cliOptions: CLIOptions): Config & { configFile?: string } {\n  const { browserName, channel } = resolveBrowserParam(cliOptions.browser);\n\n  // Launch options\n  const launchOptions: playwrightTypes.LaunchOptions = {\n    channel,\n    executablePath: cliOptions.executablePath,\n    headless: cliOptions.headless,\n  };\n\n  // --sandbox was passed, enable the sandbox\n  // --no-sandbox was passed, disable the sandbox\n  if (cliOptions.sandbox !== undefined)\n    launchOptions.chromiumSandbox = cliOptions.sandbox;\n\n  let device = cliOptions.device;\n  if (cliOptions.mobile) {\n    if (device)\n      throw new Error('Cannot use --mobile together with --device, pick one.');\n    if (browserName === 'firefox')\n      throw new Error('--mobile is not supported with the Firefox browser.');\n    device = browserName === 'webkit' ? 'iPhone 17' : 'Pixel 10';\n  }\n\n  if (device && cliOptions.cdpEndpoint)\n    throw new Error('Device emulation is not supported with cdpEndpoint.');\n\n  // Context options\n  const contextOptions: playwrightTypes.BrowserContextOptions = device ? playwright.devices[device] : {};\n\n  if (cliOptions.proxyServer) {\n    const proxy: playwrightTypes.LaunchOptions['proxy'] = { server: cliOptions.proxyServer };\n    if (cliOptions.proxyBypass)\n      proxy.bypass = cliOptions.proxyBypass;\n    // Set on both to ensure CLI takes precedence over any proxy set in the config file\n    // (launchOptions.proxy applies at browser launch, contextOptions.proxy at context creation).\n    launchOptions.proxy = proxy;","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/tools/mcp/config.ts#L291-L327","documentation":"Thrown by configFromCLIOptions() when both --mobile and --device are supplied. --mobile is a shorthand that auto-selects a device preset ('iPhone 17' for webkit, 'Pixel 10' otherwise), so it is mutually exclusive with an explicit --device name. The guard prevents two sources of device-emulation configuration from contradicting each other.","triggerScenarios":"Invoking the MCP CLI with both flags set, e.g. `--mobile --device \"iPhone 15\"`. Also reachable from a config file or env that populates both cliOptions.mobile and cliOptions.device.","commonSituations":"Copy-pasted flags from an example that used --device into a command that already had --mobile; migration from --device to --mobile without removing the old flag; a wrapper script that sets both unconditionally.","solutions":["Remove one of the two flags. Keep --device if you want a specific Playwright device descriptor, or --mobile if you want the auto-selected default preset.","If flags come from a config file or environment, audit that file for both keys being set and remove one.","Check any wrapper script or alias that appends flags automatically."],"exampleFix":"// before\nplaywright mcp --mobile --device \"iPhone 15\"\n// after (explicit device)\nplaywright mcp --device \"iPhone 15\"\n// after (auto mobile preset)\nplaywright mcp --mobile","handlingStrategy":"validation","validationCode":"if (cliOptions.mobile && cliOptions.device) {\n  throw new Error('Choose either --mobile or --device, not both.');\n}","typeGuard":"function hasMutuallyExclusiveDevice(opts: { mobile?: boolean; device?: string }): boolean {\n  return Boolean(opts.mobile) && Boolean(opts.device);\n}","tryCatchPattern":null,"preventionTips":["Document which of --mobile vs --device your project standardizes on and use only that.","Validate assembled CLI options in a wrapper script before invoking the MCP server.","Avoid blanket flag lists that get reused across different commands."],"tags":["mcp","config","cli","device-emulation","validation"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}