Skip to main content
Glama
safari-mcp
by tszaks

safari_run_javascript

Execute JavaScript in the active or specified Safari tab to extract data, modify page content, or automate browser interactions.

Instructions

Run JavaScript in the current Safari page.

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_run_javascript"
  }
}

Input Schema

NameRequiredDescriptionDefault
scriptYes
tab_indexNo
window_indexNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.2.0

TDQS

C2.7/5.0
Behavior2/5

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

With no annotations supplied, the description carries the full behavioral burden and does not meet it: it doesn't say whether the script runs in the page's main world, whether the return value is surfaced, whether async/promise results are awaited, or what happens on exceptions. For an arbitrary-code-execution tool whose effects are unbounded and potentially destructive, only the bare minimum ('it runs JS in a page') is disclosed.

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

Conciseness4/5

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

A single front-loaded sentence with no filler or redundancy; every word counts. Its brevity is a virtue for structure but also the root of the specification gaps noted elsewhere.

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

Completeness2/5

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

No output schema, no annotations, and three undocumented parameters mean the description must explain results and targeting behavior — it does neither. For an execution tool with side effects and no structured safety metadata, an agent cannot predict the return shape or the effects of a call.

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

Parameters2/5

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

Schema description coverage is 0% across three parameters, so the description is the only source of meaning — and it says nothing about tab_index or window_index. It even says 'the current' page, which gives no hint that the caller can target a different tab or window at all, leaving two of three parameters unexplained in both schema and prose.

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

Purpose4/5

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

The description names a specific verb (Run) and resource (JavaScript) plus a target (the current Safari page), so the agent can tell this apart from page-reading siblings like safari_get_page_html or DOM-manipulation siblings like safari_click_element. It stops short of differentiating scope, though: it never says why executing script is preferable to the dedicated wrappers that wrap common script operations.

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

Usage Guidelines2/5

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

No when-to-use guidance at all — nothing about when arbitrary JS is the right choice versus safari_get_page_content, safari_query_elements, or safari_extract_links, which cover common intents. There are also no stated prerequisites, such as whether 'Allow JavaScript from Apple Events' must be enabled or whether the page must be loaded before the call.

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