Cover image
Try Now
2025-03-31

该项目提供了一个Docker组成的环境,可以运行“@Playwright/MCP”服务器。

3 years

Works with Finder

2

Github Watches

1

Github Forks

0

Github Stars

Playwright MCP Docker Environment

日本語版はこちら (Japanese version here)

This project provides a Docker Compose environment to run the @playwright/mcp server. It allows you to easily set up and manage the Playwright MCP server for use with clients like Cline or Cursor.

Prerequisites

  • Docker
  • Docker Compose

Setup

  1. Clone the repository:
    git clone <repository-url>
    cd playwright-mcp-docker
    
  2. Create .env file: Copy the sample environment file:
    cp .env.sample .env
    
  3. Configure .env: Edit the .env file to adjust settings according to your environment and preferences:
    • MCP_HOST_PORT: The port on the host machine that the MCP server will be accessible through (default: 8931).
    • HEADLESS: Set to true for headless mode (no browser GUI) or false for headed mode (requires GUI setup). Default is true.
    • (Headed Mode Only) DISPLAY, WAYLAND_DISPLAY, XDG_RUNTIME_DIR: Environment variables needed for GUI applications in Linux environments (especially WSLg). Defaults are provided.
    • (Headed Mode Only) X11_HOST_PATH, WSLG_HOST_PATH: Host paths for X11 and WSLg sockets/directories. Defaults are provided. Adjust if your system configuration differs. For Windows Docker accessing WSL paths, use the \\wsl.localhost\DistroName\... format (see .env.sample).

Running the Server

  1. Build and start the container:

    docker-compose up --build -d
    

    The --build flag is only needed the first time or when Dockerfile changes. The -d flag runs the container in detached mode (in the background).

  2. Configure MCP Client (e.g., VSCode/Cline):

    • Add or enable an MCP server named playwright_sse (or any name you prefer).
    • Set the connection type to SSE.
    • Set the URL to http://localhost:<MCP_HOST_PORT>/sse (replace <MCP_HOST_PORT> with the value from your .env file, e.g., http://localhost:8931/sse).
    • Example client configuration (filename depends on the client):
    {
      "mcpServers": {
        "playwright_sse": { // Server name is arbitrary
          "url": "http://localhost:8931/sse" // Match the port number in .env
        }
      }
    }
    

Configuration Details

  • .env file: Manages environment-specific settings like ports, headless mode, and paths for headed mode.
  • docker-compose.yml: Defines the Docker service, reads variables from .env, sets up port mapping and volumes.
  • Dockerfile: Defines the Docker image, installs @playwright/mcp and its dependencies (including Chrome).
  • entrypoint.sh: Script that runs when the container starts, passing the correct arguments (--headless or --port) to the npx @playwright/mcp command based on the HEADLESS environment variable.

Switching Modes

  • Headless Mode: Set HEADLESS=true in .env. Restart the container: docker-compose up -d.
  • Headed Mode: Set HEADLESS=false in .env. Ensure your host environment (e.g., WSLg or X Server) is correctly set up. Restart the container: docker-compose up -d.

Headed Mode Notes (WSLg)

  • If you are using WSLg on Windows, the default settings in docker-compose.yml and the WSL2-specific paths in .env.sample should generally work. Ensure the paths in your .env match your WSL distribution name if it's not Ubuntu.
  • If you are not using WSLg (e.g., standard Linux desktop or macOS/Windows with a separate X Server), you will need to adjust the DISPLAY variable and potentially the volume mounts (X11_HOST_PATH) in your .env file according to your X Server setup.

Stopping the Server

docker-compose down

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Lists Tailwind CSS classes in monospaced font

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • Yasir Eryilmaz
  • AI scriptwriting assistant for short, engaging video content.

  • https://appia.in
  • Siri Shortcut Finder – your go-to place for discovering amazing Siri Shortcuts with ease

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • HiveNexus
  • 一个适用于中小型团队的AI聊天机器人,支持DeepSeek,Open AI,Claude和Gemini等车型。 专为中小团队设计的ai聊天应用,支持deepSeek,打开ai,claude,双子座等模型。

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

    Reviews

    4 (1)
    Avatar
    user_ETRTbOgX
    2025-04-17

    As a devoted user of the mcp application, I highly recommend the "playwright-mcp-docker" by iuill. This excellent tool integrates seamlessly with my testing workflows and has significantly improved our automation processes. The setup is straightforward, and the performance is remarkable. For anyone looking to enhance their automation capabilities with Docker and Playwright, this is a must-try. Check it out on GitHub!