Blog /
Playwright MCP Codex Setup: Config, Commands and Fixes
Add Playwright MCP to Codex with one command or a config.toml table, confirm it with codex mcp list, and fix the setup problems the docs name.

To add Playwright MCP to OpenAI Codex, run codex mcp add playwright npx "@playwright/mcp@latest", or add a [mcp_servers.playwright] table with command = "npx" and args = ["@playwright/mcp@latest"] to ~/.codex/config.toml. Both forms come from the Playwright MCP README. Then run codex mcp list (or /mcp inside the Codex TUI) to confirm the server is there, and ask Codex to open a page.
The rest of this guide covers the exact config, the options worth knowing, the errors the docs name, and where a browser inside a Codex session stops being enough.
Add Playwright MCP to Codex
The Playwright MCP README gives two equivalent ways for Codex.
One command:
codex mcp add playwright npx "@playwright/mcp@latest"
Or edit ~/.codex/config.toml:
[mcp_servers.playwright] command = "npx" args = ["@playwright/mcp@latest"]
What the Codex MCP docs add to this:
The general form of the command is
codex mcp add <server-name> --env VAR1=VALUE1 -- <stdio server-command>. Everything after--is the command that starts the server, which is the clean way to pass Playwright flags such as--headless.~/.codex/config.tomlis the default file. You can also "scope MCP servers to a project with.codex/config.toml(trusted projects only).""The ChatGPT desktop app, Codex CLI, and IDE extension share this configuration," so one entry serves all three.
Before you start, check the requirement the README lists: Node.js 20 or newer, available in the same shell, container or remote host where Codex runs.
Version pinning:
@latestmakesnpxfetch the newest published version on start. If every machine on the team should behave the same, replace@latestwith a fixed version.
Confirm Codex Can Drive the Browser
An entry in the file does not prove the server starts. The Codex MCP docs give two ways to look:
In the terminal:
codex mcp listshows configured servers.In the
codexTUI:/mcpshows active MCP servers.
When playwright is active, give Codex a small task against a page you own:
"Open https://your-app.example and tell me the page title."
"List the main headings, links and buttons on this page."
"Click the Pricing link, then tell me the new URL."
"Take a screenshot of the page."
One action per prompt makes it obvious which step failed.
Why this works without screenshots of every step: the Playwright MCP getting-started guide says "Playwright MCP operates on the page's accessibility tree, not pixels." The model acts on element references from a snapshot of that tree. A snapshot reflects the page at the moment it was taken, so after a navigation or a dialog, let Codex take a fresh one before the next action.
By default the browser opens headed and keeps a persistent profile, so "login state and cookies [are] preserved between sessions," per the Playwright MCP introduction. The README gives the profile location: ~/.cache/ms-playwright/mcp-{channel}-{workspace-hash} on Linux and ~/Library/Caches/ms-playwright/mcp-{channel}-{workspace-hash} on macOS, changeable with --user-data-dir.
Options and config.toml Fields
Playwright flags go into args, after the package name. The descriptions below are quoted from the README.
| Option | README description | Use it when |
|---|---|---|
--browser | "browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge" | You need a browser other than the default |
--headless | "run browser in headless mode, headed by default" | No display, or you do not want a window |
--isolated | "keep the browser profile in memory, do not save it to disk" | Each session should start clean |
--config | "path to the configuration file" | Several settings live in one JSON file |
--user-data-dir | Changes where the persistent profile is kept | You want the profile in a known place |
- Option
--browser- README description
- "browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge"
- Use it when
- You need a browser other than the default
- Option
--headless- README description
- "run browser in headless mode, headed by default"
- Use it when
- No display, or you do not want a window
- Option
--isolated- README description
- "keep the browser profile in memory, do not save it to disk"
- Use it when
- Each session should start clean
- Option
--config- README description
- "path to the configuration file"
- Use it when
- Several settings live in one JSON file
- Option
--user-data-dir- README description
- Changes where the persistent profile is kept
- Use it when
- You want the profile in a known place
A headless, clean-profile setup:
[mcp_servers.playwright] command = "npx" args = ["@playwright/mcp@latest", "--headless", "--isolated"]
Or with one command, using the -- separator from the Codex docs:
codex mcp add playwright -- npx @playwright/mcp@latest --headless --isolated
Codex's own fields for any [mcp_servers.<name>] table, from the Codex MCP docs:
| Field | What the docs say |
|---|---|
command | "The command that starts the server." (required) |
args | "Arguments to pass to the server." |
env | "Environment variables to set for the server." |
env_vars | "Environment variables to allow and forward." |
cwd | "Working directory to start the server from." |
startup_timeout_sec | "Timeout (seconds) for the server to start. Default: 10." |
tool_timeout_sec | "Timeout (seconds) for the server to run a tool. Default: 60." |
enabled | "Set false to disable a server without deleting it." |
- Field
command- What the docs say
- "The command that starts the server." (required)
- Field
args- What the docs say
- "Arguments to pass to the server."
- Field
env- What the docs say
- "Environment variables to set for the server."
- Field
env_vars- What the docs say
- "Environment variables to allow and forward."
- Field
cwd- What the docs say
- "Working directory to start the server from."
- Field
startup_timeout_sec- What the docs say
- "Timeout (seconds) for the server to start. Default:
10."
- Field
tool_timeout_sec- What the docs say
- "Timeout (seconds) for the server to run a tool. Default:
60."
- Field
enabled- What the docs say
- "Set
falseto disable a server without deleting it."
cwd matters when --config points to a relative path checked into the repository. env and env_vars let you pass the browser process only the variables it needs.
If you are deciding whether Codex should drive the browser through MCP at all, the Playwright MCP introduction suggests the CLI for coding agents working with large codebases, because its output costs fewer tokens; we compare the two in Playwright CLI vs MCP.
Codex, Cursor and Claude Code Configs Side by Side
The server is the same in every client; only the client's config format changes. Codex reads TOML, so a JSON snippet copied from a Cursor or Claude Code guide will not work in config.toml.
| Client | How to add Playwright MCP | Source |
|---|---|---|
| Codex | codex mcp add playwright npx "@playwright/mcp@latest" or [mcp_servers.playwright] in ~/.codex/config.toml | Playwright MCP README |
| Cursor | JSON mcpServers entry with "command": "npx" and "args": ["@playwright/mcp@latest"] | Playwright MCP README, see our Cursor setup guide |
| Claude Code | claude mcp add playwright npx @playwright/mcp@latest; to pass flags, use the form claude mcp add [options] <name> -- <command> [args...] | Playwright MCP README, Claude Code MCP docs |
- Client
- Codex
- How to add Playwright MCP
codex mcp add playwright npx "@playwright/mcp@latest"or[mcp_servers.playwright]in~/.codex/config.toml- Source
- Playwright MCP README
- Client
- Cursor
- How to add Playwright MCP
- JSON
mcpServersentry with"command": "npx"and"args": ["@playwright/mcp@latest"] - Source
- Playwright MCP README, see our Cursor setup guide
- Client
- Claude Code
- How to add Playwright MCP
claude mcp add playwright npx @playwright/mcp@latest; to pass flags, use the formclaude mcp add [options] <name> -- <command> [args...]
Fix Common Setup Problems
Only problems the official docs name are listed here.
| Symptom | Likely cause | Fix (source) |
|---|---|---|
playwright missing from codex mcp list | No entry, or the table name is not mcp_servers.playwright | Re-run codex mcp add or fix the table name (Codex MCP docs) |
| Server listed but never becomes active | It takes longer than the 10-second default to start, e.g. while npx downloads the package | Raise startup_timeout_sec in the server's table (Codex MCP docs) |
| Server fails to start at all | Node.js older than 20, or no Node in the environment where Codex runs | Install Node.js 20 or newer there (README) |
| A long browser action is cut off | It runs past the 60-second tool default | Raise tool_timeout_sec (Codex MCP docs) |
| You want the server off for a while | Set enabled = false instead of deleting the table (Codex MCP docs) | |
| An action fails on a page that changed | The model acted on an old accessibility snapshot | Ask Codex to take a fresh snapshot first (getting-started guide) |
- Symptom
playwrightmissing fromcodex mcp list- Likely cause
- No entry, or the table name is not
mcp_servers.playwright - Fix (source)
- Re-run
codex mcp addor fix the table name (Codex MCP docs)
- Symptom
- Server listed but never becomes active
- Likely cause
- It takes longer than the 10-second default to start, e.g. while
npxdownloads the package - Fix (source)
- Raise
startup_timeout_secin the server's table (Codex MCP docs)
- Symptom
- Server fails to start at all
- Likely cause
- Node.js older than 20, or no Node in the environment where Codex runs
- Fix (source)
- Install Node.js 20 or newer there (README)
- Symptom
- A long browser action is cut off
- Likely cause
- It runs past the 60-second tool default
- Fix (source)
- Raise
tool_timeout_sec(Codex MCP docs)
- Symptom
- You want the server off for a while
- Likely cause
- Fix (source)
- Set
enabled = falseinstead of deleting the table (Codex MCP docs)
- Symptom
- An action fails on a page that changed
- Likely cause
- The model acted on an old accessibility snapshot
- Fix (source)
- Ask Codex to take a fresh snapshot first (getting-started guide)
For other errors, the Codex MCP docs and the Playwright MCP repository are the places to look.
Your agent says “done”. We check your app.
After each deploy and every day, we walk the journeys you choose on your live app and tell your agent what passed and what failed, with screenshots.
claude mcp add --scope user --transport http checkmyapp https://checkmyapp.dev/mcpFree account: $3 of checks, no card · Cursor, Codex and the full install guide
What a Browser in the Session Does Not Cover
Playwright MCP gives Codex a browser inside its session. That is the right tool while Codex builds and debugs: it can open your local or preview app, click through the change it just made, and look at what rendered. It is free, open source and runs on your machine.
What it does not do is check the deployed app after the session ends. The session closes when Codex says "done", and nothing in this setup looks at production after the next deploy.
That is the gap CheckMyApp is for. Your agent says "done"; CheckMyApp uses your live app as a real user and tells it what broke. It connects to Codex through MCP, with one line in your agent and one sign-in in the browser, as shown on the install page. Keep Playwright MCP for the work inside the session, and let a separate check decide whether the live app still works.
This article was prepared with the help of AI. Found a mistake? Tell us.


