Skip to main content
Glama

element_getAttributes

Read WXML attributes like class, id, or data-index from Mini Program elements. Supports custom component internals using innerSelector.

Instructions

读取元素的 WXML 特性值(element.attribute(name)),如 ['class','id','data-index']。读 CSS 样式请用 element_getStyles。单个读不到的特性返回 null,全部读取失败则报错。结果超过 maxBytes(默认 50000B)会截断。要读自定义组件内部元素的特性,用 selector 定位组件、innerSelector 定位内部元素。selector 支持 [index=N](仅作用于 selector)。⚠️ 对象型 data-*(如 data-item 绑定了对象)经 WXML attribute 只能拿到字符串 '[object Object]'——需要结构化值请改用 element_getBoundingClientRect 返回的 dataset。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namesYes
maxBytesNo
selectorYes
connectionNo可选连接覆盖(不传则用默认会话)。可用字段:mode(launch|connect)、cliPath、projectPath、wsEndpoint、timeout、port(【自动化端口】→ cli auto --auto-port,默认 9420;不是 IDE HTTP 服务端口,别把 IDE 服务端口传进来)、account、ticket、trustProject、args、cwd、autoClose、autoLaunch、launchTimeout、connectTimeout。
innerSelectorNo
Behavior5/5

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

With no annotations, the description fully discloses behavior: returns null for single missing attribute, errors for all missing, truncates results over maxBytes, and notes that object-type data-* attributes return string '[object Object]' via WXML. This exceeds expectations.

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?

The description is fairly concise for the amount of information conveyed, but it is a single block of text without clear separation of concerns. It could benefit from bullet points or structured formatting for easier reading.

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?

Given no output schema, the description explains return values (null for missing, error for all missing, truncation) but does not explicitly state that the result is an object mapping attribute names to values. For a read tool with multiple parameters, it covers most important aspects, but leaves a small gap.

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

Parameters4/5

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

Schema coverage is low (20%), but the description adds meaning for key parameters: names (list of attribute names), maxBytes (truncation threshold), selector/innerSelector (targeting). However, it does not explicitly describe the return type or the format of the results, leaving some ambiguity.

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?

The description clearly states it reads WXML attributes (e.g., class, id, data-index) and distinguishes itself from element_getStyles for CSS styles. The verb '读取' (read) and resource 'WXML 特性值' (WXML attribute values) make the purpose specific.

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?

Explicitly says when to use (read attributes) and when not (CSS styles -> use element_getStyles). Provides guidance on reading custom component inner elements using selector/innerSelector, and warns about object-type data-* attributes, suggesting getBoundingClientRect instead. Also mentions truncation behavior with maxBytes.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Chaixueyuan/weapp-agent-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server