Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
frameNoRun 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.
scriptYesJavaScript code to execute
receiptNoOpaque extension-issued tab receipt — pass the one safari_new_tab returned to keep targeting that tab after an MCP reconnect

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv2.20.0
    • addedInput schema / properties / frame
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "number"
      +    }
      +  ],
      +  "description": "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."
      +}
  2. Changed1 schema field changedv2.18.1
    • addedInput schema / properties / receipt
      Added value: +{
      +  "description": "Opaque extension-issued tab receipt — pass the one safari_new_tab returned to keep targeting that tab after an MCP reconnect",
      +  "type": "string"
      +}
  3. Addedv2.11.6
  4. Removedv2.11.3
  5. Addedv2.10.9
  6. Removedv2.10.8
  7. Addedv2.10.5
  8. Removedv2.10.4
  9. First observed

TDQS

A4.6/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It does well by revealing that returned Promises are awaited, that fetch/timers work in background tabs while requestAnimationFrame never fires there, and that there is an automatic AppleScript fallback under CSP restrictions. It does not detail error behavior or side effects of executing arbitrary JavaScript, but the disclosed execution-environment quirks are valuable and go beyond what the schema alone would tell an agent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded: the core action and Promise behavior come first, followed by the fallback, then routing guidance. Every sentence earns its place, and the sibling references are woven in without redundancy. It packs substantial behavioral and usage detail into a short space.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no output schema and no annotations, the description covers the key operational concerns: execution environment, fallback behavior, and when to choose alternatives. It does not mention return value shape or error handling, but the tool's purpose is open-ended JavaScript execution, so an agent should expect arbitrary results. The frame and receipt parameters are well explained, making the tool callable in practice.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds meaningful context for the frame parameter by explaining why it is needed (cross-origin iframes, micro-frontend shells, embedded checkouts) and how the substring matching works. It also clarifies the receipt parameter's purpose (keep targeting a tab after MCP reconnect). The script parameter itself is self-explanatory, but the added frame and receipt context pushes this above baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource ('Execute JavaScript in the current page') and immediately distinguishes it from siblings by noting Promise awaiting and background-tab behavior. It also names the sibling tools it is not (safari_read_page, safari_snapshot, safari_click/fill), so an agent can tell it apart from the many related tools without opening schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives explicit when-to-use guidance: use it for JavaScript execution, prefer safari_read_page or safari_snapshot for reading data, and prefer safari_click/fill for interactions. It also discloses the automatic AppleScript fallback when CSP blocks execution, with concrete examples (Google Search Console, LinkedIn), which helps an agent decide when this tool is still appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools