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
check_login_status
(no parameters), which returns whether the user is logged in and the username.
  • Logged in → Inform the user of the currently logged-in account
  • Not logged in → Proceed to Step 2

2. 扫码登录

2. QR Code Login

调用
get_login_qrcode
(无参数)。MCP 工具返回两部分内容:
  • 文本:超时提示(含截止时间)
  • 图片:PNG 格式二维码(MCP image content type,Base64 编码)
展示二维码:MCP 返回的图片会通过客户端渲染给用户。如果客户端无法直接展示图片(如纯文本终端),则将 Base64 数据保存为临时 PNG 文件,告知用户文件路径让其手动打开:
bash
undefined
Call
get_login_qrcode
(no parameters). The MCP tool returns two parts:
  • 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
undefined

fallback: 保存二维码到临时文件

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

当用户要求重新登录或切换账号时:
  1. 调用
    delete_cookies
    (⚠️ 需用户确认)— 清除当前登录状态
  2. 调用
    get_login_qrcode
    — 获取新二维码
  3. 引导用户扫码
When the user requests re-login or account switching:
  1. Call
    delete_cookies
    (⚠️ User confirmation required) — Clear current login status
  2. Call
    get_login_qrcode
    — Obtain new QR code
  3. Guide the user to scan the code

约束

Constraints

  • delete_cookies
    会清除登录状态,执行前必须确认
  • 登录需要用户手动用手机 App 扫码,无法自动完成
  • delete_cookies
    will clear the login status; must confirm with the user before execution
  • Login requires manual QR code scanning via the mobile App; cannot be completed automatically

失败处理

Failure Handling

场景处理
MCP 工具不可用引导用户使用
/setup-xhs-mcp
完成部署和连接配置
二维码超时重新调用
get_login_qrcode
ScenarioHandling
MCP tool unavailableGuide the user to use
/setup-xhs-mcp
to complete deployment and connection configuration
QR code expiredRe-call
get_login_qrcode