Search WeChat Official Accounts (async task, CLI waits synchronously by default for up to 30 seconds), and cancel an in-progress search task. After getting mpId , the next step is supsub sub add --mp-id <mpId>(see supsub-sub skill)—— mp search returned by mpId is a WeChat-native base64 string,cannotbe passed to --source-id(that is supsub's internal positive-integer ID, a different ID space).
Prerequisites
- Install:
curl -fsSL https://raw.githubusercontent.com/SupSub-AI/supsub-cli/master/scripts/install.sh | bash(native install, installs to~/.local, supports background auto-update); or package managernpm i -g @supsub/cli/pnpm add -g @supsub/cli - Already logged in:
supsub auth statusshows Authenticated (on first use, firstsupsub auth login) - When unauthorized (exit 2 / UNAUTHORIZED), do not stop at "you are not logged in": directly run
supsub auth loginto open browser authorization for the user (the command will automatically open the browser and block waiting for authorization, so use a sufficiently long timeout, such as 10 minutes; the user only needs to click confirm in the browser and does not need to enter anything in the terminal), and after authorization succeeds, retry the original command. In a browserless / headless environment, fall back to prompting the userSUPSUB_NO_BROWSER=1 supsub auth login。
Commands
Search Official Account (async, auto-poll)
supsub mp search <name>
<name> is the Official Account name keyword (quotes recommended). Internal command flow:
POST /api/mps/search-taskscreates an async task, obtainingsearchId。- The CLI polls the task status every 2s,for up to 30 seconds。
- The backend will, across multiple polls, one by one return candidate Official Accounts, and the CLI automatically accumulates and deduplicates them.
- After receiving
finished=true, output all candidates at once as the result. - If not completed within 30 seconds → exit and return
searchId, with a hint message.
Fields for each candidate:mpId, name, img, description, isSubscribed。
# 同步搜索(实测约 15-30 秒,工具超时请设到 60s 以上)
supsub mp search "机器之心"
# JSON
supsub mp search "机器之心" -o json
JSON shape (success):{"success":true,"data":[{"mpId":"...","name":"...","img":"...","description":"...","isSubscribed":false}, ...]}
What is returned isa batch of candidates(measured: 10 for "机器之心", 5 for "阮一峰"), not a single exact match. See the account-selection constraints in Agent Usage Notes below.
Not found: exits with MP_NOT_FOUND error (non-zero exit code).
Timeout: exits with MP_SEARCH_TIMEOUT error, and the error body includes data.searchId, with a hint message of the form 30 秒内未完成,可重试 supsub mp search 或取消任务: supsub mp search-cancel <searchId>。
⚠️ Timeout handling: the CLI does not provide a recovery-type query command. When a timeout occurs, the user has only two paths — rerun
supsub mp search <name>, or callsupsub mp search-cancel <searchId>to cancel that orphan task and then try again.
Cancel a running search task
supsub mp search-cancel <searchId>
<searchId> comes from the previous supsub mp search error data returned in the timeout branch (JSON mode:{"success":false,"error":{"code":"MP_SEARCH_TIMEOUT","data":{"searchId":"..."}}} this kind of shape is handled by dieWith and output() ; in table mode the error string will directly include searchId)。
supsub mp search-cancel sid_abc123
supsub mp search-cancel sid_abc123 -o json
JSON shape: {"success":true,"data":{"message":"已取消"}}
When the task does not exist or has been canceled, exits with TASK_NOT_FOUND error (HTTP 404 → non-zero exit code).
Agent Usage Notes
mp searchis a synchronously wrapped async task: callers generally do not need to care aboutsearchId, and can just take the result array; only in the 30-second timeout branch do they need to handlesearchId。- For parsing results, uniformly use
-o json. On success,dataisMp[]; on failure, follow the standardErrorEnvelope(code、message, optionaldata.searchId)。 - Search → Subscribe chain (most common):
# 1. 列出候选,连 name 一起看(实测「机器之心」返回 10 条) supsub mp search "机器之心" -o json | jq -r '.data[] | "\(.mpId)\t\(.isSubscribed)\t\(.name)"' # 2. 与用户确认选中哪一个后,用 --mp-id 订阅(走 POST /api/mps;type 默认 MP,可省) # 可顺带 --group <gid> 一步入组 supsub sub add --mp-id "MzA3MzI4MjgzMw==" --group 1166 - ⚠️ Never
jq '.data[0]'directly take the first item. Measuredmp search "机器之心"'s 10 candidates include near-name accounts like "机器之心PRO会员" and "机器之心SOTA模型", as well as completely unrelated accounts like "新智元" and "量子位".You must list the candidates (name+description+isSubscribed) for the user to choose from, and only subscribe after confirmation; especially when there is more than one same-name/near-name account, you must not decide for the user. - ⚠️ Do not treat
mpIdas--source-id:mp searchreturned bympIdis a WeChat native base64 string (e.g.MzkyNTYzODk0NQ==),supsub sub add --source-idexpects supsub's internal positive integer sourceId (fromsupsub search/sub list), the two belong to different ID spaces. Even if the base64 decodes to a number, the backend will reject it with "information source does not exist". Uniformly use--mp-id。 - candidate field is
mpId/name/img/description/isSubscribed。isSubscribedmeasured to exist(verified in the dev environment in 2026-07), and you can directly use it to skip already-subscribed accounts, without having to go aroundsupsub search --type MPor comparesub list. If a certain backend version really lacks this field, fall back to comparingsub list。 mp searchinternal fixed polling: interval 2s, total duration 30s (POLL_INTERVAL_MS/POLL_MAX_MS), the CLI does not expose a tuning flag.Measured, one real search takes about 15-30 seconds("机器之心" 27.4s, "阮一峰" 14.7s). Therefore: when calling this command, set the tool timeout to 60s or more, do not use the default value; and before initiating, first tell the user "this step will take about half a minute", do not let the user think it is stuck.- The backend returns candidate official accounts in a "streaming" manner: the CLI already deduplicates (by
mpId), the caller does not need to deduplicate again. - The only legal follow-up actions for the timeout branch are:
supsub mp search-cancel <searchId>cancel the orphan task, or re-initiatesupsub mp search <name>。 - Exit codes:
0OK; business errors such as timeout / not found / task does not exist (backend 4xx) are1;2UNAUTHORIZED,10network errors,11server errors (5xx).