Skip to main content
Glama

mp_pollUntil

Poll page data or evaluate a predicate repeatedly until a condition is met, then optionally run an action and capture before/after snapshots of specified data paths.

Instructions

通用 wait-for-condition / waitData 工具:轮询执行 predicate(返回任意真值即命中)直到命中或超时,可选在命中后执行 action,并按 snapshotPaths 拍 before/after 快照。典型场景:等 page.data 某字段变化(predicate 写 function(){ return getCurrentPages().pop().data.conversationHistory.length === 1 })、等异步状态切换、等 SSE 流式中段、时序敏感打断。

predicate / action 是 function 源码字符串,跑在 AppService(可用 getCurrentPages、wx 等);predicateArgs / actionArgs 是按顺序展开给这两个函数的入参数组。轮询由 server 端管理,重连不留脏 setInterval。

predicate 与 dataPath 二选一:若该环境 evaluate 注入通道不可用(对任意函数都报 'is not a function'),改用 dataPath 直接轮询 page.data 的某条路径(SDK 端单路径投影,不走 evaluate)——dataEquals 省略时按真值命中、给了则与该值 deep-equal 命中(可精确等 false/0/null)。注意:命中后的 action 仍走 evaluate,evaluate 不可用时只用 dataPath+snapshotPaths(snapshot 读 page.data、不依赖 evaluate)。

snapshotPaths 走点路径取值,支持 [N] 下标、负索引、[*] 通配(如 conversationHistory[*].aiStatuslist.length);before = predicate 命中时刻的 page.data,after = action 跑完且等 snapshotAfterMs 后的 page.data(snapshotAfterMs 给异步 setData 留时间,默认 0,上限 60000,仅在传 snapshotPaths 时有效)。结果超过 maxBytes(默认 50000B)会截断。

注意:timeoutMs(默认 15s,上限 600s)是 predicate、action、等待和快照的整体预算;若比单次 evaluate 还短,可能只跑 1 次 predicate 就超时。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionNo
dataPathNo
maxBytesNo
predicateNo
timeoutMsNo
actionArgsNo
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。
dataEqualsNo
predicateArgsNo
snapshotPathsNo
pollIntervalMsNo
snapshotAfterMsNo
Behavior5/5

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

With no annotations, the description fully discloses behavior: polling mechanism, predicate/action as function strings, dataPath fallback, snapshot feature with before/after, timeouts, size limits, and connection handling. It warns about edge cases like timeout being too short or evaluate unavailability.

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 lengthy but well-structured with markdown formatting and front-loaded summary. While there is some redundancy, it remains organized and each sentence adds value given the tool's complexity.

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?

Given 12 parameters, no output schema, and high complexity, the description is remarkably complete. It covers all major behaviors, parameter interactions, fallback logic, and edge cases, leaving little ambiguity for the agent.

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

Parameters5/5

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

Schema coverage is only 8%, but the description adds extensive meaning to all 12 parameters: explains predicate/action as source strings, dataPath for direct polling, dataEquals for exact match, snapshotPaths with wildcard syntax, and parameter interactions. This compensates fully for the low schema coverage.

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 is a '通用 wait-for-condition / waitData 工具' and lists typical scenarios like waiting for page.data field changes, async state switches, and SSE streaming. It distinguishes itself from sibling tools like page_waitElement and page_waitRoute by being a generic polling tool that can use predicates or data paths.

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?

The description provides good guidance on when to use predicate vs dataPath (when evaluate is unavailable), typical scenarios, and constraints like timeoutMs and maxBytes. However, it does not explicitly compare to sibling wait tools, so usage context is clear but not exhaustive.

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