Skip to main content
Glama

页面元素基础交互

interact_element
Destructive

Perform DOM actions in a browser page—click, fill, wait, hover, select, press, type, or read text—using Playwright selectors. Failed actions return structured errors with screenshots for easier retry.

Instructions

在当前页面上执行基础 DOM 操作。action 取值:click=点击;fill=填写输入框(自动兼容受控组件,失败会降级为模拟键入);wait_for=等待元素出现/可见/隐藏;hover=鼠标悬停;select=选择下拉项(text 传选项文案);press=发送按键(text 传按键名,如 Enter);type=用真实键盘事件逐字输入(专用于 xterm/Canvas 这类"看不见输入框"的 Web 终端,例如腾讯云 OrcaTerm 在线终端;selector 传终端容器用于点击取得焦点,传 body 表示直接往当前焦点输入,配合 submit=true 会在输入完按 Enter);get_text=读取元素文本。selector 支持 Playwright 全部选择器语法:CSS、text=文字、xpath=//...、以及 :has-text() 等扩展伪类。所有操作失败时返回结构化错误并附上当前页面截图,便于 LLM 修正选择器后重试。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nthNo匹配到多个元素时取第几个(从 0 开始),默认 0。
textNofill 的填写内容(空串表示清空);select 的选项文案;press 的按键名;type 要输入的内容(可含 shell 命令)。click/wait_for/hover/get_text 不需要。
delayNo仅 type 有效:每个字符之间的间隔毫秒数,默认 30;Web 终端建议不要低于 20,否则可能丢字符。
forceNo常规点击被遮挡时是否降级为 force 点击(默认 true,会在返回中标注)。
stateNo仅 wait_for 有效:等待的目标状态,默认 visible。visible
actionYes要执行的动作。
submitNo仅 type 有效:输入完成后是否按一次 Enter(提交 shell 命令用),默认 false。
cdpPortNo可选:CDP 调试端口。省略时沿用当前已连接的端口(从未连接过则为 9222)。
selectorYes元素选择器,例如 "button:has-text('保存')"、"#login-email"、"xpath=//input[@name='q']"。
timeoutMsNo超时毫秒数,默认 10000。
pageUrlContainsNo可选但强烈建议在多标签场景下使用:用 URL 片段指定要操作的标签页(例如 "orcaterm" 指 Web 终端、"lighthouse" 指控制台)。不传时工具按"刚新打开的标签页 → 上次操作过的标签页 → 最后一个普通标签页"的顺序自动选择,可能会选错。
frameUrlContainsNo可选:目标元素位于 iframe 内时,用 URL 片段定位对应 frame。

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.5/5.0
Behavior5/5

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

Adds substantial context beyond the destructiveHint=true annotation: failed operations return structured errors with a page screenshot to enable retry, clicks degrade to force-click when obstructed (and mark it in the return), fill degrades to simulated typing, and the tab auto-selection order is disclosed along with a delay floor of 20ms for web terminals to avoid dropped characters. The mutation actions align with destructiveHint=true, so there is no contradiction with the annotations.

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?

A single dense paragraph that front-loads the core purpose, then flows coherently through action semantics, selector syntax, and error behavior. Given the tool's complexity (12 parameters, 9 action enums), the length is proportional — every sentence carries operational content and nothing is redundant. It could marginally benefit from bulleted structure, but the density is justified.

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?

For a 12-parameter tool with no output schema, the description achieves strong coverage: per-action semantics, selector grammar, degradation paths, tab disambiguation (pageUrlContains), iframe targeting (frameUrlContains), and error-return format. Two minor gaps remain — the undocumented 'reload' action and the unsaid success return payload (e.g., what get_text returns) — but neither blocks a competent agent from calling the tool correctly.

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 100%, so the baseline is 3; the description earns a point above baseline by giving operational meaning the schema lacks. The schema's action field only says '要执行的动作', while the description explains what each action does and how text/delay/submit apply per action, plus the full selector grammar (CSS, text=, xpath=, :has-text()). The only gap is that 'reload' appears in the enum but is absent from the description's action enumeration, leaving the agent to infer its meaning from the English name alone.

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 and resource — '在当前页面上执行基础 DOM 操作' (execute basic DOM operations on the current page) — and then enumerates nearly all actions (click, fill, wait_for, hover, select, press, type, get_text) with one-line semantics each. This sharply separates it from functionally distinct siblings like connect_edge, take_screenshot, and add_dns_record, so an agent knows at a glance this is the page-interaction tool.

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

Usage Guidelines4/5

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

Provides strong action-selection guidance: type is explicitly scoped to xterm/Canvas web terminals (Tencent Cloud OrcaTerm), fill is described as auto-compatible with controlled components with a degradation fallback, and pageUrlContains is flagged as strongly recommended in multi-tab scenarios with the auto-selection order spelled out and an honest '可能会选错' warning. It does not explicitly name sibling tools as when-not-to-use alternatives, but the siblings are functionally distinct enough that little exclusion guidance is needed.

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