xiaohongshu-skill
Provides tools to automate Xiaohongshu (小红书/RED) operations, including publishing image and video posts, searching content with filters, managing engagement through likes and comments, and retrieving user profile and analytics data.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
安装
pip install redbook-cli
xhs init # 引导:环境检查 → 代理 → 启动 MCP → 扫码登录(一次即可)源码安装:
git clone https://github.com/Youhai020616/xiaohongshu.git
cd xiaohongshu && bash setup.shDocker(无需本地 Go / 二进制 / Chrome,见 Docker):
docker compose up -d && docker compose exec cli xhs login依赖说明
Python ≥ 3.10
MCP 服务二进制 —
xhs init/xhs server start会从上游 Releases 自动下载(darwin-arm64、linux-amd64、windows-amd64)Google Chrome — 仅 CDP 功能需要(数据看板、通知、
xhs login --cdp)可选:
pip install 'redbook-cli[api]'启用 REST API 服务
Related MCP server: xiaohongshu-mcp-py
快速开始
xhs init # 首次引导设置
xhs search "美食" # 搜索 → 结果自动缓存
xhs read 1 # 查看第 1 条(短索引)
xhs like 1 # 点赞第 1 条
xhs fav 2 # 收藏第 2 条
xhs comment 1 -c "好文!" # 评论第 1 条
xhs publish -t "标题" -c "内容" -i img.jpg # 发布图文功能特性
🔍 搜索 — 关键词搜索,支持排序 / 类型 / 时间 / 范围 / 位置筛选,导出 CSV / JSON
📝 发布 — 图文与视频,支持标签、定时、可见范围、原创声明、商品关联
💬 互动 — 点赞、收藏、评论、回复(支持短索引)
📊 数据看板 — 创作者后台数据导出(CDP)
🔔 通知 — @提及与互动通知
👤 主页 — 用户信息与笔记列表
🔢 短索引 —
xhs search → xhs read 1 → xhs like 1,无需复制 ID📦 导出 —
xhs search "AI" -o results.csv🔐 登录 — MCP 扫码 + CDP 浏览器登录
👥 多账号 — 独立 Chrome Profile 隔离
🏗️ 双引擎 — MCP 服务(快)+ CDP 自动回退
🤖 Agent 友好 —
--json-output成功与失败都输出统一信封;stdout 只有数据,进度走 stderr🌐 REST API —
xhs api start以 HTTP 暴露全部能力(FastAPI)🐳 Docker — 一条
docker compose up在 Linux 上跑起 MCP + Chrome + CLI
命令
搜索与查看
xhs search "关键词" # 基础搜索
xhs search "旅行" --sort 最多点赞 # 按点赞排序
xhs search "穿搭" --type 图文 # 按类型筛选
xhs search "AI" -o results.csv # 导出 CSV
xhs search "咖啡" --engine cdp # CDP 引擎(额外返回推荐词)
xhs read 1 # 按短索引查看
xhs detail 1 --comments # 同时加载评论
xhs detail FEED_ID -t TOKEN # 按 ID + xsec_token 查看
xhs feeds # 首页推荐发布
xhs publish -t "标题" -c "正文" -i photo.jpg # 图文
xhs publish -t "标题" -c "正文" -v video.mp4 # 视频
xhs publish -t "标题" -c "正文" -i img.jpg --tags 旅行 --tags 美食 # 带标签
xhs publish -t "测试" -c "内容" -i img.jpg --visibility 仅自己可见 # 私密
xhs publish -t "标题" -c "正文" -i img.jpg --schedule "2026-05-01T10:00:00+08:00" # 定时
xhs pub -t "标题" -c "正文" -i img.jpg --dry-run # 仅预览互动
xhs like 1 # 点赞(短索引)
xhs like FEED_ID -t TOKEN --unlike # 取消点赞
xhs fav 1 # 收藏
xhs comment 1 -c "写得好!" # 评论
xhs reply 1 --comment-id X --user-id Y -c "回复" # 回复评论数据与主页
xhs analytics # 创作者数据看板(CDP)
xhs analytics --csv data.csv # 导出 CSV
xhs notifications # 提及 / 互动通知(CDP)
xhs me # 我的信息
xhs profile USER_ID -t TOKEN # 用户主页服务、账号与配置
xhs login # MCP 扫码登录(自动启动 MCP 服务)
xhs login --cdp # CDP 浏览器登录
xhs status # 两个引擎的登录状态
xhs server start # 启动 MCP 服务(二进制,自动安装)
xhs server start --docker # 以 Docker 启动 MCP 服务
xhs server status | stop | log # 管理 MCP 服务
xhs account list # 列出账号
xhs config show # 查看配置
xhs config set mcp.proxy http://... # 设置代理别名
简写 | 命令 | 简写 | 命令 | |
|
|
|
| |
|
|
|
| |
|
|
|
| |
|
|
|
|
面向 AI Agent 的结构化输出
几乎所有命令支持 --json-output:stdout 只输出一个 JSON 信封,进度与提示全部走 stderr,可直接管道给 jq 或由 Agent 解析:
xhs status --json-output | jq '.data.authenticated'
xhs search "AI" --json-output | jq '.data'
xhs like 1 --json-output # 变更类命令也返回结构化结果{ "ok": true, "schema_version": "1", "data": ... }
{ "ok": false, "schema_version": "1", "error": { "code": "mcp_error", "message": "..." } }失败时退出码为 1,error.code 取值固定(not_authenticated / invalid_argument / mcp_error / cdp_error / action_failed 等)。完整约定见 SCHEMA.md,作为 Agent Skill 使用见 SKILL.md。
REST API
pip install 'redbook-cli[api]'
xhs api start --port 8080 # Swagger 文档: http://127.0.0.1:8080/docs/api/v1 下的端点:login/status · login/qrcode · search · publish · feeds/detail · feeds/list · feeds/like · feeds/favorite · feeds/comment · feeds/comment/reply · user/me · user/profile · analytics · notifications · /health。
Docker
镜像在上游 xpzouying/xiaohongshu-mcp 之上叠加 Python CLI 与 Chrome,Linux amd64 无需安装 Go 或二进制即可运行 MCP:
docker compose up -d # 构建并启动(MCP :18060,CDP :9222)
docker compose exec cli xhs login # 扫码登录
docker compose exec cli xhs search "美食"
docker compose exec cli xhs publish -t "标题" -c "正文" -i /app/data/images/photo.jpg
docker compose logs -f # 日志
docker compose down # 停止持久化数据在 ./docker/data/(cookies/ 登录态,images/ 待发布素材)。详见 docker/README.md。
配置
路径 | 用途 |
| 全局配置 |
| 上次搜索的短索引缓存 |
默认配置(xhs config show):
{
"mcp": { "host": "127.0.0.1", "port": 18060, "proxy": "", "auto_start": true },
"cdp": { "host": "127.0.0.1", "port": 9222, "headless": false },
"default": { "account": "default", "engine": "auto", "output": "table" }
}xhs config set mcp.proxy http://127.0.0.1:7897 # MCP 代理
xhs config set default.engine cdp # 强制引擎:auto | mcp | cdp
xhs config set cdp.headless true # CDP 使用无头 Chrome
xhs config get mcp.port
xhs config reset架构
引擎 | 负责 | 技术 |
MCP 服务 | 搜索、发布、点赞、收藏、评论、回复、主页、推荐 | Go 二进制(上游 xiaohongshu-mcp),HTTP JSON-RPC |
CDP 脚本 | 数据看板、通知、多账号;搜索 / 点赞 / 评论 / 发布的回退 | Python + Chrome DevTools Protocol |
flowchart LR
CLI[xhs 命令] --> MCP[MCP 服务<br/>Go · :18060]
CLI --> CDP[CDP 脚本<br/>Chrome · :9222]
MCP -->|搜索 / 发布 / 互动| XHS[xiaohongshu.com]
CDP -->|数据看板 / 通知| XHS
MCP -.->|不可用时回退| CDP
API[xhs api · FastAPI] --> CLI引擎自动选择:MCP 服务在运行则用 MCP,否则用 CDP。可用 --engine 或 default.engine 覆盖。
平台支持
组件 | macOS ARM64 | macOS x86 | Linux amd64 | Windows amd64 |
xhs CLI | ✅ | ✅ | ✅ | ✅ |
MCP 服务(自动安装二进制) | ✅ | ❌ | ✅ | ✅ |
MCP 服务(Docker) | ✅ | ✅ | ✅ | ✅ |
CDP 脚本 | ✅ | ✅ | ✅ | ✅ |
二进制来自上游 Releases;macOS x86 上游没有构建 —— 请用 Docker 或纯 CDP 模式。WSL 已适配(自动延长超时)。
开发
git clone https://github.com/Youhai020616/xiaohongshu.git && cd xiaohongshu
python3 -m venv .venv && source .venv/bin/activate
pip install -e . && pip install pytest ruff
ruff check src/ tests/
pytest tests/ -vCI 在 Python 3.10 / 3.12 上运行 lint 与测试。
文档
README.en.md — English
SCHEMA.md — 结构化输出约定
SKILL.md — 作为 AI Agent Skill 使用
docker/README.md — Docker 部署
免责声明
本项目通过 MCP 服务与 Chrome 自动化驱动小红书网页端,目前处于 Alpha 阶段,仅供学习与研究使用。平台更新可能导致选择器或接口失效;自动化操作存在账号风控风险。请遵守小红书用户协议,使用后果自行承担。
许可证
🔗 生态
项目 | 说明 |
AI Agent 自学习记忆系统 | |
基于 Camoufox 的反检测浏览器 CLI | |
X/Twitter 隐身自动化 | |
抖音 CLI | |
AI 社媒管理 |
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Remote MCP server for China brand visibility, destination demand, and KOL discovery workflows.
RedNote (Xiaohongshu, 小红书) note search, full notes, comment threads and creator profiles.
Hosted MCP server for DataLikers — Instagram & TikTok data API. 51 tools: Instagram user search by demographics (gender/age/race/country/city), profiles, bulk lookup, engagement, posts & reels, comments, hashtags, locations, stories, highlights, music, business accounts, top users; TikTok users, videos, comments, hashtags, playlists and top charts. Streamable HTTP, Bearer API key. Free tier: 100 requests on signup at https://datalikers.com/p/1by27bwg
MCP server for real-time Chinese internet hot-search and trending boards across major platforms.
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP server enabling AI assistants to search, analyze, and generate content for Xiaohongshu (RedNote), China's leading lifestyle social media platform.69MIT
- FlicenseNot gradedqualityDmaintenanceMCP server for Xiaohongshu automation, enabling feed browsing, search, note publishing, and interaction via Playwright and FastMCP.4-
- AlicenseAqualityDmaintenanceA lightweight MCP server that provides read-only access to Xiaohongshu (Little Red Book) data, enabling search, note details, user profiles, and trending feeds via direct HTTP APIs.518 npm1MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for automatically publishing text, image, and video notes to Xiaohongshu (Little Red Book).1MIT