evaluate
Run custom JavaScript in the page to retrieve JSON results for measurements, UI state changes, or framework data when no standard tool applies.
Instructions
ESCAPE HATCH — run arbitrary agent-authored JavaScript in the page and get the JSON result. Use ONLY when no purpose-built tool covers the need: a custom measurement, forcing a UI state (dispatch an event / toggle a class), or reading framework/component state. Prefer explain_styles / measure_element / inspect_element / interact where they apply — reach for evaluate when the question is genuinely bespoke and none of them fits. The JS is trusted (you wrote it); its result is returned verbatim and size-capped.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timeoutMs | No | Max run time in ms before aborting (default 5000, clamped 100..30000). | |
| expression | Yes | JavaScript evaluated in the page (top-level frame). May be an expression (e.g. "getComputedStyle(document.body).zoom"), a bare object literal (e.g. "{ w: innerWidth, h: innerHeight }"), or an IIFE for multi-step logic. The value it produces is returned as JSON. | |
| awaitPromise | No | If the expression yields a Promise, await it and return the resolved value (default true). |