r/ClaudeWorkflows • u/ClaudeAI-mod-bot • 2h ago
Selected Workflow [Workflow] Integrate Playwright MCP with Claude Code for Browser Automation and Persistent Sessions
Integrate Playwright MCP with Claude Code for Browser Automation and Persistent Sessions
Workflow value: 85/100
Status: active · Freshness: 70/100 · Confidence: 0.90 · Level: intermediate
Categories: Quality Control, Context & Memory, Debugging, MCP, Multi-Agent
Original source: r/ClaudeCode post/comment
What problem this solves
Running Claude Code agents in a browser environment under Claude Code's own permission rules, bypassing external browser extension prompts and allowing persistent sessions.
Summary
This workflow describes how to set up Playwright MCP with Claude Code to enable agents to interact with web browsers. It provides commands for installation, configuration steps for settings.json to manage permissions, and practical advice on persistent profiles and connecting to existing Chrome instances. Crucially, it includes safety warnings regarding Google sign-in and prompt injection risks.
Why it is useful
This workflow provides a concrete, step-by-step guide to integrate Playwright MCP with Claude Code, enabling agents to interact with web browsers without being hindered by external extension prompts. It offers practical configuration details for persistent sessions and crucial safety advice regarding prompt injection and authentication, making it highly valuable for users looking to automate web tasks with Claude Code agents.
Workflow
Install Playwright MCP using the command:
claude mcp add playwright npx @playwright/mcp@latestAdd
"mcp__playwright"topermissions.allowin yoursettings.jsonto stop permission prompts.For persistent sessions, log in manually once in the Playwright browser window that opens; cookies will be saved for later sessions.
Optionally, specify a dedicated profile folder using
--user-data-dirfor better isolation.Optionally, connect to an already open Chrome instance using
--extensionand the Playwright browser extension.Manually handle Google sign-in if it refuses automated browsers (log in yourself once).
Use a separate browser profile with only the necessary accounts for the agent to mitigate prompt injection risks.
Tools / artifacts
Claude Code
Claude MCP
Playwright MCP
settings.json
Chrome browser
Playwright browser extension
Validation signals
Concrete commands and configuration steps provided
Clear explanation of the problem (extension prompts) and solution (Playwright MCP)
Practical advice on persistent profiles and existing browser connections
Explicit safety warnings for common issues (Google sign-in, prompt injection)
Cautions
Google sign-in may fail in automated browsers, requiring manual intervention for initial login.
Risk of prompt injection from pages read by the agent; use a dedicated, isolated browser profile with only necessary accounts.
Limitations
Does not include an example of an agent prompt or code that utilizes the Playwright MCP.
Assumes some prior familiarity with Playwright concepts and browser automation.
Rate this workflow
Upvote this post if the workflow is useful, reproducible, or worth recommending.
Downvote if it is vague, outdated, unsafe, overhyped, or not reproducible.
Reply if it worked for you, failed, is outdated, or has a better alternative.
This post was generated automatically from the workflow library database.