mcp-playwright icon indicating copy to clipboard operation
mcp-playwright copied to clipboard

Browser window not starting in headed mode

Open maaft opened this issue 8 months ago β€’ 1 comments

I'm using playwright mcp with cursor IDE.

It calls playwright_navigate with the following payload:

{
  "url": "http://localhost:5173/"
}

This is the error I'm getting:

Failed to initialize browser: browserType.launch: Target page, context or browser has been closed
Browser logs:

╔════════════════════════════════════════════════════════════════════════════════════════════════╗
β•‘ Looks like you launched a headed browser without having a XServer running.                     β•‘
β•‘ Set either 'headless: true' or use 'xvfb-run <your-playwright-app>' before running Playwright. β•‘
β•‘                                                                                                β•‘
β•‘ <3 Playwright Team                                                                             β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
Call log:
[2m  - <launching> /home/foobar/.cache/ms-playwright/chromium-1161/chrome-linux/chrome --disable-field-trial-config --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AcceptCHFrame,AutoExpandDetailsElement,AvoidUnnecessaryBeforeUnloadCheckSync,CertificateTransparencyComponentUpdater,DeferRendererTasksAfterInput,DestroyProfileOnBrowserClose,DialMediaRouteProvider,ExtensionManifestV2Disabled,GlobalMediaControls,HttpsUpgrades,ImprovedCookieControls,LazyFrameLoading,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --unsafely-disable-devtools-self-xss-warnings --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-QKMTVD --remote-debugging-pipe --no-startup-window[22m
[2m  - <launched> pid=7678[22m
[2m  - [pid=7678][err] [7678:7678:0326/082253.823227:ERROR:ozone_platform_x11.cc(245)] Missing X server or $DISPLAY[22m
[2m  - [pid=7678][err] [7678:7678:0326/082253.823251:ERROR:env.cc(257)] The platform failed to initialize.  Exiting.[22m
. Please try again.

I'm running this on a Desktop Ubuntu 22.04 machine.

Aferwards, cursor will call it in headless mode which seems to be working, but I'd like to see a browser window to follow the process.

Any idea how I can debug this?

maaft avatar Mar 26 '25 07:03 maaft

Update: Initially, i've installed it via smithery.

Now I cloned this repo directly and conifigured cursor to use my local version of playwright-mcp.

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": [
        "--directory",
        "/your-playwright-mcp-server-clone-directory",
        "run",
        "@executeautomation/playwright-mcp-server"
      ]
    }
  }
}

And violΓ‘ - it works and opens the browser window.

Not sure why it doesn't work with smithery.

maaft avatar Mar 26 '25 08:03 maaft

Great, ideally it should be working, not sure why not working though. Thanks for reporting !

executeautomation avatar Mar 26 '25 16:03 executeautomation