Skip to main content
Glama

mp_screenshot

Capture screenshots of WeChat Mini Program viewports for debugging or documentation. Returns inline images or saves to specified file paths.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionNo
pathNo

Implementation Reference

  • The createScreenshotTool function returns the mp_screenshot tool object, with the execute handler that performs the screenshot using miniProgram.screenshot, handles base64 output as image content or saves to path.
    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("截图未产生图片数据。"); } ); }, }; }
  • Zod schema for mp_screenshot parameters: optional path for saving screenshot, extends connectionContainerSchema.
    const screenshotParameters = connectionContainerSchema.extend({ path: z.string().trim().min(1).optional(), });
  • The mp_screenshot tool is registered by including createScreenshotTool(manager) in the array returned by createApplicationTools.
    export function createApplicationTools( manager: WeappAutomatorManager ): AnyTool[] { return [ createEnsureConnectionTool(manager), createNavigateTool(manager), createScreenshotTool(manager), createCallWxMethodTool(manager), createGetConsoleLogsTool(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