[MCP]: page snapshots in .playwright-mcp/ are not git-ignored (.playwright-cli/ is, since #42318)
What's going on?
After browser_navigate, browser_click, browser_type and most other calls, the MCP server writes a snapshot of the page to .playwright-mcp/page-<time>.yml. When the page logs anything, its console messages go to console-<time>.log beside it. The folder is created in the workspace: the client's MCP root, or the server cwd when there is no root. For a coding agent that is the project, usually a git repository, and nothing ignores the folder:
$ git status --porcelain
?? .playwright-mcp/console-2026-11-22T00-13-19-546Z.log
?? .playwright-mcp/page-2026-11-22T00-13-19-601Z.yml
A snapshot is the text of the page. On a signed-in page that means names, e-mail addresses and account details, one git add -A away from a commit. I noticed it when the first snapshot of a session, taken on a Google account chooser, listed every signed-in address. On my own machine, 10 git repositories have this folder: 8 have a .playwright-mcp/ line added to their .gitignore, and in the other 2 it sat untracked (412 files) until I counted.
#42307 reported the same gap for the CLI, and #42318 fixed it: playwright-cli install now appends .playwright-cli/ to .gitignore, "since traces and storage state saved there can contain credentials". The MCP server has no install step, so nothing does this for .playwright-mcp/. (microsoft/playwright-mcp#1789 asked to move these files out of the workspace and was declined, with the advice to treat .playwright-mcp like .env. I am not asking to move them.)
Steps
git init demo- Start the server with
demoas its cwd, or announcedemoas the client's only MCP root. - Call
browser_navigateon a page that logs to the console. git -C demo status --porcelainprints the two lines above, andgit check-ignoreexits 1 for both files.
Expected: the default output folder stays out of git status. One way that leaves the user's .gitignore alone: when the server creates .playwright-mcp/, it also writes .playwright-mcp/.gitignore containing *, as Python's venv and pytest's cache directory do. With that file added by hand, git status in the steps above is clean.
The folder comes from outputDir(); every snapshot except an explicit browser_snapshot goes to a file.
Version
@playwright/mcp 0.0.86 (playwright-core 1.66.0-alpha-2026-11-18), and the same with playwright-core 1.66.0-alpha-2026-11-21. Windows 11, Node 24.21.0; the folder logic is not platform-specific.
Hi, I'm the Playwright bot. I started triaging this issue on Windows: agent run
Hi, I'm the Playwright bot. I reproduced this and prepared a fix.
Reproduced on Windows with Chromium, Firefox and WebKit, using 1.66.0-next at aa3c4453c15602f20ccf60c52fde74497e1ac268. The default output directory is created without an ignore rule, so both snapshots and console logs appear in Git status.
The proposed fix creates .playwright-mcp/.gitignore containing * before saving output. It preserves existing ignore files, leaves custom output directories and CLI output unchanged, and reports unexpected write errors instead of silently leaving files unignored.
Reproduction and checks
The existing browser_navigate test was extended, rather than adding another navigation test:
execFileSync('git', ['init', '--quiet', testInfo.outputPath()]);
server.setContent('/hello-world', `
<title>Title</title>
<body>Hello, world!<script>console.log('hello')</script></body>
`, 'text/html');
await client.callTool({
name: 'browser_navigate',
arguments: { url: server.HELLO_WORLD },
});
expect(execFileSync('git', [
'status', '--porcelain', '--untracked-files=all', '--', '.playwright-mcp',
], { cwd: testInfo.outputPath(), encoding: 'utf-8' })).toBe('');
The test also checks that a snapshot and a console log were saved.
| Check | Result |
|---|---|
| Unmodified main, Windows headless Chromium 159.0.8154.13, Firefox 159.0 and WebKit 27.2 | Regression fails on all three: snapshot and console log are untracked |
Linked PR #44291, head 5cf75811bddc92347c72890f2b781ea7915fc65e, plus the independent regression |
Both its test and the independent regression pass on all three engines |
| Both tests without the linked PR's source change | Both fail on all three engines |
| Proposed fix, same three engines | Regression passes on all three |
core.spec.ts, console.spec.ts, file-paths.spec.ts, same three engines |
93 passed; 3 permission tests skipped because this account can bypass directory permissions |
roots.spec.ts, same three engines |
18 passed |
| Existing ignore rules, custom output directory, CLI mode, explicit screenshot export | Preserved, checked with Chromium |
Injected EACCES when writing the ignore file |
Linked PR returns success with an unignored snapshot; proposed fix reports the error and saves no snapshot |
npm run build, npm run flint |
Passed |
Only Windows was tested. The reported published alpha versions were not run because the issue reproduced on main. Initial setup checks found missing dependencies and browsers; these were installed. The first lint attempt omitted the isolated browser path; it passed after that path was set.
Draft PR: https://github.com/microsoft/playwright/pull/44316
Triaged on Windows by the Playwright bot - agent run