Skip to main content
Glama

mp_recoverConnection

Recovers a degraded or expired connection by rebuilding the automator session, remounting log listener, and restoring project context. Use when health check indicates needsRecovery=true.

Instructions

按标准顺序修复一个已存在但降级/失效的连接:重建 automator 会话 → 重挂日志监听 → 恢复项目上下文,并返回恢复前后对比。

何时用:这是升级修复步——只有当 mp_healthCheck 显示 needsRecovery=true 时调它,而不是只看 summary='degraded' 就重连。 何时不用:首次“建立连接”不要用本工具,用 mp_ensureConnection(它才负责自动拉起 IDE);连接全绿但截图失败且 needsRecovery=false 时也不要用,重连无法修复截图通道。与 ensure(reconnect=true) 的区别:本工具跑一套有序修复并报告 before/after,ensure 只是把会话弄就绪。

⚠️ 副作用(launch 模式):重连会退出并重新 launch 小程序(App.exit + 关 IDE 窗口 → cli auto 冷启),页面栈被重置回项目的启动/入口页 —— 当前所在页 / reLaunch 的现场会丢失。所以仅在连接确实降级失效(needsRecovery=true)时用;若只是想保留当前页、连接其实没坏,不要用本工具。connect 模式(配置了 wsEndpoint)只断开重连 WS、不重启小程序,不丢页。

返回 JSON 含 ok / recovered、actions、before/after 状态、health.summary、warnings/errors。recovered=true 只表示连接恢复完成;若历史截图仍失败,health.summary 会保持 degraded 但 needsRecovery=false。recovered=false 说明连接修复未完成——此时不要无限重试,确认开发者工具确实在运行,必要时反馈给用户。

参数:reconnect 默认 true(丢弃旧会话重连);设 false 仅在不想强制重连、只想跑其余修复步骤时用。connection 可选,覆盖默认连接参数。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
reconnectNo
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。
Behavior5/5

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

Since no annotations are provided, the description fully covers behavioral traits. It explains side effects in launch mode (app exit and relaunch, loss of current page stack) versus connect mode (only WS reconnection). It also clarifies the meaning of recovery results, warnings about infinite retries, and the conditions under which health may remain degraded.

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 fairly long but well-structured with clear sections. Each sentence contributes meaningful information, and the structure aids readability. It could be slightly more concise, but the complexity of the tool justifies the length.

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?

The description is highly complete given the tool's complexity. It explains the return JSON structure, the meaning of recovery flags, and provides guidance on handling failures. It also addresses edge cases and potential pitfalls, 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?

The description adds significant meaning beyond the input schema. It explains the default value and purpose of the reconnect parameter, and provides detailed explanations for fields in the connection object, including warnings about the port parameter. This is especially valuable given the nested object and the need to clarify parameter usage.

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: to repair an existing but degraded or failed connection by following a standard sequence of steps. It explicitly lists the actions (rebuild automator session, remount log listener, restore project context) and mentions that it returns a before/after comparison. This differentiates it from sibling tools like mp_ensureConnection and mp_diagnoseConnection.

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 this tool (only when mp_healthCheck shows needsRecovery=true) and when not to use it (for first-time connections, or when needsRecovery=false). It also distinguishes between this tool and others like mp_ensureConnection and the ensure(reconnect=true) variant, clearly specifying the appropriate contexts.

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