Skip to content

Connect Playwright MCP to OpenCode

Browser automation over MCP from the Playwright team. Agents use it to open the built UI, take screenshots and check layouts against the design.

MCP serverOfficialChecked 2026-11-16

Before you start

  1. Step 1: Add Playwright MCP to OpenCode

    Add it from the terminal

    Run this in your project folder. It saves the server to the project's opencode.json.

    Terminal
    opencode mcp add playwright -- npx -y @playwright/mcp@latest

    Or edit the config file

    Add this to opencode.json at the project root.

    opencode.json
    {
      "$schema": "https://opencode.ai/config.json",
      "mcp": {
        "playwright": {
          "type": "local",
          "command": [
            "npx",
            "-y",
            "@playwright/mcp@latest"
          ],
          "enabled": true
        }
      }
    }
  2. Step 2: Check it's connected

    Terminal
    opencode mcp list

    Start OpenCode in the project; the server's tools are available to the agent straight away.

  3. Step 3: Try a first request

    Ask OpenCode something that only works with Playwright MCP connected:

    Say to OpenCode
    Open http://localhost:3000, take a screenshot at 375 px wide and tell me what looks broken.

If it doesn't work

  • OpenCode reads opencode.json from the project root, or ~/.config/opencode/opencode.json for every project.
  • Environment variables use the {env:NAME} syntax inside the config file.
  • Servers that need a sign-in: run opencode mcp auth <name>.