Skip to main content
Glama

page_callMethod

Execute methods exposed on current page instances within WeChat Mini Program development, passing parameters as arrays for automated testing and interaction.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionNo
methodYes
argsNo

Implementation Reference

  • The execute handler function for the 'page_callMethod' tool. Parses input arguments using the schema, invokes page.callMethod with the method name and arguments via the manager, and returns a formatted JSON response containing the method, arguments, and result.
    execute: async (rawArgs, context: ToolContext) => { const args = callPageMethodParameters.parse(rawArgs ?? {}); const callArgs = args.args ?? []; return manager.withPage<ContentResult>( context.log, { overrides: args.connection }, async (page) => { const result = await page.callMethod(args.method, ...callArgs); return toTextResult( formatJson({ method: args.method, arguments: callArgs, result: toSerializableValue(result), }) ); } ); },
  • Zod schema defining the input parameters for the 'page_callMethod' tool: 'method' (required string) and 'args' (optional array of any values), extending connectionContainerSchema.
    const callPageMethodParameters = connectionContainerSchema.extend({ method: z.string().trim().min(1), args: z.array(z.unknown()).optional(), });
  • Registration of the 'page_callMethod' tool within the createPageTools function, which creates and returns an array of page-related tools including page_callMethod.
    export function createPageTools(manager: WeappAutomatorManager): AnyTool[] { return [ createGetElementTool(manager), createWaitForElementTool(manager), createWaitForTimeoutTool(manager), createGetPageDataTool(manager), createSetPageDataTool(manager), createCallPageMethodTool(manager), ]; }
  • src/tools.ts:7-13 (registration)
    Higher-level registration where createPageTools (including page_callMethod) is incorporated into the main createTools function that aggregates all tools.
    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