execute_js
Run custom JavaScript in a live browser tab to trigger side effects, control dialogs, and retrieve results with explicit session and timeout handling.
Instructions
Execute arbitrary JS, which can cause side effects, in session_id's browser tab under one total deadline. Pin an explicit session_id; fallbacks keep that target and never replay an already-started script. For complex async bodies use an explicit return in an async IIFE. accept/dismiss prepare current injectable frames on extension routes; the legacy CDP fallback covers only its current evaluation context. manual keeps native dialogs. wait=false returns operation_id after delivery acknowledgement; collect with get_execute_js_result in the same MCP session, without replay. partial/unknown results or an expired handle do not prove non-execution; inspect retry_safe before retrying. A dispatched exec_timeout retains an outcome_unknown reservation for the bounded recovery window; the deadline does not cancel page JS. Use wait_for/wait_for_url for page state instead of sleep Promises. Conversion on all routes: undefined/non-finite numbers become null; BigInt/symbol become strings; DOM/Error/functions become readable values; cycles/depth 6/iterables above 200 items have markers. JSON UTF-8 over 24 KiB or any unpaired UTF-16 uses a private JSON result_file with result_bytes, result_sha256, result_format and result_file_scope=js-value. result_file_encoding=json means JSON-decode the path once; otherwise use it directly. Parse the UTF-8 file once; it preserves the full converted value and markers. If file writing fails, parse the complete ASCII result_json once (result_json_scope=js-value); this fallback may exceed the inline limit and preserves original result/retry verdicts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| wait | No | ||
| script | Yes | ||
| timeout | No | ||
| no_monitor | No | ||
| session_id | No | ||
| dialog_policy | No | dismiss |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||