Skip to main content
Glama

mp_navigate

Navigate within a WeChat Mini Program and return the active page path and query after navigation. Supports multiple transition types like navigateTo, redirectTo, reLaunch, switchTab, and navigateBack.

Instructions

在小程序内导航并返回导航后的 activePage(path+query)。返回的 activePage 是这次导航 resolve 的真实当前页,可直接信任,无需再调 mp_currentPage 或 mp_evaluate 交叉校验路由。

transition 怎么选:

  • navigateTo(默认):压栈打开新页,可 navigateBack 返回。

  • redirectTo:关掉当前页再打开,不入栈。

  • reLaunch:关掉所有页栈后打开(回首页 / 重置状态用)。

  • switchTab:仅用于 app.json tabBar 里注册的 tab 页,且不支持 query;跳非 tabBar 页会报 'can not switch to no-tabBar page' —— 这种情况改用 navigateTo。(不确定哪些是 tab 页时,custom-tab-bar 项目 tabBar 可能为空,需查 app.json 的 tabBar.list 或 pages。)

  • navigateBack:返回上一页,此时整个省略 path(切勿传空字符串 ""——会被 schema 当作非法 path 拒绝);其余 transition 都必须传 path。

query 用 query 参数传(对象,如 {id:'1'}),会自动拼到 url,不要手动拼进 path;switchTab 除外。

⚠️ waitMs 是 dumb sleep,不是等条件。时序敏感场景(onShow 鉴权 / SSE 初始化 / 异步 setData)建议 waitMs 留小(如 500 给 transition 过渡),再用 mp_pollUntil 等具体条件就绪。若 waitMs 阶段超时,错误里会带 currentRoute 帮你判断导航是否其实已生效。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNo
queryNo
waitMsNo
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。
transitionNonavigateTo
Behavior5/5

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

With no annotations, the description fully discloses behavioral traits: navigation stack behavior, query handling, the nature of waitMs as a 'dumb sleep', error handling with currentRoute, and the reliability of the returned activePage. No contradictions present.

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 sections and bullet points, but slightly lengthy. It front-loads the main purpose and each sentence adds value, though minor redundancy could be trimmed.

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 5 parameters, no output schema, and complex behaviors, the description covers all aspects: parameter details, edge cases (switchTab without query, navigateBack path omission), return value, and references to sibling tools. It is comprehensive and actionable.

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%, but the description adds extensive meaning for all parameters: path (omit for navigateBack), query (object, not hand-stitched), waitMs (dumb sleep, not condition), connection (nested object details), and transition (enum meanings with examples). This compensates fully.

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 the tool's purpose: navigate within a mini-program and return the resulting activePage. It distinguishes from siblings like mp_currentPage and mp_evaluate by explaining that the returned page is trustworthy and eliminates the need for cross-validation.

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?

The description provides explicit guidance on when to use each transition type (navigateTo, redirectTo, reLaunch, switchTab, navigateBack), including scenarios where switchTab fails and alternatives like navigateTo. It also advises on using mp_pollUntil for condition-based waits instead of waitMs.

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