Skip to main content
Glama
yfmeii

WeChat Mini Program Dev MCP

by yfmeii

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),
      ];
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the output behavior (inline image or file save) which is valuable, but doesn't address critical aspects like whether this requires specific permissions, if it's a read-only operation, potential side effects, error conditions, or performance characteristics.

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 appropriately brief with two clear clauses. The first sentence states the core purpose, and the second explains output options. There's no wasted verbiage, though it could be more front-loaded with critical information about parameters or prerequisites.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with complex parameters (nested object with 12 properties), 0% schema coverage, no annotations, and no output schema, the description is inadequate. It doesn't explain the connection requirements, parameter meanings, error handling, or what the output looks like beyond basic format options.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage and 2 parameters (including a complex nested 'connection' object with 12 properties), the description provides no information about parameters. It doesn't explain what 'connection' or 'path' mean, their purposes, or how they affect the screenshot operation, leaving significant gaps in understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('截取' - capture/screenshot) and target ('当前小程序视口' - current mini-program viewport), providing specific verb+resource. However, it doesn't explicitly differentiate from sibling tools like element_getWxml or page_getElement that might also retrieve visual/structural information.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There's no mention of prerequisites (like needing an active connection), comparison to similar tools, or scenarios where this is appropriate versus other screenshot or data retrieval methods.

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

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