Skip to main content
Glama

safari_evaluate

Execute JavaScript in the current browser page to access and manipulate DOM data, with an automatic AppleScript fallback for sites that block script injection.

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

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. Changed2 schema fields changedv2.22.19
    • removedInput schema / properties / frame / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "number"
      -  }
      -]
    • addedInput schema / properties / frame / type
      Added value: +[
      +  "string",
      +  "number"
      +]
  2. 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."
      +}
  3. 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"
      +}
  4. Addedv2.11.6
  5. Removedv2.11.3
  6. Addedv2.10.9
  7. Removedv2.10.8
  8. Addedv2.10.5
  9. Removedv2.10.4
  10. First observed

TDQS

A4.4/5.0
Behavior4/5

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

With no annotations, the description carries the full behavioral burden and does well on execution semantics: Promise awaiting, fetch/timer behavior in background tabs, requestAnimationFrame limitation, and AppleScript fallback under CSP. It still omits safety-relevant details such as arbitrary script side effects and return-value serialization, preventing a 5.

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?

Three dense sentences, front-loaded with the core action and followed by important caveats and alternatives. Every sentence earns its place with no repetition or filler.

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 parameter-complete tool with no output schema or annotations, the description covers execution behavior and routing well. It is still missing return-value expectations and a note on page-mutating side effects, which would round out completeness for arbitrary JS execution.

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

Parameters3/5

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

Schema coverage is 100%, so frame, script, and receipt are already documented in the schema. The description adds no parameter-specific meaning beyond 'current page', so the baseline 3 is appropriate.

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?

States a specific verb and resource: execute JavaScript in the current page. It also distinguishes itself from reading and interaction siblings by naming alternatives. An agent can immediately tell what the tool does.

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?

Explicitly says to prefer safari_read_page or safari_snapshot for reading data, and safari_click/safari_fill with refs for interactions. It also covers the CSP fallback case, leaving little ambiguity about when to choose this tool.

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