safari_evaluate
Execute JavaScript in the current browser tab with promise support; automatically uses AppleScript fallback when Content Security Policy blocks execution, and can target specific iframes for cross-origin scripts.
Instructions
Execute JavaScript in the current page (a returned Promise is awaited — fetch/timers work in background tabs; requestAnimationFrame never fires there). Automatically falls back to AppleScript when CSP blocks execution (e.g. Google Search Console, LinkedIn). For reading data, prefer safari_read_page or safari_snapshot. For interactions, prefer safari_click/fill with refs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| frame | No | Run inside a sub-frame instead of the main document: a frameId from safari_list_frames, or a substring of the frame's URL (must match exactly one). Needed for cross-origin iframes — micro-frontend app shells, embedded checkouts — where the main document only holds a loader. | |
| script | Yes | JavaScript code to execute | |
| receipt | No | Opaque extension-issued tab receipt — pass the one safari_new_tab returned to keep targeting that tab after an MCP reconnect |