Skip to main content
Glama

Evaluate JS in Webview

webview_evaluate
Destructive

Executes JavaScript in a mobile WebView and returns the JSON result, including resolved promises. Supports older Chrome versions by avoiding modern syntax.

Instructions

在 webview 页面执行 JS 并返回 JSON 结果(Runtime.evaluate,returnByValue+awaitPromise)。⚠ chrome68 老机型禁用 ?./??,用 a&&a.b。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceYes目标设备 serial(同 mobile_list_available_devices 的 id)
expressionYesJS 表达式,如 location.hash 或 (function(){...})()

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.0.1

TDQS

A3.5/5.0
Behavior3/5

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

Annotations include destructiveHint: true, indicating potential destructive effects. The description does not explain what might be destructive, leaving the agent uncertain. It does provide useful technical details like using returnByValue and awaitPromise, and warns about JS syntax limitations on old devices, which adds value. No contradiction with annotations, but could better clarify side effects.

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 concise and information-dense, with no fluff. It front-loads the main action and technical details, then adds a critical compatibility warning at the end. Every word earns its place.

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

Completeness3/5

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

Given no output schema, the description mentions it returns JSON, which is helpful. However, it does not specify the exact structure of the return value (e.g., whether it includes exceptions, result object). It also lacks behavioral details about side effects, which is important due to destructiveHint. The description is adequate but not complete.

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?

The schema description coverage is 100%, so parameters are already documented. The description adds an example of expression format and the meaning of device serial, but the schema already provides that. Minimal added value beyond schema.

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 clearly states the tool evaluates JavaScript in a webview and returns JSON results, specifying the protocol method and options. It mentions execution context and return behavior. It does not explicitly differentiate from sibling tools like webview_click_text or webview_get_computed_style, but the focus on arbitrary JS evaluation is distinct enough.

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

Usage Guidelines3/5

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

The description implies usage for running JavaScript in a webview but does not state when to prefer this over alternatives, such as using dedicated tools for clicking or styling. It also does not mention prerequisites like needing a webview connection (via webview_connect). The warning about old devices is a usage constraint but not for alternative selection.

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