Skip to main content
Glama

safari_evaluate

Execute JavaScript in the current Safari page via AppleScript to run scripts where CSP blocks injection, supporting awaited promises and background-tab fetch/timers.

Instructions

Execute JavaScript in the current page (a returned Promise is awaited — fetch/timers work in background tabs; requestAnimationFrame never fires there). Runs through AppleScript (the extension bridge is off in Daylight), which works where CSP blocks injected scripts (e.g. Google Search Console, LinkedIn). For reading data, prefer safari_read_page or safari_snapshot. For interactions, prefer safari_click/fill with refs.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "script": "<script>"
    },
    "name": "safari_evaluate"
  }
}

Input Schema

NameRequiredDescriptionDefault
frameNoNot available in Daylight (the extension bridge is off): a call that passes it is refused. Scripts run in the main document.
scriptYesJavaScript code to execute
receiptNoOmit it: Daylight has no tab receipts and refuses a call that passes one

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

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 burden and does substantial work: it discloses that returned Promises are awaited, that fetch/timers run in background tabs while requestAnimationFrame never fires, that execution goes through AppleScript, and that CSP-blocked pages are handled. It stops short of describing result serialization or error behavior on script exceptions, so not quite full coverage.

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 with the core action front-loaded, followed by execution semantics and then routing guidance. Every clause carries operational information; nothing is redundant.

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 no-annotation, no-output-schema execution tool, the description covers the runtime model, tab-visibility quirks, AppleScript backend, CSP behavior, and sibling routing. The main remaining gap is what the call returns or how script errors surface, but the essentials an agent needs to invoke it correctly are present.

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 description coverage is 100%, so the schema already documents 'script', 'frame', and 'receipt', including that frame/receipt are refused in Daylight. The description reinforces the environment constraint but adds no new meaning about parameter formats or values beyond the structured fields. Baseline 3 applies.

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' — and immediately delineates it from the read/interaction siblings by name. An agent can identify this as the escape-hatch execution tool without inspecting the schema.

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?

Names concrete alternatives and the conditions that select them: safari_read_page/safari_snapshot for reading data, safari_click/fill with refs for interactions. This is explicit when-to-use and when-not-to-use guidance rather than implied usage.

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