Codex Desktop launches Playwright MCP with cwd /, causing output path resolution to /.playwright-mcp

Open 💬 8 comments Opened Apr 1, 2026 by rmcarthur-oracle

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

  1. Configure Playwright MCP in Codex Desktop with:
[mcp_servers.playwright]
command = "npx"
args = ["@playwright/mcp@latest", "--extension"]
enabled = true
  1. Open a workspace in Codex Desktop.
  2. Invoke any Playwright MCP tool, for example browser_navigate.
  3. 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.

View original on GitHub ↗

8 Comments

aristide1997 · 3 months ago

Same error here

jagaldol · 3 months ago

I can reproduce the same issue on Desktop.

In my case there were two separate failures in sequence:

  • first, a temporary Browser is already in use conflict from another Playwright session
  • after closing that other session, the remaining failure was the same ENOENT: no such file or directory, mkdir '/.playwright-mcp'

The root cause looks like a generic stdio MCP cwd defaulting problem rather than something Playwright-specific:

  • Playwright MCP falls back to process.cwd() when it does not get client roots / workspace context
  • in the failing Desktop path, the stdio MCP child appears to start with cwd=/
  • Playwright then resolves its output dir under /.playwright-mcp
  • browser_navigate includes a snapshot in the response path, so it eventually tries to create that directory and fails there

The smallest fix seems to be on the Codex side when normalizing / preparing MCP server configs, not in Playwright itself:

  • for McpServerTransportConfig::Stdio, if cwd is unset, default it to the active session/workspace cwd
  • preserve explicitly configured cwd values as-is
  • apply the same normalization on refresh/reconnect paths too, so the injected cwd is stable across session updates

Concretely, the relevant spot looks like the MCP server aggregation / normalization path in codex-rs/core/src/mcp/mod.rs (for example around effective_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.

callum-atwal · 3 months ago

Worked around this issue. You can specify the --output-dir manually and override it trying to create a folder in the root level.

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": [
        "@playwright/mcp@latest",
        "--output-dir=/Users/<your username>/.playwright-mcp"
      ]
    }
  }
}

Of course, the dir can be anywhere that is writable.

mahnunchik · 3 months ago

I've faced with the same issue.

Why does VSCode launch Codex with the current working directory set to /? What is the sense?

jagaldol · 3 months ago

Confirmed this workaround fixes it for me in Codex Desktop as well.

I added --output-dir=/Users/hyejun/.playwright-mcp to 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.

Jeffrey-FC · 3 months ago

same issue here
mkdir '/.playwright-mcp‘

mobiletoly · 3 months ago

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:

[mcp_servers.drymint]
# set to your project's directory
cwd = "/Users/me/TempProjects/project"
# other params
args = ["mcp", "run"]
startup_timeout_sec = 20.0

then at least you can set it up for your different projects (but obviously don't commit this)

ohcedar · 3 months ago

+1, I am seeing the same Codex Desktop Playwright MCP behavior on macOS: screenshots try to write under /.playwright-mcp even though the workspace has a writable .playwright-mcp directory. The --output-dir workaround is needed here too.