mp_callWx
Execute WeChat Mini Program API methods to automate development tasks, enabling navigation, inspection, and manipulation of pages and components through the miniprogram-automator API.
Instructions
调用微信小程序 API 方法。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connection | No | ||
| method | Yes | ||
| args | No |
Implementation Reference
- src/tools/application.ts:210-237 (handler)The createCallWxMethodTool function defines and returns the tool object for 'mp_callWx', including the execute handler that parses parameters, uses the manager to call the miniProgram's callWxMethod, and returns formatted result.function createCallWxMethodTool(manager: WeappAutomatorManager): AnyTool { return { name: "mp_callWx", description: "调用微信小程序 API 方法。", parameters: callWxMethodParameters, execute: async (rawArgs, context: ToolContext) => { const args = callWxMethodParameters.parse(rawArgs ?? {}); return manager.withMiniProgram<ContentResult>( context.log, { overrides: args.connection }, async (miniProgram) => { const callArgs = args.args ?? []; const result = await miniProgram.callWxMethod( args.method, ...callArgs ); return toTextResult( formatJson({ method: args.method, arguments: callArgs, result: toSerializableValue(result), }) ); } ); }, }; }
- src/tools/application.ts:44-47 (schema)Zod schema defining the input parameters for the mp_callWx tool: extends connectionContainerSchema with required 'method' string and optional 'args' array.const callWxMethodParameters = connectionContainerSchema.extend({ method: z.string().trim().min(1), args: z.array(z.unknown()).optional(), });
- src/tools/application.ts:53-63 (registration)The createApplicationTools function registers createCallWxMethodTool (mp_callWx) into the array of application tools.export function createApplicationTools( manager: WeappAutomatorManager ): AnyTool[] { return [ createEnsureConnectionTool(manager), createNavigateTool(manager), createScreenshotTool(manager), createCallWxMethodTool(manager), createGetConsoleLogsTool(manager), ]; }
- src/tools.ts:7-13 (registration)The createTools function includes application tools (containing mp_callWx) by spreading createApplicationTools.export function createTools(manager: WeappAutomatorManager): AnyTool[] { return [ ...createApplicationTools(manager), ...createPageTools(manager), ...createElementTools(manager), ]; }
- src/index.ts:17-17 (registration)Top-level registration of all tools, including mp_callWx, to the FastMCP server via createTools.server.addTools(createTools(manager));