browser_exec
Run arbitrary async JavaScript against Chrome's API to control tabs, user context, and browser state. Use this escape hatch for custom automation beyond standard actions.
Instructions
Run arbitrary async JavaScript against Codex's Chrome API. In scope: agent, browser, tabs (=browser.tabs), user (=browser.user), tab (current or selected tab, else null), console, log. Use return to produce a JSON result; images returned/emitted are attached. Code runs in the MCP server's Node process: Node APIs like fetch work here (no browser cookies), while in-page JS must go through tab.playwright.evaluate (sandboxed, see eval_js). This is the full-power escape hatch.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Async function body. e.g. `return await tab.title();` | |
| tab_id | No | Optional tab id to bind as `tab`. |