Skip to main content
Glama
yfmeii

WeChat Mini Program Dev MCP

by yfmeii

page_callMethod

Call a method exposed on the current page instance. Pass method name and arguments as an array to execute page-specific functions.

Instructions

调用当前页面实例上暴露的方法。参数可以作为数组提供。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionNo
methodYes
argsNo

Implementation Reference

  • Function that creates the 'page_callMethod' tool. The execute handler calls page.callMethod(args.method, ...callArgs) and returns the result.
    function createCallPageMethodTool(manager: WeappAutomatorManager): AnyTool {
      return {
        name: "page_callMethod",
        description: "调用当前页面实例上暴露的方法。参数可以作为数组提供。",
        parameters: callPageMethodParameters,
        execute: async (rawArgs, context: ToolContext) =>
          withUserErrorResult(async () => {
          const args = callPageMethodParameters.parse(rawArgs ?? {});
          const callArgs = args.args ?? [];
          return manager.withPage<ContentResult>(
            context.log,
            { overrides: args.connection },
            async (page) => {
              let result;
              try {
                result = await page.callMethod(args.method, ...callArgs);
              } catch (error) {
                const message = error instanceof Error ? error.message : String(error);
                throw new UserError(`调用页面方法 "${args.method}" 失败: ${message}`);
              }
              return toTextResult(
                formatJson({
                  method: args.method,
                  arguments: callArgs,
                  result: toSerializableValue(result),
                })
              );
            }
          );
          }),
      };
    }
  • Zod schema for the 'page_callMethod' tool parameters: 'method' (required string) and 'args' (optional array of unknown values).
    const callPageMethodParameters = connectionContainerSchema.extend({
      method: z.string().trim().min(1),
      args: z.array(z.unknown()).optional(),
    });
  • The 'page_callMethod' tool is registered via createCallPageMethodTool(manager) in the createPageTools array export.
    export function createPageTools(manager: WeappAutomatorManager): AnyTool[] {
      return [
        createGetElementTool(manager),
        createGetElementsTool(manager),
        createWaitForElementTool(manager),
        createWaitForTimeoutTool(manager),
        createGetPageDataTool(manager),
        createSetPageDataTool(manager),
        createCallPageMethodTool(manager),
      ];
Behavior2/5

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

No annotations are provided, so the description must carry the full burden of behavioral disclosure. It only states the basic action (call a method) and that args can be an array, but does not disclose side effects, error behavior (e.g., unknown method), or any requirements like a valid connection. This is insufficient for zero annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very concise (two sentences) and front-loaded with the purpose. However, given the complexity of the tool (many schema properties), it is under-specified. Every sentence earns its place but more structure (e.g., listing important connection options) would help.

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

Completeness1/5

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

The tool is complex with a nested connection object and three parameters, yet the description provides almost no additional context beyond a one-line summary. There is no output schema, so the description should explain return values or behavior, which it does not. The description is far from complete for an agent to use correctly.

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

Parameters1/5

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

Schema description coverage is 0%, meaning the description adds no meaning to the three parameters (connection, method, args). It only mentions that 'args can be provided as an array', which is already evident from the schema. The complex 'connection' object is completely unexplained, and the 'method' field is not elaborated. With 0% coverage, the description should compensate heavily but fails.

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 verb 'call' and the resource 'methods exposed on the current page instance'. It is not a tautology and provides a specific action. However, it does not differentiate from sibling tool 'element_callMethod', which calls methods on elements, so it loses a point.

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 like 'element_callMethod' or when not to use it. There is no mention of context, prerequisites, or exclusions, leaving the agent without decision support.

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