Call or mock wx APIs
mp_wxCall or mock wx APIs inside a running WeChat Mini Program to control test responses without network calls, then restore or list active mocks.
Instructions
Call a wx API inside the running mini program, or mock one so it returns a fixed result (or runs a function) without touching the network. This is the only request control the WeChat automator exposes: it replaces wx API results, it does not intercept HTTP. Mocks persist for the session; restore or restore_all removes them.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"action": "<action>"
},
"name": "mp_wx"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | Arguments passed to the wx API for action "call". | |
| action | Yes | call: invoke a wx API inside the app. mock: replace a wx API result. restore: drop one mock. restore_all: drop every mock. list_mocks: show what is mocked. | |
| method | No | wx API name, e.g. "request", "getStorageSync", "showToast". Required by call, mock and restore. | |
| result | No | Value the mocked wx API returns for action "mock". Mutually exclusive with function_source. | |
| function_source | No | JavaScript function source evaluated inside the app for action "mock", e.g. "function (options) { options.success({ data: [] }) }". Only use code you wrote. |