Can I attach cookies or storage state to the browser context in playwright-mcp?
In microsoft/playwright-mcp (issue opened 2025-05-12, no version or OS given, no error message — it's a feature request), I want to attach Okta MFA session cookies to the browser context so the MCP-driven browser starts already authenticated and skips MFA, the way our Playwright tests attach token cookies obtained from an API call. Was cookie or storage-state support added?
Originally asked on GitHub: https://github.com/microsoft/playwright-mcp/issues/403
3 answers
This issue is closed as COMPLETED, but the thread does not document the exact version, tool name, or configuration that implements the request — check the playwright-mcp docs/release notes for your installed version to see how cookie support was shipped.
The approach discussed in the thread is Playwright's storage-state pattern. The reporter described an existing (non-MCP) workflow: as a prerequisite, a script makes an API call to obtain the Okta token cookies and attaches them to the browser context, bypassing MFA for their Playwright tests. For the MCP server, they asked for a way to attach those same cookies to the browser context it creates.
A commenter recommended adding session persistence / storage-state support, as described in the Playwright auth docs (https://playwright.dev/docs/auth (opens external site)): authenticate once in a separate session, persist the authenticated state to a file, and then reference that storage state file when the browser starts. Their stated motivation was to run authentication outside the MCP server so credentials are not exposed to the AI agent — keep your Okta/API authentication separate from the MCP session for the same reason.
As general advice: keep your existing API-call prerequisite script, save the resulting session state, and look for a storage-state or cookie option in the playwright-mcp configuration for your version. The thread does not confirm that anyone tested this against the MCP server.
Did this work for you?What a GitHub user tried on GitHub (Outcome unclear)
The reporter's existing non-MCP workflow: as a test prerequisite, an API call obtains Okta token cookies and attaches them to the browser context to bypass MFA. The thread does not evaluate whether this works against the MCP server.
Source: https://github.com/microsoft/playwright-mcp/issues/403 (opens external site)
Did this work for you?What @DimitarTarkalanov tried on GitHub (Outcome unclear)
A commenter suggested adding session persistence / storage-state support: authenticate separately, save the storage state, then reference the file as in Playwright's auth guide (https://playwright.dev/docs/auth (opens external site)), so credentials are not exposed to the AI agent. Not tested in the thread.
Source: https://github.com/microsoft/playwright-mcp/issues/403#issuecomment-2876496579 (opens external site)
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?