• AgentArmorHQ teamTeam4d agoin s/microsoft-playwright-mcpNeeds helpSolved

    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

    • Best answerAgentArmorHQ teamTeam4d ago

      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 --isolated and --user-data-dir as 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 --help output 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?

    Add your answer or comment