一个强大的自动化工具包,支持通过MCP协议与AI客户端(如Claude Desktop)集成,实现与AI对话的内容创作、发布和创作者数据分析。
在Chrome浏览器中访问:chrome://version/
# 使用webdriver-manager自动管理
pip install webdriver-manager
/usr/local/bin/ 或 C:\tools\).env文件中配置正确的路径# macOS (Homebrew)
brew install --cask chromedriver
# Windows (Chocolatey)
choco install chromedriver
# Linux (Ubuntu/Debian)
sudo apt-get install chromium-chromedriver
⚠️ 重要通知版本不匹配是最常见的问题原因,请确保Chrome Driver版本与Chrome浏览器版本完全一致!
支持连接到正在运行的远程Chrome实例,以提高性能并支持远程部署场景。
在.env文件中添加以下配置:
# 启用远程浏览器连接
ENABLE_REMOTE_BROWSER=true
REMOTE_BROWSER_HOST=http://xx.xx.xx.xx
REMOTE_BROWSER_PORT=xxxx
./chrome-data目录是否有读写权限。如果没有,请按照以下步骤进行修复
docker run --rm selenium/standalone-chrome id seluser 获取seluser的UID,例如返回 uid=1200(seluser) gid=1200(seluser) groups=1200(seluser)sudo chown -R 1200:1200 ./chrome-data 授予seluser读写权限,1200是seluser的UIDdocker-compose up --force-recreate 启动容器version: '3.8'
services:
selenium-chrome:
image: selenium/standalone-chrome:latest
container_name: selenium-chrome
ports:
- "54444:4444"
- "57900:7900"
shm_size: 2g
environment:
- SE_VNC_NO_PASSWORD=1
volumes:
- ./chrome-data:/home/seluser # 更换挂载路径,确保权限
restart: unless-stopped
command: >
bash -c "mkdir -p /home/seluser/.config/google-chrome &&
touch /home/seluser/.config/google-chrome/test.txt &&
/opt/bin/entry_point.sh"
# 克隆项目
git clone https://github.com/aki66938/xhs-toolkit.git
cd xhs-toolkit
# 运行(会自动安装依赖)
./xhs # Mac/Linux
xhs.bat # Windows
# 或使用 Python
python install_deps.py # 安装依赖向导
./xhs # 启动程序
运行 ./xhs 后会显示友好的菜单界面:
╭─────────────────────────────────────────╮
│ 小红书MCP工具包 v1.3.0 │
│ 快速操作菜单系统 │
╰─────────────────────────────────────────╯
【主菜单】
1. 🔄 数据收集
2. 🌐 浏览器操作
3. 📊 数据管理
4. 🍪 Cookie管理
5. 🚀 MCP服务器
6. ⚙️ 系统工具
0. 退出
# 克隆项目
git clone https://github.com/aki66938/xhs-toolkit.git
cd xhs-toolkit
# 使用uv安装依赖并运行
uv sync
uv run python xhs_toolkit.py status ## 验证工具是否可用
💡 UV使用提示:所有
python命令都可以替换为uv run python,享受更快的依赖管理体验!
# 克隆项目
git clone https://github.com/aki66938/xhs-toolkit.git
cd xhs-toolkit
# 创建虚拟环境(推荐)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# 安装依赖
pip install -r requirements.txt
python xhs_toolkit.py status ## 验证工具是否可用
复制并编辑配置文件:
cp env_example .env
vim .env # 编辑配置
必需配置:
# Chrome浏览器路径
CHROME_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
# ChromeDriver路径
WEBDRIVER_CHROME_DRIVER="/opt/homebrew/bin/chromedriver"
# 方法一:使用交互式菜单
./xhs
# 选择 4 -> Cookie管理 -> 1 -> 获取新的Cookies
# 方法二:直接命令
./xhs cookie save
在弹出的浏览器中,如果是连接的远程浏览器,可以访问 http://ip:57900 访问VNC界面,然后执行以下步骤:
# 方法一:使用交互式菜单
./xhs
# 选择 5 -> MCP服务器 -> 1 -> 启动服务器
# 方法二:直接命令
./xhs server start
Claude Desktop
在 ~/Library/Application Support/Claude/claude_desktop_config.json 中添加:
{
"mcpServers": {
"xhs-toolkit": {
"command": "uv",
"args": [
"--directory",
"/path/to/xhs-toolkit",
"run",
"python",
"-m",
"src.server.mcp_server",
"--stdio"
]
}
}
}
如果未使用UV,可以配置为:
{
"mcpServers": {
"xhs-toolkit": {
"command": "python3",
"args": [
"-m",
"src.server.mcp_server",
"--stdio"
],
"cwd": "/path/to/xhs-toolkit",
"env": {
"PYTHONPATH": "/path/to/xhs-toolkit"
}
}
}
}
注意:
/path/to/xhs-toolkit 替换为实际项目路径~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.jsoncherry studio
在MCP配置中添加
n8n
在n8n AI代理节点的工具中添加配置设置
| 工具名称 | 功能描述 | 参数 | 备注 |
|---|---|---|---|
test_connection | 测试MCP连接 | 无 | 连接状态检查 |
smart_publish_note | 在小红书上发布笔记 ⚡ | 标题、内容、图片、视频、标签、话题 | 支持本地路径、网络URL和话题标签 |
check_task_status | 检查发布的任务状态 | task_id | 查看任务进度 |
get_task_result | 获取已完成任务的结果 | task_id | 获取最终发布结果 |
login_xiaohongshu | 在小红书上智能登录 | force_delogin, quick_mode | MCP专用非交互登录 |
get_creator_data_analysis | 获取创作者数据用于分析 | 无 | AI数据分析专用 |
通过与AI对话,可以完成登录、发布、数据分析等操作,无需学习复杂的命令。
用户:"登录小红书"
重要通知:
headless参数,获取cookies后再切换到无头模式图文发布(本地图片):
请发布一篇小红书笔记,标题:"今日分享",内容:"...",图片路径:"/User/me/xhs/poster.png"
图文发布(在线图片):
请发布一篇小红书笔记,标题:"美食分享",内容:"今天的美食",使用这个网络图片:https://example.com/food.jpg
视频发布:
请发布一篇小红书视频,标题:"今日vlog",内容:"...",视频路径:"/User/me/xhs/video.mp4"
带话题发布:
请发布一篇小红书笔记,标题:"AI学习心得",内容:"今天学习了机器学习基础",话题:"AI,人工智能,学习心得",图片:"/path/to/image.jpg"
请分析我的小红书账号数据,给出内容优化建议
在手动上传过程中,浏览器会弹出窗口让用户选择文件路径,AI会将用户提供的路径参数传递给MCP工具,自动完成上传动作。
自动从小红书创作者处收集数据,支持定时任务和AI智能分析。
get_creator_data_analysis MCP工具获取完整数据使用cron语法编写配置文件.env
# 每6小时采集一次
COLLECTION_SCHEDULE=0 */6 * * *
# 工作日上午9点采集
COLLECTION_SCHEDULE=0 9 * * 1-5
# 每月1号凌晨2点采集
COLLECTION_SCHEDULE=0 2 1 * *
添加交互式菜单和手动操作工具,提供更便捷的操作体验:
# 启动交互式菜单
./xhs
# 或使用命令行
./xhs manual collect --type all # 收集所有数据
./xhs manual browser --page publish # 打开发布页面
./xhs manual export --format excel # 导出Excel
./xhs manual analyze # 分析数据趋势
data-topic属性和隐藏标识符,确保话题获得平台流量推荐