Skip to main content
Glama

mp_runScenario

Execute a series of mini-program actions (navigate, tap, input) and assertions, then summarize each step's pass/fail. Designed for automated regression testing of short user flows.

Instructions

按顺序执行一组小程序调试/回归步骤,一次调用跑完并汇总每步 pass/fail。用于把一条短链路脚本化复跑(导航→操作→断言);只做单次交互探查请用单个 page_*/element_* 工具。要把结果整理成 markdown 复核产物时改用 mp_generateScenarioReport(参数相同)。

steps[] 每项必带 type,最多 25 步,共 12 种(分动作类与断言类): ● 动作类(不返回 pass,只在抛错时算失败):

  • navigate {path?, query?, transition?=navigateTo|redirectTo|reLaunch|switchTab|navigateBack, waitMs?} — 只有 navigateBack 可省略 path;waitMs 是 dumb sleep,时序敏感场景宁可用 waitRoute 步或拆出来用 mp_pollUntil

  • tap {selector, innerSelector?, waitMs?}

  • input {selector, innerSelector?, value(string|number)}

  • snapshot {selectors?[], dataPaths?[], withData?=false, withElements?=true, withWxml?=false, limit?=10, maxBytes?=50000} — 每个 selector 受 limit 限制,所有 selector 合计最多汇总 100 个元素摘要;超 maxBytes 会截断并返回 note;比独立 page_snapshot 弱

  • getLogs {clear?, contains?, logType?, since?, limit?=100}

  • screenshot {path?, timeoutMs?=30000} — 不传 path 时不回传 base64(只给 note),要图请单独调 mp_screenshot 或传 path 存文件;连续 2 次截图通道失败后会短路 ● 断言类(决定 scenario 整体 ok/pass):

  • waitRoute {path, timeout?=5000, retryInterval?=200} — 轮询直到 route 命中,返回 matched

  • expectRoute {path} — 即时断言当前 route

  • expectVisible {selector} — 命中 ≥1 个即过

  • expectText {selector, expected, mode?=equals|includes}

  • expectCount {selector, expected(整数)}

  • expectData {path, expected} — 必须显式给 expected;path 未解析到值且 expected 省略时直接判失败(避免 undefined===undefined 静默判过)

⚠️ selector 用 page.$ / page.$$,不穿透自定义组件内部;组件内元素用 innerSelector(在父元素内再查),取第 N 个匹配用 selector[index=N] 语法。 ⚠️ 想要真正验证就必须放至少一个断言步:纯动作步全部不抛错也只代表跑通了,ok=true 不等于断言通过。

stopOnFailure 默认 true:遇到首个失败步即停,后续步不执行;设 false 跑完所有步再汇总。scenarioTimeoutMs 控制整体预算,默认 120000ms、最大 600000ms。maxBytes 控制聚合结果大小,默认 500000B。

建议每个 scenario 保持短(≤ ~10 步):snapshot/screenshot 在长链路后段更易超时/抖动 — 拆成多个短 scenario 分段跑。

返回 {ok, totalSteps, executedSteps, passedSteps, failedSteps, results[]},每个 result = {index, type, pass, step, result 或 error}。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stepsYes
maxBytesNo
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。
stopOnFailureNo
scenarioTimeoutMsNo
Behavior4/5

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

No annotations provided, so description carries full burden. It discloses extensive behavioral traits: step types (action vs assertion), return value structure, selector limitations (no custom component penetration, innerSelector, index syntax), screenshot not returning base64 without path, snapshot being weaker, channel failure short circuit, and timeout boundaries. Some details are buried, but overall transparent.

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 well-structured with bullet points and sections (action vs assertion, warnings at end), but it is lengthy and contains some redundancy (e.g., maxBytes mentioned twice). It is front-loaded with purpose but could be slightly more concise without losing detail.

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 the complexity (5 top-level parameters, nested step schemas, no output schema), the description is thorough. It explains all step types, return value, edge cases, and relationships with sibling tools. No missing critical information for agent invocation.

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 description coverage is only 20% (only 'connection' has a description), but the tool's description adds immense value by enumerating all 12 step types with their parameters, defaults, and behavior. It compensates fully for the schema gaps, explaining each parameter's meaning beyond the schema definitions.

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 executes a set of debug/regression steps sequentially, summarizes pass/fail per step, and distinguishes itself from single-use tools like page_*/element_* and from mp_generateScenarioReport for markdown output. The verb 'runScenario' and resource 'scenario' are well-defined.

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 states when to use (scripting a short chain of navigation->action->assertion) and when not to use (single interaction: use individual tools; generating report: use mp_generateScenarioReport). Also provides constraints like max 25 steps, suggests ≤10 steps for reliability, and clarifies stopOnFailure behavior.

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