[BUG] Playwright MCP frequently fails

Status Fixed / completed
Maintainer reply None cached
Activity 6 comments · opened May 28, 2025 · 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 ↗

6 Comments

swombat · 1 year ago

I asked Claude to detail why playwright is failing:

⏺ Let me provide detailed debug information about the Playwright issues I'm encountering:

  Playwright Tool Availability Issues

  1. Initial Tool That Worked

  mcp__playwright__browser_tab_new
  This tool worked initially and successfully opened a new tab with the login page.

  2. Tools That Failed

  After the initial success, these tools all returned "No such tool available" errors:

  mcp__playwright__browser_wait_for_page_load
  mcp__playwright__browser_snapshot
  mcp__playwright__browser_tab_current
  mcp__playwright__browser_navigate
  mcp__playwright__browser_goto
  mcp__playwright__browser_tab_navigate

  3. Working Tools

  These tools continued to work:
  mcp__playwright__browser_type - Successfully filled in email and password fields
  mcp__playwright__browser_click - Clicked the Sign In button (though unclear if it completed)

  4. The Core Issue

  The main problem seems to be:
  - I can interact with elements (type, click)
  - But I cannot check the current state of the page after interactions
  - I cannot navigate to new URLs directly
  - I cannot wait for page loads or get snapshots to see what happened

  5. Expected Behavior vs Actual

  Expected: After clicking "Sign In", I should be able to:
  1. Wait for the page to load/redirect
  2. Check if login was successful
  3. Navigate to the Pod Filings report URL
  4. Take a snapshot to verify the page content

  Actual: After clicking "Sign In":
  1. No way to verify if login succeeded
  2. No way to navigate to the target page
  3. No way to check current page state

  6. Specific Error Messages

  All the failed tools returned identical error messages:
  Error: No such tool available: mcp__playwright__[tool_name]

  7. Context

  This seems to be an inconsistency in the MCP Playwright tool availability - some tools work while others that should be basic functionality (like navigation and page state checking) are not
  available.

  Would this information help you debug the Playwright MCP server and file the bug report with Anthropic?

> Very helpful... but please try again from scratch once more, opening a new playwright browser via MCP, logging in, going to the reports url... document how it goes and try and identify when
  which things stop working. Then print this out for debug purposes.

⏺ I'll document the entire Playwright session from scratch, testing each step to identify exactly when and where things break. Let me start fresh:

  Playwright Debug Session - Fresh Start

  Step 1: Opening New Browser Tab

  Tool: mcp__playwright__browser_tab_new
  URL: http://localhost:4000

⏺ RESULT: FAILED immediately
  - The tool that worked earlier is now completely unavailable
  - This suggests the MCP Playwright server may have stopped or disconnected

  Step 2: Try Alternative Browser Opening

  Let me check if any playwright tools are available:

⏺ RESULT: FAILED

  Step 3: Try Basic Playwright Commands

⏺ RESULT: FAILED

  Step 4: Try Different Naming Patterns

⏺ RESULT: FAILED

⏺ RESULT: FAILED

  Debug Summary

  Timeline of Tool Availability:

  1. Earlier in this conversation: mcp__playwright__browser_tab_new worked successfully
  2. Earlier in this conversation: mcp__playwright__browser_type worked successfully
  3. Earlier in this conversation: mcp__playwright__browser_click worked successfully
  4. Now: ALL playwright tools return "No such tool available"

  Key Observations:

  1. Complete Tool Disappearance: Every single playwright-related tool has become unavailable
  2. No Gradual Failure: It's not that some tools work and others don't - they're ALL gone
  3. Timing: The tools were available and working approximately 10-15 minutes ago in this same conversation
  4. No Error Context: The error message gives no indication of why the tools disappeared

  Possible Causes:

  1. MCP Server Crash: The Playwright MCP server may have crashed or disconnected
  2. Tool Registration Issue: The tools may have been unregistered from the MCP system
  3. Resource/Memory Issue: The Playwright browser instances may have consumed too much memory
  4. Connection Timeout: The MCP connection to Playwright may have timed out
  5. Service Restart: An underlying service restart may have cleared the tool registry

  Impact:

  - Cannot test the Pod Filings report implementation
  - Cannot verify if the code actually works in the browser
  - Cannot complete the user's request to test the functionality

  This appears to be a complete failure of the MCP Playwright integration rather than individual tool issues.

Hope the above helps to debug this...

swombat · 1 year ago

Ok, I figured it out.

For future possible others who hit this issue... the problem is the MCP Playwright installed by Claude Desktop isn't any good. It was using playwright@latest and that was downloading a beta version that was buggy.

Instead, use one of the releases on https://executeautomation.github.io/mcp-playwright/docs/intro - I ended up using npm install -g @executeautomation/playwright-mcp-server to install it.

And then put this in your ~/.claude.json file:

      "mcpServers": {
        "playwright": {
          "command": "npx",
          "args": [
            "-y",
            "@executeautomation/playwright-mcp-server"
          ]
        }
      },

Since doing this, MCP Playwright now works reliably. Closing the issue.

jounih · 1 year ago

getting this issue also - would be nice to be able to use the official microsoft playwright mcp server

swombat · 1 year ago
getting this issue also - would be nice to be able to use the official microsoft playwright mcp server

Did you see my fix @jounih ?

triwats · 1 year ago

For me, my issue was the environment that I've been using. When I resumed the session, I got the error due to my use of nvm:

  1. Start claude
  2. Enter bash mode (!) and run your nvm command (e.g. nvm use --lts)
  3. Run /mcp add playwright npx @playwright/mcp@latest

---

❯ claude            
╭───────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code!                         │
│                                                   │
│   /help for help, /status for your current setup  │
│                                                   │
│   cwd: /Users/triwats/src/climbing.pro            │
╰───────────────────────────────────────────────────╯

 ※ Tip: Hit shift+tab to cycle between default mode, auto-accept edit mode, and plan mode

! nvm use --lts
  ⎿  Now using node v22.14.0 (npm v11.2.0)
╭────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Manage MCP servers                                                                                 │
│                                                                                                    │
│ ❯ 1. playwright  ✔ connected · Enter to view details                                               │
╰───────────────────────────────────────────────────────────
github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.