Skip to main content
Glama

mp_screenshot

Capture screenshots of WeChat Mini Program viewports for debugging and documentation purposes. Returns inline images or saves to specified file paths to help developers verify UI appearance and identify visual issues.

Instructions

截取当前小程序视口的截图。默认返回内联图片,或保存到文件路径。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionNo
pathNo

Implementation Reference

  • Full definition of the mp_screenshot tool, including its handler (execute function) that captures screenshot of the mini program viewport using miniProgram.screenshot(), handles base64 output as image content or saves to file.
    function createScreenshotTool(manager: WeappAutomatorManager): AnyTool { return { name: "mp_screenshot", description: "截取当前小程序视口的截图。默认返回内联图片,或保存到文件路径。", parameters: screenshotParameters, execute: async (rawArgs, context: ToolContext) => { const args = screenshotParameters.parse(rawArgs ?? {}); return manager.withMiniProgram<ContentResult>( context.log, { overrides: args.connection }, async (miniProgram) => { const output = await miniProgram.screenshot( args.path ? { path: args.path } : undefined ); if (typeof output === "string") { const buffer = Buffer.from(output, "base64"); const image = await imageContent({ buffer }); return { content: [image] }; } if (args.path) { return toTextResult(`截图已保存到 ${args.path}`); } throw new UserError("截图未产生图片数据。"); } ); }, }; }
  • Parameters schema for mp_screenshot: extends shared connection schema with optional path to save screenshot.
    const screenshotParameters = connectionContainerSchema.extend({ path: z.string().trim().min(1).optional(), });
  • Registration of mp_screenshot within createApplicationTools by calling createScreenshotTool(manager).
    export function createApplicationTools( manager: WeappAutomatorManager ): AnyTool[] { return [ createEnsureConnectionTool(manager), createNavigateTool(manager), createScreenshotTool(manager), createCallWxMethodTool(manager), createGetConsoleLogsTool(manager), ];
  • src/tools.ts:7-13 (registration)
    Top-level registration where application tools (including mp_screenshot) are included in the full tools list.
    export function createTools(manager: WeappAutomatorManager): AnyTool[] { return [ ...createApplicationTools(manager), ...createPageTools(manager), ...createElementTools(manager), ]; }

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/yfmeii/weapp-dev-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server