← Back to microsoft/playwright
microsoft / playwright · Issue No. 42104
We run @playwright/mcp as a long-lived stdio MCP server inside an agentic coding CLI (Claude Code). Our workflow uses git worktree heavily: a single coding session self-provisions a new worktree mid-session (a sibling directory checked out from the same repo) and does the rest of its work there — including browser-driven QA/evidence capture. Multiple such sessions run concurrently, each in its own worktree.
--output-dir (and the MCP roots capability) are resolved once, at MCP server process start, against whatever the coding tool's root was at that moment (the primary checkout). When a session later moves its own work into a freshly created worktree, the server's output directory does not follow — it stays bound to the original path for the life of that long-lived server process. Screenshot/trace/evidence writes aimed at the session's own worktree path get denied as "outside allowed roots", and writes that do succeed land in the original (shared) directory, where concurrent worktree sessions collide with each other.
This isn't solved by the existing "isolate concurrent sessions" workarounds, because those target a different axis of the problem:
--isolated + distinct --user-data-dir, or a tabId-per-agent scheme as discussed in microsoft/playwright-mcp#893) isolates the browser instance, not the output directory.roots is fixed at init and, per the discussion on microsoft/playwright-mcp#1240, is being phased out client-side anyway (SEP-2577). Even where honored, roots reflects the coding tool's session root — which in our case also doesn't change when a worktree is created mid-session; the CLI process's own root stays put, only the working directory used for that sub-task moves.What we actually need is one of:
output-dir per-connection or per-call at runtime (e.g., an override accepted alongside a tool call, or the server re-reading roots/cwd against a later negotiation rather than only at init), orWe'd like to avoid both (a) widening --output-dir to some insecure common-ancestor directory outside the actual project roots, and (b) building/maintaining a custom wrapper MCP server just to re-derive per-worktree paths.
roots-based approach, with a "wrap our MCP into yours" suggestion. That's a different deployment shape (remote/HTTP) from ours (local stdio, git-worktree-based).devtools capability's start/stop with explicit paths — doesn't address the local worktree-root-mismatch case.Given the "wrap it yourself" answer on microsoft/playwright-mcp#1240, is there an official recommended pattern for the git-worktree case specifically — or would a small opt-in mechanism (output-dir override per call, or re-reading roots/cwd on a later negotiation) be worth considering?
Happy to provide more detail on the worktree lifecycle if useful.
Relay reads this issue against the repository's contribution signals: the files it is likely to touch, how the maintainers triage work this size, and what the first contribution would exercise.
The full analysis for this issue is still being assembled. Until then, the description above and the thread on GitHub are the most reliable context.