小红书 MCP 客户端技能
name: xiaohongshu-mcp-client
by cn-p5 · published 2026-03-22
$ claw add gh:cn-p5/cn-p5-xiaohongshu-aio---
name: xiaohongshu-mcp-client
description: |
小红书 MCP 客户端技能,用于管理小红书账号、登录、发布笔记、视频、图文内容、搜索、互动等操作。
支持账号管理、登录状态检查、内容发布、Feed管理、互动操作和用户信息查询。
metadata:
{
"openclaw": {
"requires": { "bins": ["python","uv"], "env": ["XHS_MCP_BASE_URL"], "config": [] },
"primaryEnv": "XHS_MCP_BASE_URL",
"emoji": "📱"
}
}
---
# 小红书 MCP 客户端技能
功能概述
本技能提供完整的小红书账号管理和内容操作功能,基于小红书 MCP 服务器 API。
主要功能
安装
cd xiaohongshu-aio
pip install -e .执行流程
**执行任何操作前,都需要先检查 MCP 服务器是否运行**:
chmod +x check-service.sh
./check-service.sh1. 账号管理流程
#### 添加账号
1. 执行:`xhs login status`确保 MCP 服务器已登录
2. 执行:`xhs account add`(自动检测用户名)
3. 或执行:`xhs account add --username 账号名称 --notes "备注"`
4. 系统会自动将当前 cookies 保存为指定账号
#### 切换账号
1. 执行:`xhs account switch --username 账号名称`
2. 系统会将指定账号的 cookies 写入 MCP 服务器的 cookies.json
3. 执行:`xhs login status` 确认切换成功
#### 查看账号
2. 登录管理流程
#### 检查登录状态
1. 执行:`xhs login status`
2. 系统返回当前登录状态和用户名
#### 扫码登录
1. 执行:`xhs login qrcode`
2. 系统返回登录二维码(Base64 格式)
3. 用户使用小红书 App 扫描二维码
4. 扫描后执行:`xhs login status` 确认登录成功
#### 登出
1. 执行:`xhs login logout`
2. 系统会清除当前登录状态
3. 内容发布流程
#### 发布图文内容
1. 执行:
```bash
xhs publish "标题" "内容" "图片URL1" "图片URL2" --tags 标签1 标签2
```
#### 发布视频内容
1. 执行:
```bash
xhs publish "视频标题" "视频内容" "视频文件路径" --is-video
```
4. Feed 管理流程
#### 搜索内容
1. 执行:`xhs feed search --keyword "关键词"`
2. 系统返回相关内容列表
#### 获取内容详情
1. 从搜索结果中获取 feed_id 和 xsec_token
2. 执行:
```bash
xhs feed detail --feed-id "feed_id" --xsec-token "token"
```
5. 互动操作流程
#### 点赞内容
1. 执行:`xhs interact like "feed_id" "token"`
#### 发表评论
1. 执行:
```bash
xhs interact comment "feed_id" "token" --content "评论内容"
```
命令参考
账号管理
登录管理
内容发布
Feed 管理
互动操作
用户信息
配置
环境变量
配置文件
注意事项
1. **账号安全**:请妥善保管 `user_cookies.json` 文件
2. **频率限制**:避免过于频繁的操作,遵守平台规则
3. **服务器依赖**:本技能依赖运行中的小红书 MCP 服务器
4. **网络连接**:发布视频时需要稳定的网络连接
5. **错误处理**:遇到错误时检查 MCP 服务器状态
故障排除
常见问题
| 问题 | 解决方案 |
|------|----------|
| 无法连接服务器 | 检查 MCP 服务器是否运行,地址是否正确、重启 MCP 服务器 |
| 登录失败 | 确保二维码扫描及时,检查账号状态 |
| 发布失败 | 检查内容是否符合平台规范,文件是否可访问 |
| 账号切换失败 | 检查账号是否存在,重启 MCP 服务器 |
**失败时重启 MCP 服务器**:
chmod +x strart-service.sh
./strart-service.sh依赖
示例工作流
完整发布流程
1. **检查登录状态**
```bash
xhs login status
```
2. **如未登录,获取二维码**
```bash
xhs login qrcode
```
3. **扫码登录后确认**
```bash
xhs login status
```
4. **添加账号**
```bash
xhs account add
```
5. **发布内容**
```bash
xhs publish "我的第一篇笔记" "这是内容" "https://example.com/image.jpg" --tags 测试 小红书
```
6. **搜索相关内容**
```bash
xhs feed search --keyword "咖啡"
```
7. **点赞内容**
```bash
xhs interact like "feed_id" "token"
```
More tools from the same signal band
Order food/drinks (点餐) on an Android device paired as an OpenClaw node. Uses in-app menu and cart; add goods, view cart, submit order (demo, no real payment).
Sign plugins, rotate agent credentials without losing identity, and publicly attest to plugin behavior with verifiable claims and authenticated transfers.
The philosophical layer for AI agents. Maps behavior to Spinoza's 48 affects, calculates persistence scores, and generates geometric self-reports. Give your...