Skip to main content
Glama

mp_screenshot

Screenshot the current mini program viewport. Returns inline image or saves to file, creating parent directories as needed.

Instructions

截取当前小程序视口截图。需已有活动会话(无会话先 mp_ensureConnection)。不传 path 返回内联图片(image content);传 path 则存文件并返回 JSON {ok,path,route} —— 此时拿不到图像本身,route 为可空诊断字段。 父目录不存在会自动 mkdir -p;文件模式会验证输出存在且非零字节后才返回成功。

⚠️ 截图是单通道串行能力:全局一次只跑一个,不要并发拍图;超时后也不要立刻重发(底层那条超时请求仍占着单通道,再发会互相打乱)—— 等本次调用返回再说。截图前不会额外读取 currentPage,避免非必要请求先占住截图通道。仅支持开发者工具模拟器(客户端环境可能返回 EMPTY_OUTPUT)。

失败时返回 reasonCode 并附可操作建议:SCREENSHOT_TIMEOUT、SIMULATOR_HIDDEN、RENDERER_NOT_READY、LOCAL_OUTPUT_ERROR、EMPTY_OUTPUT、UNKNOWN。只有 RENDERER_NOT_READY 会自动重试一次;本地输出错误不会计入截图通道连续失败。连续 2 次拿不回帧后,后续截图会直接返回 SCREENSHOT_UNAVAILABLE 跳过;确认环境恢复后传 force:true 再试。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNo
forceNo
timeoutMsNo
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?

With no annotations provided, the description carries full burden and excels: it discloses single-channel serial execution (no concurrency), timeout handling, failure reason codes with actionable advice, auto-retry only for RENDERER_NOT_READY, error counting leading to SCREENSHOT_UNAVAILABLE, and the effect of force. It also states that it does not read currentPage to avoid blocking the channel. This is comprehensive behavioral transparency.

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 each sentence adds value. It is well-structured with warnings in bullet-style and a clear list of error codes. The main purpose is front-loaded, and details are organized logically. Slightly verbose but not wasteful.

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 tool's complexity (multiple modes, error handling, concurrency constraints, no output schema), the description covers all critical aspects: input/output behavior, error codes and their meaning, auto-retry logic, error counting with force flag, environment limitations, and prerequisite checks. An agent can make an informed decision without additional info.

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 only 25%, so the description must compensate. It thoroughly explains 'path' (inline vs file storage) and 'force' (reset error counter). 'timeoutMs' and 'connection' are not explained in the description, but 'connection' has a detailed description in the schema. The description adds significant meaning beyond the schema for the two key parameters.

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 action ('截取当前小程序视口截图') and resource, distinguishing it from all sibling tools (none of which are screenshot-related). It also explains two operational modes depending on the 'path' parameter, providing full clarity.

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 explicit when-to-use guidance: requires an active session (referencing mp_ensureConnection), warns against concurrency due to single-channel serialization, advises not to resend after timeout, and notes it only works in devtools simulator. It also explains the force flag for recovery. While it doesn't explicitly name alternatives, no other screenshot tool exists, so the guidance is sufficient.

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