Playwright MCP for Claude Code

How Playwright MCP supports Claude Code frontend work with browser inspection, screenshots, UI verification, and safe local testing.

Playwright MCP is useful when Claude Code needs to inspect a real browser, click through UI states, capture screenshots, or prove that a frontend change actually renders. It turns visual verification into a repeatable workflow instead of a vague "looks fine" step.

Last checked on May 24, 2026. Playwright MCP server options, browser requirements, and command flags may change. Verify the current Playwright MCP docs before standardizing a team workflow.

When Playwright MCP Is Worth Adding

Use Playwright MCP for frontend and browser-facing work:

  • Open a local page after changing UI.
  • Capture desktop and mobile screenshots.
  • Click through navigation, forms, modals, menus, and authenticated flows.
  • Reproduce a visual or interaction bug.
  • Check that text does not overflow in key viewports.
  • Confirm canvas, animation, image, or chart rendering.

Skip it for backend-only edits, simple static copy changes, or situations where a plain unit test already proves the behavior.

Setup Shape

Playwright documents MCP setup directly. The common stdio shape for Claude Code is:

claude mcp add --transport stdio playwright -- npx @playwright/mcp@latest

Some environments may need browser installation, custom executable paths, or project-specific launch flags. Keep those details in team setup notes rather than scattering them across prompts.

A Good Visual Verification Flow

  1. Build or run the local app.
  2. Open the target URL through Playwright MCP.
  3. Check the console for runtime errors.
  4. Capture a desktop screenshot.
  5. Capture a mobile screenshot.
  6. Interact with the key controls.
  7. Summarize what was verified and what remains untested.

This is especially important for Claude Code UI work because code can compile while the page is visually broken.

What to Check

CheckWhy it matters
Page statusConfirms the route and assets load
Console errorsCatches hydration, runtime, and asset problems
Text wrappingPrevents mobile overflow and clipped labels
Primary interactionConfirms buttons, menus, forms, and links work
Responsive layoutEnsures desktop polish did not break mobile
Screenshot evidenceGives the user something concrete to review

Safe Usage Rules

  • Prefer local or staging URLs.
  • Avoid production admin pages unless the test is explicitly approved.
  • Do not run destructive actions against real customer data.
  • Keep authentication state separate from unrelated projects.
  • Treat screenshots as potentially sensitive if they contain user or internal data.
  • Reset test data after flows that create records.

Prompt Patterns

NeedPrompt pattern
UI check"Open /en/faqs, check console errors, and capture desktop plus mobile screenshots."
Interaction"Click the menu, search box, and primary CTA, then report any broken state."
Regression"Compare the current page against the expected layout: left nav, article body, right TOC."
Mobile polish"Use a 390px viewport and check text overflow, tap targets, and sticky headers."

Common Failure Modes

SymptomLikely causeFix
Browser does not launchMissing browser dependency or wrong executable pathInstall browsers or configure the executable path
Page is blankApp server not running, wrong port, or asset copy mismatchRestart the app and verify the route with curl
Hydration errorServer and client render different markupReproduce in dev mode and remove dynamic first-render differences
Screenshot differs by runAnimations, loading states, or unstable dataWait for network idle and stable selectors
Test mutates productionWrong base URL or authenticated stateUse staging/local and separate test credentials

Official Sources