run, snapshot, and screenshot. A Codex SDK thread connects to the Stagehand facade MCP server over MCP/stdio, and one server process owns the browser, so page state survives across tool calls.
Stagehand ships this experimental integration from the repository rather than publishing it as a standalone adapter.
Prerequisites
- Node.js 24 or newer
- pnpm 11.10.0
- An OpenAI API key or an existing
codex loginfor the example agent - A current Google Chrome installation for local browser mode
Quickstart
1
Clone and build Stagehand
2
Configure the Codex agent
CODEX_STAGEHAND_MODEL to override it.3
Choose the browser
The example defaults to Browserbase when
BROWSERBASE_API_KEY is set, otherwise it uses local Chrome:4
Run a browser task
The example sets
approvals_reviewer = "auto_review" in the Codex config override. Headless MCP tool calls on machines without a global approvals_reviewer fail with “user cancelled MCP tool call” without it, regardless of approval policy. If pnpm skips the SDK’s vendored-binary postinstall, set export CODEX_PATH_OVERRIDE=$(which codex).Configuration
Keep the browser session alive
The example starts one Codex thread against one facade MCP server, with raised MCP startup and tool timeouts because browser launches exceed the Codex defaults. The local sandbox stays read-only; the browser work happens in the MCP server. Preserve that lifetime if you adapt the integration; a new process per tool call starts a new browser. Codex has no native turn limit; long tasks run until the model finishes. The MCP child receives only Stagehand and Browserbase configuration plus the process values required to launch Node. The host’s model credential remains in the Codex process.Connect a running Codex CLI
The same server works from the Codex CLI. Merge the package’sconfig.toml into ~/.codex/config.toml, adjusting the path to your checkout:
codex exec overrides:
[mcp_servers] already in your ~/.codex/config.toml rather than replacing them; set CODEX_HOME to a scratch directory if you need isolation.
Codex integration source
Read the Codex config override, agent thread setup, and contract tests.

