browser_evaluate
Execute JavaScript in a live page to read or modify its state, extract data, or drive interactions. Target a specific tab or use an agent ID for parallel execution.
Instructions
Evaluate JavaScript in a page context. IMPORTANT: top-level const/let/var declarations persist across calls — always wrap multi-statement code in an IIFE: (() => { const x = ...; return x; })(). Never use bare 'return' at top level. Max timeout: 10s — avoid setTimeout > 10000ms. Supports targeting a specific tab via tabId.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tabId | No | Target tab ID (from browser_tabs list). Uses active tab if omitted. | |
| agentId | No | Agent identifier for parallel execution. Pass a unique ID (e.g. 'C1', 'J2') — the server automatically routes calls to this agent's dedicated tab (registered via browser_tabs action=new). | |
| expression | Yes | JavaScript expression or IIFE to evaluate |