post-to-xhs

小红书内容发布与管理助手。当用户要求登录、发小红书、搜索小红书、评论点赞收藏等任何小红书相关操作时使用。

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "post-to-xhs" with this command: npx skills add luweizheng/post2xhs

xhs-mcp-py 使用方式

安装

首次使用需要确认环境中有 Python 解释器。

# 使用 pip 安装
pip install -U xhs-mcp-py

# 安装 Playwright 浏览器(必需)
playwright install chromium

⚠️ 重要:所有操作必须先登录

小红书所有功能(发布、搜索、点赞、评论等)都需要先登录。

1. 检查登录状态

执行任何操作前,先检查是否已登录:

xhs-mcp status
  • 输出 ✅ 已登录:可以继续操作
  • 输出 ❌ 未登录:必须先执行登录步骤

2. 登录方式(带 fallback 逻辑)

推荐按以下顺序尝试登录:

方式一:终端二维码(Claude Code / Open Code 推荐)

xhs-mcp login-qrcode --terminal
  • ⚠️ 需要安装 zbar 库才能解析二维码:
    • macOS: brew install zbar
    • Ubuntu: apt install libzbar0
  • 如果未安装 zbar,会自动保存二维码图片并提示路径
  • 用户扫码后按回车完成登录
  • 如果终端显示失败,fallback 到方式二

方式二:浏览器扫码登录(有图形界面的环境)

xhs-mcp login-browser
  • 会弹出浏览器窗口供用户扫码
  • 如果无法弹出浏览器(如远程服务器无图形界面),会提示使用二维码方式

方式三:保存二维码图片(OpenClaw 推荐)

xhs-mcp login-qrcode --save /tmp/qrcode.png
  • 将二维码图片发送给用户扫码
  • 用户扫码后按回车完成登录

如果以上方式都失败:

  • 提醒用户需要安装浏览器环境(Playwright + Chromium)
  • 或需要图形界面环境

3. 登录参数说明

login-qrcode 参数:

参数类型必需说明
-s/--savestring保存二维码图片到指定路径
--terminal/--no-terminalflag是否在终端显示二维码(默认 terminal)

登录成功后,cookies 会保存到本地文件,后续操作自动复用(有效期约 7-30 天)。

发布操作

发布图文内容

命令:xhs-mcp publish

参数:-i/--image--tag 可多次指定)

参数类型必需说明
-t/--titlestring文字标题
-c/--contentstring文字正文内容
-i/--imagestring图片路径(可多次指定)
--tagstring话题标签(可多次指定)
--headless/--no-headlessflag是否无头模式(默认 headless)

示例:

xhs-mcp publish -t "标题" -c "正文" -i /abs/1.jpg -i /abs/2.jpg --tag 旅行 --tag 美食

发布视频内容

命令:xhs-mcp publish-video

参数:

参数类型必需说明
-t/--titlestring文字标题
-c/--contentstring文字正文内容
-v/--videostring视频路径
--tagstring话题标签(可多次指定)
--headless/--no-headlessflag是否无头模式(默认 headless)

示例:

xhs-mcp publish-video -t "标题" -c "正文" -v /abs/video.mp4

发布文字配图(文字卡片)

命令:xhs-mcp publish-text-card

参数:-p/--page--tag 可多次指定)

参数类型必需说明
-c/--coverstring封面文字
-p/--pagestring正文页文字(可多次指定,最多17页)
-s/--stylestring卡片样式:基础|边框|备忘|手写|便签|涂写|简约|光影|几何
-t/--titlestring文字标题
--contentstring文字正文内容
--tagstring话题标签(可多次指定)
--headless/--no-headlessflag是否无头模式(默认 headless)

示例:

xhs-mcp publish-text-card -c "封面" -p "第一页" -p "第二页" -s "基础" -t "笔记标题"

浏览/搜索

搜索内容

命令:xhs-mcp search

参数:

参数类型必需说明
-k/--keywordstring搜索关键词
--headless/--no-headlessflag是否无头模式(默认 headless)

输出:

命令会打印搜索到的笔记列表。每条结果会包含:

  • ID:对应后续命令里的 --feed-id
  • xsec_token:对应后续命令里的 --xsec-token

示例(截断):

1. 标题...
   作者: xxx | 点赞: 123
   ID: 1234567890abcdef
   xsec_token: xsec_xxx

互动(点赞/收藏/评论)

以下命令需要你先从搜索结果或笔记链接中拿到 feed_idxsec_token

点赞/取消点赞

命令:xhs-mcp like

参数:

参数类型必需说明
--feed-idstring笔记 ID
--xsec-tokenstring访问令牌
--unlikeflag取消点赞(默认 false 为点赞)
--headless/--no-headlessflag是否无头模式(默认 headless)

示例:

xhs-mcp like --feed-id FEED_ID --xsec-token XSEC_TOKEN
xhs-mcp like --feed-id FEED_ID --xsec-token XSEC_TOKEN --unlike

收藏/取消收藏

命令:xhs-mcp favorite

参数:

参数类型必需说明
--feed-idstring笔记 ID
--xsec-tokenstring访问令牌
--unfavoriteflag取消收藏(默认 false 为收藏)
--headless/--no-headlessflag是否无头模式(默认 headless)

示例:

xhs-mcp favorite --feed-id FEED_ID --xsec-token XSEC_TOKEN
xhs-mcp favorite --feed-id FEED_ID --xsec-token XSEC_TOKEN --unfavorite

发表评论

命令:xhs-mcp comment

参数:

参数类型必需说明
--feed-idstring笔记 ID
--xsec-tokenstring访问令牌
-c/--contentstring评论内容
--headless/--no-headlessflag是否无头模式(默认 headless)

示例:

xhs-mcp comment --feed-id FEED_ID --xsec-token XSEC_TOKEN -c "评论内容"

回复评论

命令:xhs-mcp reply-comment

参数:

参数类型必需说明
--feed-idstring笔记 ID
--xsec-tokenstring访问令牌
-c/--contentstring回复内容
--comment-idstring目标评论 ID
--user-idstring目标用户 ID
--headless/--no-headlessflag是否无头模式(默认 headless)

--comment-id--user-id 至少需要提供一个。

示例:

xhs-mcp reply-comment --feed-id FEED_ID --xsec-token XSEC_TOKEN -c "回复内容" --comment-id COMMENT_ID

退出登录

命令:xhs-mcp logout

会删除本地 cookies。

(可选)MCP 模式

如果你的运行环境支持 MCP(例如 Claude Desktop / Cursor),可以启动 MCP:

xhs-mcp serve

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Accelo

Accelo integration. Manage Organizations, Leads, Pipelines, Users, Goals, Filters. Use when the user wants to interact with Accelo data.

Registry SourceRecently Updated
General

8X8

8x8 integration. Manage Persons, Organizations, Deals, Leads, Activities, Notes and more. Use when the user wants to interact with 8x8 data.

Registry SourceRecently Updated
General

7Shifts

7shifts integration. Manage Companies. Use when the user wants to interact with 7shifts data.

Registry SourceRecently Updated
General

46Elks

46elks integration. Manage Organizations. Use when the user wants to interact with 46elks data.

Registry SourceRecently Updated