modelscope·@parsons0503/xiaohongshu-automation
小红书-自动化
基于 Model Context Protocol (MCP) 的小红书自动化解决方案,为 AI 助手提供内容发布、评论管理和系统监控能力。
🎉 现已支持 SSE 实时数据推送!
新增的 SSE 功能提供:
# 启动 SSE 服务器
python mcp_server.py --sse
# 或者直接启动
python mcp_sse_server.py
在浏览器中打开 sse_web_client.html 体验实时监控界面,或查看 SSE_GUIDE.md 获取完整使用指南。
推荐使用 uv 进行环境管理(更快更现代的Python包管理器)
# 安装 uv(如果还没安装)
# Windows:
curl -LsSf https://astral.sh/uv/install.ps1 | powershell
# macOS/Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh
# 克隆项目
git clone <repository-url>
cd xiaohongshu-automation
# 方式一:使用 uv(推荐)
uv venv # 创建虚拟环境
uv sync # 安装所有依赖
# 方式二:传统方式
python -m venv venv
venvScriptsactivate # Windows
# source venv/bin/activate # macOS/Linux
pip install -r requirements.txt
# 一键设置开发环境
scriptssetup_dev.bat
无需克隆代码,直接测试最新版本:
# 快速启动 FastAPI 服务器(从 PyPI)
uvx --from xiaohongshu-automation xhs-server
# 快速启动 MCP 服务器(从 PyPI)
uvx --from xiaohongshu-automation xhs-mcp
# 从 Git 仓库直接运行最新开发版
uvx --from git+https://github.com/A1721/xiaohongshu-automation.git xhs-server
# 测试特定版本
uvx --from xiaohongshu-automation==1.0.0 xhs-server
# 克隆项目
git clone <repository-url>
cd xiaohongshu-automation
# 使用 uv(推荐)
uv venv # 创建虚拟环境
uv sync # 安装所有依赖
# 或传统方式
python -m venv venv
venvScriptsactivate # Windows
# source venv/bin/activate # macOS/Linux
pip install -r requirements.txt
# 构建包
uv build
# 使用 uvx 测试本地构建的包
uvx --from ./dist/xiaohongshu_automation-1.0.0-py3-none-any.whl xhs-server
uvx --from ./dist/xiaohongshu_automation-1.0.0-py3-none-any.whl xhs-mcp
# 发布到 PyPI(使用便捷脚本)
scriptspublish.bat
# 或手动发布
uv pip install twine
twine upload dist/*
# 测试发布到 TestPyPI
twine upload --repository testpypi dist/*
# 使用 uvx 测试 TestPyPI 版本
uvx --index-url https://test.pypi.org/simple/ --from xiaohongshu-automation xhs-server
重要: 必须按顺序启动两个服务
# 第一步:启动 FastAPI 后端服务并且扫码登录小红书
python main.py
# 第二步:启动 MCP 服务器
python mcp_server.py
在支持 MCP 的 AI 客户端中配置连接到本地 MCP 服务器。
如果项目已发布到 PyPI,用户可以直接安装:
pip install xiaohongshu-automation
uvx 是 uv 的一个强大功能,可以直接运行 Python 包而无需先安装到当前环境,非常适合运行 CLI 工具和一次性任务。
# 直接运行 FastAPI 服务器
uvx --from xiaohongshu-automation xhs-server
# 直接运行 MCP 服务器
uvx --from xiaohongshu-automation xhs-mcp
# 运行特定脚本(如果包提供)
uvx --from xiaohongshu-automation --help
# 指定版本运行
uvx --from xiaohongshu-automation==1.0.0 xhs-server
# 从 TestPyPI 运行(测试版本)
uvx --index-url https://test.pypi.org/simple/ --from xiaohongshu-automation xhs-server
# 从本地构建的包运行
uvx --from ./dist/xiaohongshu_automation-1.0.0-py3-none-any.whl xhs-server
# 从 Git 仓库直接运行
uvx --from git+https://github.com/A1721/xiaohongshu-automation.git xhs-server
# 克隆项目
git clone <repository-url>
cd xiaohongshu-automation
# 使用 uv 安装
uv pip install -e .
# 或使用 pip 安装
pip install -e .
症状: MCP服务调用成功,但AI执行结果显示失败
原因: FastAPI后端服务未运行
解决: 运行 python main.py 启动后端服务
详细故障排除指南请参考:TIMEOUT_TROUBLESHOOTING.md
# 运行诊断工具
python test_timeout_improvements.py
# 或在MCP中调用
xiaohongshu_timeout_diagnostic
xiaohongshu_publish - 发布内容到小红书
xiaohongshu_get_comments - 获取评论分析
xiaohongshu_reply_comments - 批量回复评论
xiaohongshu_monitor - 系统监控
xiaohongshu_timeout_diagnostic - 超时诊断 🆕
POST /publish
Content-Type: application/json
{
"pic_urls": ["https://example.com/image1.jpg"],
"title": "标题",
"content": "内容文本"
}
GET /get_comments?url=https://www.xiaohongshu.com/explore/xxxxx
POST /post_comments?url=https://www.xiaohongshu.com/explore/xxxxx
Content-Type: application/json
{
"comment_id_1": ["回复内容1", "回复内容2"],
"comment_id_2": ["回复内容3"]
}
# 基本超时设置
export FASTAPI_TIMEOUT=30 # 默认超时
export PUBLISH_TIMEOUT=60 # 发布操作超时
export COMMENTS_TIMEOUT=30 # 评论操作超时
export MONITOR_TIMEOUT=15 # 监控操作超时
export HEALTH_CHECK_TIMEOUT=5 # 健康检查超时
# 重试机制
export ENABLE_AUTO_RETRY=true # 启用自动重试
export MAX_RETRIES=3 # 最大重试次数
export RETRY_DELAY=2 # 重试间隔(秒)
# 日志配置
export LOG_LEVEL=INFO # 日志级别
export DETAILED_ERROR_MSG=true # 详细错误信息
export FASTAPI_TIMEOUT=30
export PUBLISH_TIMEOUT=60
export ENABLE_AUTO_RETRY=true
export MAX_RETRIES=3
export FASTAPI_TIMEOUT=60
export PUBLISH_TIMEOUT=120
export ENABLE_AUTO_RETRY=true
export MAX_RETRIES=5
export RETRY_DELAY=3
# 基础功能测试
python test_mcp_server.py
# 超时和诊断测试
python test_timeout_improvements.py
# 发布功能专项测试
python test_publish_fix.py
# 启用详细日志
export LOG_LEVEL=DEBUG
python mcp_server.py
# 监控系统状态
xiaohongshu_monitor
#…
快递100 MCP Server提供快递信息查询、快递运费预估比价、快递时效查询(含发货前时效查询与在途动态时效查询)等功能。
视频合成、剪辑、素材创作等一系列工具。支持图生视频、一张或多张图片合成视频、一个或多个视频合成视频、支持将配音、背景音乐等进行合成,支持字幕识别、字幕打轴等功能。
即梦AI全能力生成MCP服务是一个基于Model Context Protocol (MCP)的AI图像和视频生成工具,集成了火山引擎即梦AI的强大生成能力。
一个集成了Figma API的模型上下文协议服务器,允许与Figma文件、评论、组件、项目和webhook管理进行交互。
语言类型:英语 翻译结果:具有完整API功能的Figma MCP
您可以在支持MCP协议的AI模型客户端中搜索授权的高清商业视频素材。