How to add Playwright MCP server to Codex

Adding Playwright MCP to Codex gives a Codex session browser automation tools for navigation, clicks, form input, screenshots, console messages, network requests, and page snapshots from the same prompt. That is useful when a task needs live browser state instead of shell output alone.

OpenAI's current Codex MCP docs store MCP server configuration in ~/.codex/config.toml by default and share that saved entry with the Codex IDE extension. The current Playwright MCP README publishes npx @playwright/mcp@latest as the standard launcher, and a successful codex mcp add writes that launcher under [mcp_servers.playwright] so it can be checked immediately with codex mcp get or codex mcp list.

Current upstream Playwright MCP requirements are Node.js 18 or newer and an MCP client such as Codex. Because Playwright MCP runs as a local stdio server, Auth showing Unsupported in codex mcp list is expected, and the first browser task uses Playwright's default browser behavior unless additional arguments such as --headless or --isolated are added when the server is saved.

Steps to add Playwright MCP server to Codex:

  1. Add the standard Playwright MCP launcher to Codex.
    $ codex mcp add playwright -- npx @playwright/mcp@latest
    Added global MCP server 'playwright'.

    The current upstream Codex and Playwright MCP docs publish the same npx @playwright/mcp@latest launcher. Append extra Playwright MCP arguments after @playwright/mcp@latest only when the saved server needs non-default behavior such as --headless or --isolated.

  2. Retrieve the saved MCP entry in JSON to confirm that Codex stored the expected local stdio server.
    $ codex mcp get playwright --json
    {
      "name": "playwright",
      "enabled": true,
      "disabled_reason": null,
      "transport": {
        "type": "stdio",
        "command": "npx",
        "args": [
          "@playwright/mcp@latest"
        ],
        "env": null,
        "env_vars": [],
        "cwd": null
      },
      "enabled_tools": null,
      "disabled_tools": null,
      "startup_timeout_sec": null,
      "tool_timeout_sec": null
    }

    The decisive fields are "type": "stdio", "command": "npx", and "args": ["@playwright/mcp@latest"]. The same launcher is stored under [mcp_servers.playwright] in ~/.codex/config.toml.

  3. List the configured MCP servers and confirm that the new entry is enabled.
    $ codex mcp list
    Name        Command  Args                    Env  Cwd  Status   Auth
    playwright  npx      @playwright/mcp@latest  -    -    enabled  Unsupported

    The decisive success state is the playwright row with enabled under Status. Unsupported under Auth is expected because Playwright MCP is a local stdio launcher and does not use a separate Codex login flow.

  4. Start or restart Codex after the server entry is saved.
    $ codex

    In the interactive Codex TUI, run /mcp to confirm that the saved playwright entry is available in the current session. The same saved entry is also available to the Codex IDE extension because both clients read the same MCP config.

  5. Send a browser prompt that requires Playwright MCP tools.
    Open https://example.com and tell me the page title.

    The first browser prompt can take longer than later ones because npx may need to fetch the current @playwright/mcp package before Codex starts the local server process. When the saved launcher is correct, Codex can use the Playwright MCP browser tools for navigation and page inspection from the same session.