Skip to main content
Glama

Robot Actions — Remote Device Control

iOS Safari evaluate

ios_safari_evaluate
Destructive

Evaluate a JavaScript expression in the context of a Safari page on an iOS device via the Web Inspector. Uses Runtime.evaluate internally. Returns the result as a string (JSON-stringified for objects), followed by a second block naming the tab it actually ran on, read live from that page — check it if a result looks like it came from the wrong page. Omit pageId to auto-pick the frontmost Safari tab. An expression that evaluates to a promise IS awaited, so fetch(...).then(r => r.json()) returns the parsed body rather than an empty object; a promise still pending when the call times out is reported as such instead of being silently returned empty. WAITING: UI frameworks paint a frame or two AFTER the click that triggers them, so an evaluate fired immediately can read the DOM before the menu/overlay/row exists. Use waitForSelector to block until an element appears (and waitMs to let it settle) INSTEAD of splitting the work into a separate poll call — both wait inside this same call on the same tab. DO NOT CLICK WITH THIS TOOL. A click dispatched from JavaScript — .click(), or dispatchEvent of a MouseEvent — is an untrusted event (isTrusted false). Component frameworks and anything gated on a real user gesture (file pickers, clipboard, autoplay, anti-bot checks) may ignore it, so the evaluate SUCCEEDS and the page does nothing — a failure that looks like a passing call. Use webpage_click instead: it has the device tap its own screen at the element, delivering a real trusted touch (pointerdown, touchstart, mousedown, click). Same for typing — webpage_type.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
udidYesiOS device UDID
pageIdNoCDP target id from ios_safari_list_pages. Omit it to use the page ios_safari_navigate last landed on (or, failing that, the first loaded page) — only pass it to target a DIFFERENT tab
waitMsNoSettle delay applied just before evaluating (and AFTER waitForSelector matches, when both are given). Use for animations that have started but not finished. Maximum 10000 ms
expressionYesJavaScript expression to evaluate
waitTimeoutMsNoHow long waitForSelector may poll. Default 5000 ms, maximum 15000 ms
platformVersionNoIgnored (kept for compatibility)
waitForSelectorNoCSS selector to wait for BEFORE evaluating. Polls until it matches, then runs the expression. Errors if it never appears within waitTimeoutMs — it will not evaluate anyway and hand back a null that reads like a real answer

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changed
    • addedInput schema / properties / waitForSelector
      Added value: +{
      +  "description": "CSS selector to wait for BEFORE evaluating. Polls until it matches, then runs the expression. Errors if it never appears within waitTimeoutMs — it will not evaluate anyway and hand back a null that reads like a real answer",
      +  "type": "string"
      +}
    • addedInput schema / properties / waitMs
      Added value: +{
      +  "description": "Settle delay applied just before evaluating (and AFTER waitForSelector matches, when both are given). Use for animations that have started but not finished. Maximum 10000 ms",
      +  "maximum": 10000,
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • addedInput schema / properties / waitTimeoutMs
      Added value: +{
      +  "description": "How long waitForSelector may poll. Default 5000 ms, maximum 15000 ms",
      +  "maximum": 15000,
      +  "minimum": 0,
      +  "type": "integer"
      +}
  2. Changed1 schema field changed
    • changedInput schema / properties / pageId / description
      Previous value: -"CDP target id from ios_safari_list_pages — auto-picked when omitted"New value: +"CDP target id from ios_safari_list_pages. Omit it to use the page ios_safari_navigate last landed on (or, failing that, the first loaded page) — only pass it to target a DIFFERENT tab"
  3. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Discloses behavior well beyond the annotations: promises are awaited, a pending-promise-at-timeout is reported rather than returned empty, a second block names the tab the expression actually ran on, and the untrusted-event failure mode where a JS click 'SUCCEEDS and the page does nothing'. These are exactly the non-obvious traits annotations cannot convey.

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?

Front-loaded with the core operation, then organized into clear constraint blocks (WAITING, DO NOT CLICK). Every section carries a specific gotcha, but the prose is dense and long enough that it tips past minimal, keeping it out of the top band.

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

Completeness5/5

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

For a complex evaluate tool with no output schema, the description fully covers the return format (string, JSON-stringified objects, tab-name block), timing behavior, and the critical trusted-vs-untrusted input pitfall. An agent has everything needed to call it correctly and interpret results.

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 udid, pageId, waitMs, waitTimeoutMs, and waitForSelector in detail. The description restates the auto-pick/tab-selection behavior for pageId and the wait semantics but adds little syntax beyond what the schema provides, so the baseline of 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 (evaluate) and resource (JavaScript expression in a Safari page on an iOS device), and names the mechanism (Web Inspector / Runtime.evaluate). An agent can distinguish it from ios_safari_elements, ios_safari_get_dom, and webpage_cdp_command without opening the 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?

Explicit routing guidance: 'Use waitForSelector ... INSTEAD of splitting the work into a separate poll call', 'DO NOT CLICK WITH THIS TOOL ... Use webpage_click instead', and 'Same for typing — webpage_type'. It names when to use the tool, when not to, and the concrete alternatives, satisfying the highest bar for this dimension.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources