Skip to content

Run Playwright MCP in non-headless mode with Xvfb #3

@robcoward

Description

@robcoward

Summary

Some websites detect and block headless browsers via navigator properties, canvas fingerprinting, and WebGL capability checks. Running Playwright in headed mode with Xvfb provides a real rendering pipeline that bypasses these detections. The official playwright/mcp image already ships with Xvfb and X11 libraries.

This is the errand-desktop counterpart to the same change in the errand backend repo.

Changes Required

  • Override the Playwright MCP container entrypoint to start Xvfb before the MCP server process
  • Remove the --headless flag from command args
  • Set DISPLAY=:99 environment variable for the Xvfb virtual display
  • Add ShmSize support to ContainerConfig and DockerRuntime for Chrome shared memory (2GB)
  • Entrypoint becomes: sh -c "Xvfb :99 ... & sleep 1 && DISPLAY=:99 exec node /app/cli.js ..."

Files Affected

  • ContainerEngine.swift — Command override for playwright service
  • ContainerRuntime.swift — Add shmSize to ContainerConfig
  • DockerRuntime.swift — Pass ShmSize in HostConfig

Notes

  • ~100-150MB more memory per Playwright container, plus 2GB shared memory allocation
  • The Playwright MCP server interface and port remain identical

OpenSpec Change

merge-worker-add-playwright - 4/6 tasks complete

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions