[BUG] Playwright MCP frequently fails

Resolved 💬 6 comments Opened May 28, 2025 by swombat Closed May 30, 2025

Environment

  • Platform (select one):
  • [X] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.3
  • Operating System: MacOS Sonoma 14.3.1
  • Terminal: iTerm2 in tmux

Bug Description

Playwright MCP success is... very variable.

Sometimes it works great, it takes screenshots, it verifies its own work... then Claude is superbly useful.

Other times it just can't seem to use playwright properly and so reverts to Curl.

⏺ Now I understand! According to CLAUDE.md, I need to "open a tab using the open_tab command in playwright" first. Let me use Playwright correctly to test the pages:

⏺ playwright:browser_tab_new (MCP)(url: "http://localhost:4000")…
  ⎿  Error: Error calling tool browser_tab_new: undefined

⏺ Let me first try to navigate directly since there might be a default tab:

⏺ playwright:browser_navigate (MCP)(url: "http://localhost:4000")…
  ⎿  Error: Error calling tool browser_navigate: undefined

⏺ Let me see what the correct Playwright install command is:

⏺ playwright:browser_install (MCP)
  ⎿  No open pages available. Use the "browser_navigate" tool to navigate to a page first.

⏺ This seems to be a Playwright setup issue. Let me just run a broader test suite to ensure everything is working properly and then manually verify the browser functionality:

The instructions in CLAUDE.md:

## Using Playwright

Playwright is installed and can be used to navigate to pages, test them, take screenshots, etc.

To navigate anywhere, first you need to open a tab, using the open_tab command in playwright. Then you can navigate it wherever you want.

The app is running on http://localhost:4000 - not https!

The mcp setup:

      "mcpServers": {
        "playwright": {
          "command": "npx",
          "args": [
            "@playwright/mcp@latest",
            "--headless"
          ]
        }
      },

allowed_tools:

      "allowedTools": [
        "Bash(RAILS_ENV=test rails test *)",
        "Bash(bin/rails test:*)",
        "Bash(bundle exec rails test:*)",
        "Bash(bundle show:*)",
        "Bash(cat:*)",
        "Bash(chmod:*)",
        "Bash(find:*)",
        "Bash(gem which:*)",
        "Bash(git add:*)",
        "Bash(git clone:*)",
        "Bash(git commit:*)",
        "Bash(grep:*)",
        "Bash(ls:*)",
        "Bash(mkdir:*)",
        "Bash(rails route:*)",
        "Bash(rails test:*)",
        "Bash(rake:*)",
        "Bash(rm:*)",
        "Bash(rubocop:*)",
        "Bash(ruby:*)",
        "Bash(sed:*)",
        "Bash(test/vcr_cassettes/pipedrive_*.yml)",
        "Bash(yarn build)",
        "mcp__playwright__browser_click",
        "mcp__playwright__browser_close",
        "mcp__playwright__browser_install",
        "mcp__playwright__browser_navigate",
        "mcp__playwright__browser_snapshot",
        "mcp__playwright__browser_tab_list",
        "mcp__playwright__browser_tab_new",
        "mcp__playwright__browser_take_screenshot",
        "mcp__playwright__browser_type"
      ],

Steps to Reproduce

Just try to use Playwright. Sometimes it works sometimes not. See above conversation trace.

Expected Behavior

Successfully uses Playwright.

Actual Behavior

See log trace earlier.

View original on GitHub ↗

This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗