ClawSkills logoClawSkills

Xiaohongshu (小红书) Automation

使用适用于 xiaohongshu-mcp 服务器的 Python 客户端自动化 Xiaohongshu (RedNote) 内容运营。用于:(1) 发布图像、文本和视频内容,

介绍

# Xiaohongshu MCP Skill (with Python Client)

使用捆绑的 Python 脚本自动化小红书内容运营,该脚本与 `xpzouying/xiaohongshu-mcp` 服务器(获得 8.4k+ stars)进行交互。

**项目:** [xpzouying/xiaohongshu-mcp](https://github.com/xpzouying/xiaohongshu-mcp)

## 1. 本地服务器设置

此技能要求 `xiaohongshu-mcp` 服务器在您的本地机器上运行。

### 步骤 1:下载二进制文件

从 [GitHub Releases](https://github.com/xpzouying/xiaohongshu-mcp/releases) 页面下载适合您系统的二进制文件。

| 平台 | MCP 服务器 | 登录工具 | | -------- | ---------- | ---------- | | macOS (Apple Silicon) | `xiaohongshu-mcp-darwin-arm64` | `xiaohongshu-login-darwin-arm64` | | macOS (Intel) | `xiaohongshu-mcp-darwin-amd64` | `xiaohongshu-login-darwin-amd64` | | Windows | `xiaohongshu-mcp-windows-amd64.exe` | `xiaohongshu-login-windows-amd64.exe` | | Linux | `xiaohongshu-mcp-linux-amd64` | `xiaohongshu-login-linux-amd64` |

授予下载文件可执行权限: ```shell chmod +x xiaohongshu-mcp-darwin-arm64 xiaohongshu-login-darwin-arm64 ```

### 步骤 2:登录(仅需首次)

运行登录工具。它将打开一个带有二维码的浏览器窗口。使用您的小红书手机应用扫码。

```shell ./xiaohongshu-login-darwin-arm64 ```

> **重要提示**:不要在任何其他网络浏览器上登录同一个小红书账号,否则会使服务器的会话失效。

### 步骤 3:启动 MCP 服务器

在单独的终端窗口中运行 MCP 服务器。它将在后台运行。

```shell # Run in headless mode (recommended) ./xiaohongshu-mcp-darwin-arm64

# Or, run with a visible browser for debugging ./xiaohongshu-mcp-darwin-arm64 -headless=false ```

服务器将在 `http://localhost:18060` 上可用。

## 2. 使用技能

此技能包含一个 Python 客户端(`scripts/xhs_client.py`),用于与本地服务器交互。您可以直接从 Shell 使用它。

### 可用命令

| 命令 | 描述 | 示例 | | --- | --- | --- | | `status` | 检查登录状态 | `python scripts/xhs_client.py status` | | `search <keyword>` | 搜索笔记 | `python scripts/xhs_client.py search "咖啡"` | | `detail <id> <token>` | 获取笔记详情 | `python scripts/xhs_client.py detail "note_id" "xsec_token"` | | `feeds` | 获取推荐流 | `python scripts/xhs_client.py feeds` | | `publish <title> <content> <images>` | 发布笔记 | `python scripts/xhs_client.py publish "Title" "Content" "url1,url2"` |

### 示例工作流:市场调研

1. **检查状态**:首先,确保服务器正在运行并且您已登录。 ```shell python ~/clawd/skills/xiaohongshu-mcp/scripts/xhs_client.py status ```

2. **搜索关键词**:查找与您的研究主题相关的笔记。输出将包含下一步所需的 `feed_id` 和 `xsec_token`。 ```shell python ~/clawd/skills/xiaohongshu-mcp/scripts/xhs_client.py search "户外电源" ```

3. **获取笔记详情**:使用搜索结果中的 `feed_id` 和 `xsec_token` 获取特定笔记的完整内容和评论。 ```shell python ~/clawd/skills/xiaohongshu-mcp/scripts/xhs_client.py detail "64f1a2b3c4d5e6f7a8b9c0d1" "security_token_here" ```

4. **分析**:查看笔记的内容、评论和互动数据以收集见解。

更多产品