mp_callWx
Execute WeChat Mini Program API methods to automate development tasks, enabling AI assistants to interact with and control mini program components through the miniprogram-automator interface.
Instructions
调用微信小程序 API 方法。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connection | No | ||
| method | Yes | ||
| args | No |
Implementation Reference
- src/tools/application.ts:215-235 (handler)The execute handler for the 'mp_callWx' tool. It parses input arguments, invokes the miniProgram.callWxMethod with the specified method and args, formats the result, and returns it as text content.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: connection (from common), required method string, and optional array of arguments.const callWxMethodParameters = connectionContainerSchema.extend({ method: z.string().trim().min(1), args: z.array(z.unknown()).optional(), });
- src/tools/application.ts:211-236 (registration)The tool object definition and registration within createCallWxMethodTool function, specifying name 'mp_callWx', description, parameters schema, and execute handler.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:60-60 (registration)Registration of the mp_callWx tool by including it in the array returned by createApplicationTools.createCallWxMethodTool(manager),
- src/tools.ts:9-9 (registration)Top-level registration where application tools, including mp_callWx, are composed into the full tools array....createApplicationTools(manager),