Playwright MCP login: keep your agent signed in
I build Dejo, another browser MCP server, so read the last section with that in mind. Everything about Playwright MCP below comes from its own docs, linked, read on 13 November 2026.
Short answer: Playwright MCP keeps you logged in by default. It uses a persistent browser profile, and its docs say "login state, cookies, and local storage are preserved between sessions." Sign in once yourself in the window it opens, and later sessions start signed in. For tests or CI, save the login to a file with --caps=storage and load it with --storage-state.
The default: a persistent profile per project
From the Profile & State docs: the profile lives in a folder named after the browser channel and a hash of your workspace, so each project gets its own profile, and you sign in once per project.
| platform | default location |
|---|---|
| macOS | ~/Library/Caches/ms-playwright-mcp/mcp-{channel}-{workspace-hash} |
| Linux | ~/.cache/ms-playwright-mcp/mcp-{channel}-{workspace-hash} |
| Windows | %LOCALAPPDATA%\ms-playwright-mcp\mcp-{channel}-{workspace-hash} |
To share one login across projects, pick the folder yourself:
["@playwright/mcp@latest", "--user-data-dir=/path/to/profile"]
One catch from the same page: "A profile can only be used by one browser at a time. If it is already locked, the server fails to start." Two agent sessions on one project will clash.
How to sign in, step by step
- Ask your agent to open the site's login page with Playwright MCP.
- In the browser window it opens, sign in yourself: password, Google, a code on your phone.
- Tell the agent you're done, and carry on with the task.
- Next session, the same project starts signed in.
Don't paste the password into the chat. Anything in the conversation is part of what the model reads. Playwright's own authentication example has the agent type the password, which works, but it puts the password in the transcript.
For tests and CI: save the login to a file
The Storage & Authentication docs call storage state "the primary way to persist authentication across sessions". Turn on the storage tools with --caps=storage, then:
browser_storage_statesaves cookies and local storage to a JSON file after you sign in.browser_set_storage_staterestores it later; existing cookies and local storage are cleared first.
Or load it when the server starts, in a fresh session that writes nothing to disk:
["@playwright/mcp@latest", "--caps=storage", "--isolated", "--storage-state=./auth-state.json"]
--isolated starts every session with no saved state; it can't be combined with --user-data-dir. Treat the JSON file like a password: it holds your session cookies.
Use the browser you're already signed in to
Playwright MCP also has a browser extension that connects to your running Chrome or Edge instead of launching its own browser, so every site you're signed in to is already signed in. That suits Google, SSO and two-factor sign-ins.
When the session runs out
Sites end sessions on their own schedule, and no tool can stop that. With Playwright MCP, the agent lands on a login page and has to notice. Sign in again in the window and the profile keeps the new session.
The same thing in Dejo
Dejo also keeps a persistent profile, in ~/.dejo. The differences: when a site needs a sign-in, your agent calls dejo_login and a window opens; before it closes, Dejo checks you really signed in, and nothing is saved if the page still looks like a login page. You can keep several named profiles side by side (a customer, a vendor, an admin), and Dejo also remembers the task itself, so the next run is one call. The setup is in keep your AI agent signed in, and all three common options are compared in can Claude log in to websites.
Related reading: an AI agent with multiple signed-in user roles, Playwright MCP vs Claude in Chrome and why Playwright MCP uses so many tokens.
FAQ
Does Playwright MCP keep me logged in?
Yes, by default. Its docs say login state, cookies and local storage are preserved between sessions in a persistent profile. Sign in once in its browser window and later sessions start signed in.
Where does Playwright MCP store its browser profile?
On macOS in ~/Library/Caches/ms-playwright-mcp, on Linux in ~/.cache/ms-playwright-mcp and on Windows in %LOCALAPPDATA%\ms-playwright-mcp, in a folder named after the browser channel and a hash of your workspace. So each project gets its own profile. --user-data-dir picks a folder yourself.
How do I log in with Playwright MCP without giving the AI my password?
Sign in yourself in the browser window Playwright MCP opens, then tell the agent you are done. With the persistent profile the session is kept. Avoid typing the password into the chat: anything in the conversation is read by the model.
Why does Playwright MCP fail to start with my profile?
A profile can only be used by one browser at a time. If another Playwright MCP session or browser has it open, the docs say the server fails to start. Close the other session, or give each one its own --user-data-dir.