Skip to main content
Glama

element_getBoundingClientRect

Retrieve bounding rectangle of elements after CSS transforms, with dataset and ID. Supports cross-component selectors for accessing UI element dimensions and bound data.

Instructions

获取元素相对视口的边界矩形(left/top/width/height/right/bottom),为 CSS transform 变换后的实际渲染尺寸与位置。返回还包含 dataset(元素完整 data-* 绑定对象,含对象型值)与 id——这是读取卡片/组件绑定数据(如 plateCode/path/cardStyle)的便捷途径,优于 element_getAttributes(后者对对象型 data-* 只能拿到 '[object Object]')。支持跨组件查询:selector 设为组件选择器、innerSelector 设为内部元素选择器(内部用 >>> 穿透,比 selectComponent 更可靠)。仅支持 ID 选择器、类选择器。selector 支持 [index=N],但底层 SelectorQuery 无法可靠表达“第 N 个父元素里的 innerSelector”,因此 [index=N] 不能与 innerSelector 同时使用。选择器查询未返回矩形时抛错;微信 SelectorQuery 无法可靠区分元素不存在与 display:none。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
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?

没有注解,描述承担全部行为披露责任。完整说明了返回值(rect、dataset、id)、错误行为、跨组件查询机制(内部使用>>>)、选择器限制以及[index=N]的限制。对行为的透明性非常好。

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?

描述为一段长文本,但信息组织有序,先核心功能后细节,每句话都有价值。可以更结构化(如分点),但整体仍算简洁有效。

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?

对于没有输出schema的工具,描述完整涵盖了返回值、边角情况、错误处理、跨组件用法和选择器限制,没有明显信息缺口。

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覆盖率仅25%(只有connection有描述),描述中对selector和innerSelector的用法提供了额外含义,但未提及maxBytes参数。整体上,描述为selector和innerSelector增加了语义,弥补了schema的不足,但遗漏了一个参数。

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?

明确说明工具功能:获取元素相对视口的边界矩形(left/top/width/height/right/bottom),并强调是CSS transform后的实际渲染尺寸。还提到返回dataset和id,并对比了element_getAttributes,清晰区分了用途。

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?

提供了详尽的使用指导:说明何时使用此工具(读取卡片/组件绑定数据),对比了element_getAttributes的不足;支持跨组件查询的用法(selector和innerSelector);明确限制(仅支持ID/类选择器,[index=N]不能与innerSelector共用);以及错误处理(未返回矩形时抛错,无法区分元素不存在与display:none)。

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