xhs-login
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese执行流程
Execution Flow
1. 检查登录状态
1. Check Login Status
调用 (无参数),返回是否已登录及用户名。
check_login_status- 已登录 → 告知用户当前登录账号
- 未登录 → 进入步骤 2
Call (no parameters), which returns whether the user is logged in and the username.
check_login_status- Logged in → Inform the user of the currently logged-in account
- Not logged in → Proceed to Step 2
2. 扫码登录
2. QR Code Login
调用 (无参数)。MCP 工具返回两部分内容:
get_login_qrcode- 文本:超时提示(含截止时间)
- 图片:PNG 格式二维码(MCP image content type,Base64 编码)
展示二维码:MCP 返回的图片会通过客户端渲染给用户。如果客户端无法直接展示图片(如纯文本终端),则将 Base64 数据保存为临时 PNG 文件,告知用户文件路径让其手动打开:
bash
undefinedCall (no parameters). The MCP tool returns two parts:
get_login_qrcode- Text: Timeout prompt (including deadline)
- Image: PNG format QR code (MCP image content type, Base64 encoded)
Display QR Code: The image returned by MCP will be rendered to the user via the client. If the client cannot directly display images (such as a plain text terminal), save the Base64 data as a temporary PNG file and inform the user of the file path to open manually:
bash
undefinedfallback: 保存二维码到临时文件
fallback: 保存二维码到临时文件
echo "<base64_data>" | base64 -d > /tmp/xhs-qrcode.png
open /tmp/xhs-qrcode.png # macOS
xdg-open /tmp/xhs-qrcode.png # Linux
提示用户:
- 打开小红书 App 扫描二维码
- 二维码有效期有限,过期需重新获取
扫码完成后,调用 `check_login_status` 确认登录成功。echo "<base64_data>" | base64 -d > /tmp/xhs-qrcode.png
open /tmp/xhs-qrcode.png # macOS
xdg-open /tmp/xhs-qrcode.png # Linux
Prompt the user:
- Open the Xiaohongshu App to scan the QR code
- The QR code has a limited validity period; re-obtain it if it expires
After scanning, call `check_login_status` to confirm successful login.3. 重新登录 / 切换账号
3. Re-login / Switch Accounts
当用户要求重新登录或切换账号时:
- 调用 (⚠️ 需用户确认)— 清除当前登录状态
delete_cookies - 调用 — 获取新二维码
get_login_qrcode - 引导用户扫码
When the user requests re-login or account switching:
- Call (⚠️ User confirmation required) — Clear current login status
delete_cookies - Call — Obtain new QR code
get_login_qrcode - Guide the user to scan the code
约束
Constraints
- 会清除登录状态,执行前必须确认
delete_cookies - 登录需要用户手动用手机 App 扫码,无法自动完成
- will clear the login status; must confirm with the user before execution
delete_cookies - Login requires manual QR code scanning via the mobile App; cannot be completed automatically
失败处理
Failure Handling
| 场景 | 处理 |
|---|---|
| MCP 工具不可用 | 引导用户使用 |
| 二维码超时 | 重新调用 |
| Scenario | Handling |
|---|---|
| MCP tool unavailable | Guide the user to use |
| QR code expired | Re-call |