Skip to main content
Glama

操作或读取页面元素

wdt_element

Target and act on the nth element matching a CSS selector in WeChat DevTools: tap, input, inspect attributes/styles/data, scroll or swipe, trigger events, and call component methods.

Instructions

对匹配 selector 的第 index 个元素执行动作:tap/longpress/input/text/value/attribute/property/style/wxml/outerWxml/size/offset/trigger/scrollTo/scrollWidth/scrollHeight/swipeTo/slideTo/callMethod/callContextMethod/setData/data。slideTo 会补发 change 事件;swipeTo 只改视觉索引。

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": {
      "selector": "<selector>",
      "action": "<action>"
    },
    "name": "wdt_element"
  }
}

Input Schema

NameRequiredDescriptionDefault
xNoscrollTo 的 x
yNoscrollTo 的 y
argsNocallMethod 的参数
dataNosetData 的数据
nameNoattribute/property/style/data 的名称
pathNodata 的路径
typeNotrigger 的事件名
indexNo匹配项下标,默认 0
valueNoinput/slideTo/swipeTo/data 的值
actionYes
detailNotrigger 的 detail
methodNocallMethod 的方法名
selectorYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.2

TDQS

C2.9/5.0
Behavior3/5

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

No annotations are supplied, so the description carries the full burden, and it is silent on permission requirements, error behavior when the selector matches nothing, and side effects of write actions like tap/input/setData. It does add genuine behaviour detail absent from the schema: slideTo 补发 change 事件 vs swipeTo 只改视觉索引, which is exactly the kind of distinction an agent cannot infer. Real but partial coverage of a 22-action, read+write tool.

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

Conciseness2/5

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

The core targeting sentence is front-loaded and useful, but roughly half the text is a raw 22-item action enumeration that merely restates the action enum in the schema, consuming space without adding information. The remaining valuable sentence (slideTo vs swipeTo) is brief and deserves more prominence.

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?

For a 13-parameter tool with 22 actions, an output schema is absent, and the description never says what the read actions (text/value/attribute/wxml/size/offset) return, nor how failures surface when no element matches. Those gaps matter far more for an agent here than for a simpler tool.

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 85%, so the schema already documents that x/y belong to scrollTo, name to attribute/property/style/data, args to callMethod, and so on; the baseline of 3 applies. The description only adds the slideTo/swipeTo semantic difference and the selector/index targeting rule. It still leaves the 22 enum values themselves undocumented in both places.

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 opening states a specific verb and resource: "对匹配 selector 的第 index 个元素执行动作" tells the agent exactly which element is targeted and that the tool both reads and writes. The action list is enumerated rather than summarised, and it does not explicitly distinguish this tool from siblings like wdt_evaluate or wdt_native, so there is no sibling differentiation.

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 guidance is given on when to use wdt_element vs alternatives such as wdt_evaluate, wdt_native, or wdt_query, and no preconditions are stated (for example, that a page or element must exist). The only selection aid is the intra-tool note that slideTo re-dispatches change while swipeTo only adjusts the visual index, which helps choose between actions but not between tools.

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