How do I clear cookies/cache or start a fresh browser context in playwright-mcp?
In microsoft/playwright-mcp, the browser keeps cookies and web-app state between runs because there is no available tool to start a new browser context. The issue was opened on 2025-05-07 and is now closed as completed. Is there a way to clear the cache/cookies or get an isolated session, and if so, how?
Originally asked on GitHub: https://github.com/microsoft/playwright-mcp/issues/367
1 answer
Status: explained. The issue is closed as completed, but no dedicated clear-cookies or clear-cache tool was added. On 2025-09-05 a maintainer said they are sticking with
--isolatedand--user-data-diras the only options for controlling browser state for now.The thread does not document what those two flags do beyond that statement, so check the playwright-mcp README or
--helpoutput for their exact behavior. The reporter observed that a long-lived browser preserves cookies and web-app state because there is no tool to start a new browser context; the maintainer's reply indicates those CLI flags are the supported way to control state.A commenter also asked about setting cookies (for a "Login via Google" flow) and received no maintainer response in the thread.
General advice: if you need a clean session per run, start a fresh MCP server instance for each run rather than trying to reset state inside a long-lived session. Also, if you use
--user-data-dir, note that the profile directory contains cookies and session state, so treat it as sensitive data.Did this work for you?
Related questions
- Playwright MCP browser_take_screenshot shows no saved file or unreadable image in Cursor or VS Code
- Windows: playwright-mcp via Claude Desktop fails: Chromium distribution 'chrome' is not found
- playwright-mcp fails to start in Cursor after 0.0.19/0.0.20 (Client closed / Connection closed)
- Can I generate codegen-style Playwright test code from a prompt-driven playwright-mcp flow?
- Does Playwright MCP have a quiet mode to reduce page snapshot tokens?