Codex Desktop launches Playwright MCP with cwd /, causing output path resolution to /.playwright-mcp
What version of the Codex App are you using (From “About Codex” dialog)?
26.325.31654 (1272)
What subscription do you have?
Custom
What platform is your computer?
Darwin 25.3.0 arm64 arm
What issue are you seeing?
Summary
When Codex Desktop runs the Playwright MCP server, the MCP process appears to start with working directory / instead of the active workspace directory, and/or Codex does not provide MCP roots for the active workspace.
Playwright MCP derives its default output directory from cwd. As a result, it resolves the output path to:
/.playwright-mcp
On a read-only root filesystem, Playwright MCP then fails with:
Error: ENOENT: no such file or directory, mkdir '/.playwright-mcp'
This occurs even when running Playwright MCP in --extension mode, so the issue is not the browser profile path itself.
Environment
- Codex Desktop
- macOS
- Workspace:
/Users/username/development/project - Playwright MCP configured via
~/.codex/config.toml
[mcp_servers.playwright]
command = "npx"
args = ["@playwright/mcp@latest", "--extension"]
enabled = true
[mcp_servers.playwright.env]
PLAYWRIGHT_MCP_EXTENSION_TOKEN="..."
What steps can reproduce the bug?
Reproduction
- Configure Playwright MCP in Codex Desktop with:
[mcp_servers.playwright]
command = "npx"
args = ["@playwright/mcp@latest", "--extension"]
enabled = true
- Open a workspace in Codex Desktop.
- Invoke any Playwright MCP tool, for example
browser_navigate. - Observe Playwright MCP attempting to create
/.playwright-mcp.
Actual behavior
Playwright MCP fails with:
Error: ENOENT: no such file or directory, mkdir '/.playwright-mcp'
In my session, the live Playwright MCP processes were running with cwd /.
What is the expected behavior?
Expected behavior
Codex Desktop should either:
- launch the MCP server with cwd set to the active workspace, or
- provide MCP roots for the active workspace so the server resolves paths relative to that workspace.
Either way, Playwright MCP should not end up resolving its default output directory to /.playwright-mcp.
Evidence
Codex session context showed the active workspace cwd was not /:
"cwd": "/Users/username/.codex/worktrees/a9b7/project"
But the live Playwright MCP processes were running with cwd /.
I also traced Playwright’s behavior:
- Playwright MCP resolves its output directory from
options.cwd - when no roots are available, it falls back to
process.cwd()
So if the MCP process starts in /, its default output path becomes /.playwright-mcp.
Additional information
Notes
This looks like a Codex/Desktop bug first, with a possible secondary robustness issue in Playwright MCP. The immediate trigger is that the MCP process cwd is / or roots are not being passed through correctly.
8 Comments
Same error here
I can reproduce the same issue on Desktop.
In my case there were two separate failures in sequence:
Browser is already in useconflict from another Playwright sessionENOENT: no such file or directory, mkdir '/.playwright-mcp'The root cause looks like a generic stdio MCP
cwddefaulting problem rather than something Playwright-specific:process.cwd()when it does not get client roots / workspace contextcwd=//.playwright-mcpbrowser_navigateincludes a snapshot in the response path, so it eventually tries to create that directory and fails thereThe smallest fix seems to be on the Codex side when normalizing / preparing MCP server configs, not in Playwright itself:
McpServerTransportConfig::Stdio, ifcwdis unset, default it to the active session/workspacecwdcwdvalues as-iscwdis stable across session updatesConcretely, the relevant spot looks like the MCP server aggregation / normalization path in
codex-rs/core/src/mcp/mod.rs(for example aroundeffective_mcp_servers()), plus the session refresh path that rebuilds MCP state.That should fix this for Playwright MCP and any other stdio MCP server that implicitly depends on the process working directory.
Worked around this issue. You can specify the
--output-dirmanually and override it trying to create a folder in the root level.Of course, the dir can be anywhere that is writable.
I've faced with the same issue.
Why does VSCode launch Codex with the current working directory set to
/? What is the sense?Confirmed this workaround fixes it for me in Codex Desktop as well.
I added
--output-dir=/Users/hyejun/.playwright-mcpto the Playwright MCP args, restarted Codex, and the MCP was then able to launch and navigate successfully without trying to write to/.playwright-mcp.So at least as a workaround, overriding the output dir to a writable location works.
same issue here
mkdir '/.playwright-mcp‘
very annoying bug (and I'm building my own MCP), specific to codex app (not to codex cli)
so the only work-around I discovered so far is to create .codex/config.toml in your project's directory and set cwd to the directory that MCP should use as work directory:
then at least you can set it up for your different projects (but obviously don't commit this)
+1, I am seeing the same Codex Desktop Playwright MCP behavior on macOS: screenshots try to write under
/.playwright-mcpeven though the workspace has a writable.playwright-mcpdirectory. The--output-dirworkaround is needed here too.