xiaohongshu-automation


Namexiaohongshu-automation JSON
Version 2.0.7 PyPI version JSON
download
home_pageNone
Summary基于 Model Context Protocol (MCP) 的小红书自动化解决方案
upload_time2025-08-19 14:13:58
maintainerNone
docs_urlNone
authorA1721
requires_python>=3.10
licenseNone
keywords automation fastapi mcp xiaohongshu
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 小红书自动化工具

基于 Model Context Protocol (MCP) 的小红书自动化解决方案,为 AI 助手提供内容发布、评论管理和系统监控能力。

## ✨ 新功能:多账号支持

**🎉 版本 2.0 重大更新!**

多账号实现逻辑,现已支持多个小红书账号同时管理和操作:

### 多账号功能特性
- ✅ **多账号管理**: 支持添加、删除、切换多个小红书账号
- ✅ **独立认证**: 每个账号使用独立的cookie文件存储
- ✅ **批量操作**: 可同时使用多个账号进行发布、搜索、评论
- ✅ **账号隔离**: 各账号间完全隔离,避免登录冲突
- ✅ **向后兼容**: 完全兼容原有的单账号使用方式

### 快速体验多账号功能

```python
import requests

# 1. 添加多个账号
accounts = ["13800138000", "13900139000", "13700137000"]
for phone in accounts:
    requests.post("http://localhost:8000/account/add", json={"phone_number": phone})

# 2. 批量发布到不同账号
for phone in accounts:
    requests.post("http://localhost:8000/publish", json={
        "pic_urls": ["https://example.com/image.jpg"],
        "title": f"账号 {phone} 的内容",
        "content": "多账号测试内容",
        "phone_number": phone
    })
```

详细使用说明请参考:[多账号功能指南](MULTI_ACCOUNT_GUIDE.md)

## 🚀 快速开始

### 1. 环境准备

**推荐使用 uv 进行环境管理**(更快更现代的Python包管理器)

```bash
# 安装 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
venv\Scripts\activate      # Windows
# source venv/bin/activate  # macOS/Linux
pip install -r requirements.txt
```

### 🛠️ 开发环境一键设置

#### 方式一:使用便捷脚本(Windows)

```bash
# 一键设置开发环境
scripts\setup_dev.bat
```

#### 方式二:使用 uvx 快速测试(推荐)

无需克隆代码,直接测试最新版本:

```bash
# 快速启动 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
```

#### 方式三:传统开发环境

```bash
# 克隆项目
git clone <repository-url>
cd xiaohongshu-automation

# 使用 uv(推荐)
uv venv                    # 创建虚拟环境
uv sync                    # 安装所有依赖

# 或传统方式
python -m venv venv
venv\Scripts\activate      # Windows
# source venv/bin/activate  # macOS/Linux
pip install -r requirements.txt
```

### 📦 打包和发布

```bash
# 构建包
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(使用便捷脚本)
scripts\publish.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
```

### 2. 启动服务

**重要**: 必须按顺序启动两个服务

```bash
# 第一步:启动 FastAPI 后端服务并且扫码登录小红书
python main.py

# 第二步:启动 MCP 服务器
python mcp_server.py
```

### 2. 配置 AI 客户端

在支持 MCP 的 AI 客户端中配置连接到本地 MCP 服务器。

## 📦 安装发布版本

### 方式一:传统安装

如果项目已发布到 PyPI,用户可以直接安装:

```bash
pip install xiaohongshu-automation
```

### 方式二:使用 uvx(推荐)

**uvx** 是 uv 的一个强大功能,可以直接运行 Python 包而无需先安装到当前环境,非常适合运行 CLI 工具和一次性任务。

#### 优势
- 🚀 **无需安装**: 直接运行包,不污染当前环境
- ⚡ **自动管理**: 自动创建临时环境和依赖管理
- 🔒 **隔离运行**: 每次运行都在独立环境中
- 💾 **缓存优化**: 自动缓存环境,再次运行更快

#### 使用方法

```bash
# 直接运行 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

```bash
# 从本地构建的包运行
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
```

### 方式三:从源码安装

```bash
# 克隆项目
git clone <repository-url>
cd xiaohongshu-automation

# 使用 uv 安装
uv pip install -e .

# 或使用 pip 安装
pip install -e .
```

## 🛠️ 故障排除

### 常见问题:MCP调用成功但AI显示失败

**症状**: MCP服务调用成功,但AI执行结果显示失败
**原因**: FastAPI后端服务未运行
**解决**: 运行 `python main.py` 启动后端服务

详细故障排除指南请参考:[TIMEOUT_TROUBLESHOOTING.md](TIMEOUT_TROUBLESHOOTING.md)

### 快速诊断

```bash
# 运行诊断工具
python test_timeout_improvements.py

# 或在MCP中调用
xiaohongshu_timeout_diagnostic
```

## ⚙️ 功能特性

### 🎯 核心工具

1. **xiaohongshu_publish** - 发布内容到小红书
   - 支持多张图片(1-18张)
   - 内容质量分析和优化建议
   - 智能话题标签和@用户检测

2. **xiaohongshu_get_comments** - 获取评论分析
   - 情感分析和关键词提取
   - 评论统计和互动分析

3. **xiaohongshu_reply_comments** - 批量回复评论
   - 智能回复建议和内容优化
   - 批量处理和语调调整

4. **xiaohongshu_monitor** - 系统监控
   - 健康状态评分
   - 服务状态检查
   - 历史记录分析

5. **xiaohongshu_timeout_diagnostic** - 超时诊断 🆕
   - 网络连接测试
   - 性能分析
   - 配置建议

6. **xiaohongshu_search_notes** - 搜索笔记 🆕
   - 根据关键词搜索相关笔记
   - 支持结果数量限制(1-20条)
   - 返回笔记标题和链接

7. **xiaohongshu_get_note_content** - 获取笔记内容 🆕
   - 抓取笔记的详细内容
   - 提取标题、作者、发布时间和正文
   - 智能区分正文和评论内容

8. **xiaohongshu_analyze_note** - 分析笔记内容 🆕
   - 深度分析笔记内容质量和领域归属
   - 智能提取关键词和主题标签
   - 生成内容质量评估报告

9. **xiaohongshu_post_comment** - 发布评论内容 🆕
   - 指定某个笔记下面发布置顶评论内容
   
### 📚 资源

- **xiaohongshu://monitor/status** - 实时监控状态
- **xiaohongshu://posts/history** - 发布历史记录
- **xiaohongshu://tools/info** - 工具信息总览

### 🎨 提示模板

- **xiaohongshu_content_template** - 内容创作模板
- **xiaohongshu_reply_template** - 评论回复模板
- **xiaohongshu_optimization_tips** - 优化建议模板

## 📋 API 接口

### 发布内容
```http
POST /publish
Content-Type: application/json

{
  "pic_urls": ["https://example.com/image1.jpg"],
  "title": "标题",
  "content": "内容文本"
}
```

### 获取评论(暂未完善)
```http
GET /get_comments?url=https://www.xiaohongshu.com/explore/xxxxx
```

### 回复评论(暂未完善)
```http
POST /post_comments?url=https://www.xiaohongshu.com/explore/xxxxx
Content-Type: application/json

{
  "comment_id_1": ["回复内容1", "回复内容2"],
  "comment_id_2": ["回复内容3"]
}
```

### 搜索笔记 🆕
```http
GET /search_notes?keywords=美食&limit=5
```

### 获取笔记内容 🆕
```http
GET /get_note_content?url=https://www.xiaohongshu.com/explore/xxxxx
```

### 分析笔记 🆕
```http
GET /analyze_note?url=https://www.xiaohongshu.com/explore/xxxxx
```

## ⚙️ 配置选项

### 超时配置

```bash
# 基本超时设置
export FASTAPI_TIMEOUT=30          # 默认超时
export PUBLISH_TIMEOUT=60          # 发布操作超时
export COMMENTS_TIMEOUT=30         # 评论操作超时
export MONITOR_TIMEOUT=15          # 监控操作超时
export CONTENT_TIMEOUT=60          # 内容获取超时 🆕
export ANALYSIS_TIMEOUT=70         # 内容分析超时 🆕
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     # 详细错误信息
```

### 环境配置示例

#### 本地开发
```bash
export FASTAPI_TIMEOUT=30
export PUBLISH_TIMEOUT=60
export ENABLE_AUTO_RETRY=true
export MAX_RETRIES=3
```

#### 生产环境
```bash
export FASTAPI_TIMEOUT=60
export PUBLISH_TIMEOUT=120
export ENABLE_AUTO_RETRY=true
export MAX_RETRIES=5
export RETRY_DELAY=3
```

### 内容获取配置

```bash
# 内容获取超时设置
export CONTENT_TIMEOUT=60          # 笔记内容获取超时
```

## 🧪 测试

### 运行测试套件

```bash
# 基础功能测试
python test_mcp_server.py

# 超时和诊断测试
python test_timeout_improvements.py

# 发布功能专项测试
python test_publish_fix.py

# 搜索功能测试 🆕
python test_search_functionality.py

# 内容抓取功能测试 🆕
python test_content_functionality.py

# 内容分析功能测试 🆕
python test_analyze_functionality.py
```

### 性能监控

```bash
# 启用详细日志
export LOG_LEVEL=DEBUG
python mcp_server.py

# 监控系统状态
xiaohongshu_monitor
```

## 🏗️ 项目结构

```
xiaohongshu-automation/
├── main.py                     # FastAPI 主服务
├── mcp_server.py              # MCP 服务器
├── config.py                  # 配置管理
├── adapters/
│   └── xiaohongshu_adapter.py # 服务适配器
├── tools/                     # MCP 工具
│   ├── base_tool.py          # 基础工具类
│   ├── publish_tool.py       # 发布工具
│   ├── comments_tool.py      # 评论工具
│   ├── monitor_tool.py       # 监控工具
│   ├── timeout_diagnostic_tool.py # 诊断工具 🆕
│   ├── search_tool.py        # 搜索工具 🆕
│   ├── content_tool.py       # 内容抓取工具 🆕
│   ├── analysis_tool.py      # 内容分析工具 🆕
│   └── tool_manager.py       # 工具管理器
├── xiaohongshu_tools.py       # 核心功能模块
├── unti.py                    # 工具函数
├── requirements.txt           # Python 依赖
├── TIMEOUT_TROUBLESHOOTING.md # 故障排除指南 🆕
└── README.md                  # 项目文档
```

## 🔒 依赖

- Python 3.8+
- FastAPI - Web 框架
- MCP (Model Context Protocol) - AI 集成协议
- httpx - HTTP 客户端
- pydantic - 数据验证
- selenium - 浏览器自动化
- requests - HTTP 请求

## 📈 版本历史

### v1.0.0 (2025-06-01)
- ✅ 基础 MCP 服务器实现
- ✅ 核心工具集(发布、评论、监控)
- ✅ 智能重试和超时配置
- ✅ 超时诊断工具
- ✅ 笔记搜索功能 🆕
- ✅ 笔记内容抓取功能 🆕
- ✅ 笔记内容分析功能 🆕
- ✅ 详细的故障排除指南

## 🤝 贡献

欢迎提交 Issue 和 Pull Request 来改进项目。

## 📄 许可证

MIT License

---

## 🆘 获取帮助

如果遇到问题:

1. **查看故障排除指南**: [TIMEOUT_TROUBLESHOOTING.md](TIMEOUT_TROUBLESHOOTING.md)
2. **运行诊断工具**: `python test_timeout_improvements.py`
3. **检查服务状态**: 确保 `python main.py` 正在运行
4. **查看日志**: 启用 `LOG_LEVEL=DEBUG` 获取详细信息

**快速检查清单**:
- [ ] FastAPI 服务已启动 (`python main.py`)
- [ ] MCP 服务器已启动 (`python mcp_server.py`)
- [ ] 可以访问 http://localhost:8000/docs
- [ ] AI 客户端正确配置了 MCP 连接

---

*最后更新: 2025-06-01* 
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "xiaohongshu-automation",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "automation, fastapi, mcp, xiaohongshu",
    "author": "A1721",
    "author_email": null,
    "download_url": null,
    "platform": null,
    "description": "# \u5c0f\u7ea2\u4e66\u81ea\u52a8\u5316\u5de5\u5177\n\n\u57fa\u4e8e Model Context Protocol (MCP) \u7684\u5c0f\u7ea2\u4e66\u81ea\u52a8\u5316\u89e3\u51b3\u65b9\u6848\uff0c\u4e3a AI \u52a9\u624b\u63d0\u4f9b\u5185\u5bb9\u53d1\u5e03\u3001\u8bc4\u8bba\u7ba1\u7406\u548c\u7cfb\u7edf\u76d1\u63a7\u80fd\u529b\u3002\n\n## \u2728 \u65b0\u529f\u80fd\uff1a\u591a\u8d26\u53f7\u652f\u6301\n\n**\ud83c\udf89 \u7248\u672c 2.0 \u91cd\u5927\u66f4\u65b0\uff01**\n\n\u591a\u8d26\u53f7\u5b9e\u73b0\u903b\u8f91\uff0c\u73b0\u5df2\u652f\u6301\u591a\u4e2a\u5c0f\u7ea2\u4e66\u8d26\u53f7\u540c\u65f6\u7ba1\u7406\u548c\u64cd\u4f5c\uff1a\n\n### \u591a\u8d26\u53f7\u529f\u80fd\u7279\u6027\n- \u2705 **\u591a\u8d26\u53f7\u7ba1\u7406**: \u652f\u6301\u6dfb\u52a0\u3001\u5220\u9664\u3001\u5207\u6362\u591a\u4e2a\u5c0f\u7ea2\u4e66\u8d26\u53f7\n- \u2705 **\u72ec\u7acb\u8ba4\u8bc1**: \u6bcf\u4e2a\u8d26\u53f7\u4f7f\u7528\u72ec\u7acb\u7684cookie\u6587\u4ef6\u5b58\u50a8\n- \u2705 **\u6279\u91cf\u64cd\u4f5c**: \u53ef\u540c\u65f6\u4f7f\u7528\u591a\u4e2a\u8d26\u53f7\u8fdb\u884c\u53d1\u5e03\u3001\u641c\u7d22\u3001\u8bc4\u8bba\n- \u2705 **\u8d26\u53f7\u9694\u79bb**: \u5404\u8d26\u53f7\u95f4\u5b8c\u5168\u9694\u79bb\uff0c\u907f\u514d\u767b\u5f55\u51b2\u7a81\n- \u2705 **\u5411\u540e\u517c\u5bb9**: \u5b8c\u5168\u517c\u5bb9\u539f\u6709\u7684\u5355\u8d26\u53f7\u4f7f\u7528\u65b9\u5f0f\n\n### \u5feb\u901f\u4f53\u9a8c\u591a\u8d26\u53f7\u529f\u80fd\n\n```python\nimport requests\n\n# 1. \u6dfb\u52a0\u591a\u4e2a\u8d26\u53f7\naccounts = [\"13800138000\", \"13900139000\", \"13700137000\"]\nfor phone in accounts:\n    requests.post(\"http://localhost:8000/account/add\", json={\"phone_number\": phone})\n\n# 2. \u6279\u91cf\u53d1\u5e03\u5230\u4e0d\u540c\u8d26\u53f7\nfor phone in accounts:\n    requests.post(\"http://localhost:8000/publish\", json={\n        \"pic_urls\": [\"https://example.com/image.jpg\"],\n        \"title\": f\"\u8d26\u53f7 {phone} \u7684\u5185\u5bb9\",\n        \"content\": \"\u591a\u8d26\u53f7\u6d4b\u8bd5\u5185\u5bb9\",\n        \"phone_number\": phone\n    })\n```\n\n\u8be6\u7ec6\u4f7f\u7528\u8bf4\u660e\u8bf7\u53c2\u8003\uff1a[\u591a\u8d26\u53f7\u529f\u80fd\u6307\u5357](MULTI_ACCOUNT_GUIDE.md)\n\n## \ud83d\ude80 \u5feb\u901f\u5f00\u59cb\n\n### 1. \u73af\u5883\u51c6\u5907\n\n**\u63a8\u8350\u4f7f\u7528 uv \u8fdb\u884c\u73af\u5883\u7ba1\u7406**\uff08\u66f4\u5feb\u66f4\u73b0\u4ee3\u7684Python\u5305\u7ba1\u7406\u5668\uff09\n\n```bash\n# \u5b89\u88c5 uv\uff08\u5982\u679c\u8fd8\u6ca1\u5b89\u88c5\uff09\n# Windows: \ncurl -LsSf https://astral.sh/uv/install.ps1 | powershell\n# macOS/Linux:\ncurl -LsSf https://astral.sh/uv/install.sh | sh\n\n# \u514b\u9686\u9879\u76ee\ngit clone <repository-url>\ncd xiaohongshu-automation\n\n# \u65b9\u5f0f\u4e00\uff1a\u4f7f\u7528 uv\uff08\u63a8\u8350\uff09\nuv venv                    # \u521b\u5efa\u865a\u62df\u73af\u5883\nuv sync                    # \u5b89\u88c5\u6240\u6709\u4f9d\u8d56\n\n# \u65b9\u5f0f\u4e8c\uff1a\u4f20\u7edf\u65b9\u5f0f\npython -m venv venv\nvenv\\Scripts\\activate      # Windows\n# source venv/bin/activate  # macOS/Linux\npip install -r requirements.txt\n```\n\n### \ud83d\udee0\ufe0f \u5f00\u53d1\u73af\u5883\u4e00\u952e\u8bbe\u7f6e\n\n#### \u65b9\u5f0f\u4e00\uff1a\u4f7f\u7528\u4fbf\u6377\u811a\u672c\uff08Windows\uff09\n\n```bash\n# \u4e00\u952e\u8bbe\u7f6e\u5f00\u53d1\u73af\u5883\nscripts\\setup_dev.bat\n```\n\n#### \u65b9\u5f0f\u4e8c\uff1a\u4f7f\u7528 uvx \u5feb\u901f\u6d4b\u8bd5\uff08\u63a8\u8350\uff09\n\n\u65e0\u9700\u514b\u9686\u4ee3\u7801\uff0c\u76f4\u63a5\u6d4b\u8bd5\u6700\u65b0\u7248\u672c\uff1a\n\n```bash\n# \u5feb\u901f\u542f\u52a8 FastAPI \u670d\u52a1\u5668\uff08\u4ece PyPI\uff09\nuvx --from xiaohongshu-automation xhs-server\n\n# \u5feb\u901f\u542f\u52a8 MCP \u670d\u52a1\u5668\uff08\u4ece PyPI\uff09\nuvx --from xiaohongshu-automation xhs-mcp\n\n# \u4ece Git \u4ed3\u5e93\u76f4\u63a5\u8fd0\u884c\u6700\u65b0\u5f00\u53d1\u7248\nuvx --from git+https://github.com/A1721/xiaohongshu-automation.git xhs-server\n\n# \u6d4b\u8bd5\u7279\u5b9a\u7248\u672c\nuvx --from xiaohongshu-automation==1.0.0 xhs-server\n```\n\n#### \u65b9\u5f0f\u4e09\uff1a\u4f20\u7edf\u5f00\u53d1\u73af\u5883\n\n```bash\n# \u514b\u9686\u9879\u76ee\ngit clone <repository-url>\ncd xiaohongshu-automation\n\n# \u4f7f\u7528 uv\uff08\u63a8\u8350\uff09\nuv venv                    # \u521b\u5efa\u865a\u62df\u73af\u5883\nuv sync                    # \u5b89\u88c5\u6240\u6709\u4f9d\u8d56\n\n# \u6216\u4f20\u7edf\u65b9\u5f0f\npython -m venv venv\nvenv\\Scripts\\activate      # Windows\n# source venv/bin/activate  # macOS/Linux\npip install -r requirements.txt\n```\n\n### \ud83d\udce6 \u6253\u5305\u548c\u53d1\u5e03\n\n```bash\n# \u6784\u5efa\u5305\nuv build\n\n# \u4f7f\u7528 uvx \u6d4b\u8bd5\u672c\u5730\u6784\u5efa\u7684\u5305\nuvx --from ./dist/xiaohongshu_automation-1.0.0-py3-none-any.whl xhs-server\nuvx --from ./dist/xiaohongshu_automation-1.0.0-py3-none-any.whl xhs-mcp\n\n# \u53d1\u5e03\u5230 PyPI\uff08\u4f7f\u7528\u4fbf\u6377\u811a\u672c\uff09\nscripts\\publish.bat\n\n# \u6216\u624b\u52a8\u53d1\u5e03\nuv pip install twine\ntwine upload dist/*\n\n# \u6d4b\u8bd5\u53d1\u5e03\u5230 TestPyPI\ntwine upload --repository testpypi dist/*\n\n# \u4f7f\u7528 uvx \u6d4b\u8bd5 TestPyPI \u7248\u672c\nuvx --index-url https://test.pypi.org/simple/ --from xiaohongshu-automation xhs-server\n```\n\n### 2. \u542f\u52a8\u670d\u52a1\n\n**\u91cd\u8981**: \u5fc5\u987b\u6309\u987a\u5e8f\u542f\u52a8\u4e24\u4e2a\u670d\u52a1\n\n```bash\n# \u7b2c\u4e00\u6b65\uff1a\u542f\u52a8 FastAPI \u540e\u7aef\u670d\u52a1\u5e76\u4e14\u626b\u7801\u767b\u5f55\u5c0f\u7ea2\u4e66\npython main.py\n\n# \u7b2c\u4e8c\u6b65\uff1a\u542f\u52a8 MCP \u670d\u52a1\u5668\npython mcp_server.py\n```\n\n### 2. \u914d\u7f6e AI \u5ba2\u6237\u7aef\n\n\u5728\u652f\u6301 MCP \u7684 AI \u5ba2\u6237\u7aef\u4e2d\u914d\u7f6e\u8fde\u63a5\u5230\u672c\u5730 MCP \u670d\u52a1\u5668\u3002\n\n## \ud83d\udce6 \u5b89\u88c5\u53d1\u5e03\u7248\u672c\n\n### \u65b9\u5f0f\u4e00\uff1a\u4f20\u7edf\u5b89\u88c5\n\n\u5982\u679c\u9879\u76ee\u5df2\u53d1\u5e03\u5230 PyPI\uff0c\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u5b89\u88c5\uff1a\n\n```bash\npip install xiaohongshu-automation\n```\n\n### \u65b9\u5f0f\u4e8c\uff1a\u4f7f\u7528 uvx\uff08\u63a8\u8350\uff09\n\n**uvx** \u662f uv \u7684\u4e00\u4e2a\u5f3a\u5927\u529f\u80fd\uff0c\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c Python \u5305\u800c\u65e0\u9700\u5148\u5b89\u88c5\u5230\u5f53\u524d\u73af\u5883\uff0c\u975e\u5e38\u9002\u5408\u8fd0\u884c CLI \u5de5\u5177\u548c\u4e00\u6b21\u6027\u4efb\u52a1\u3002\n\n#### \u4f18\u52bf\n- \ud83d\ude80 **\u65e0\u9700\u5b89\u88c5**: \u76f4\u63a5\u8fd0\u884c\u5305\uff0c\u4e0d\u6c61\u67d3\u5f53\u524d\u73af\u5883\n- \u26a1 **\u81ea\u52a8\u7ba1\u7406**: \u81ea\u52a8\u521b\u5efa\u4e34\u65f6\u73af\u5883\u548c\u4f9d\u8d56\u7ba1\u7406\n- \ud83d\udd12 **\u9694\u79bb\u8fd0\u884c**: \u6bcf\u6b21\u8fd0\u884c\u90fd\u5728\u72ec\u7acb\u73af\u5883\u4e2d\n- \ud83d\udcbe **\u7f13\u5b58\u4f18\u5316**: \u81ea\u52a8\u7f13\u5b58\u73af\u5883\uff0c\u518d\u6b21\u8fd0\u884c\u66f4\u5feb\n\n#### \u4f7f\u7528\u65b9\u6cd5\n\n```bash\n# \u76f4\u63a5\u8fd0\u884c FastAPI \u670d\u52a1\u5668\nuvx --from xiaohongshu-automation xhs-server\n\n# \u76f4\u63a5\u8fd0\u884c MCP \u670d\u52a1\u5668\nuvx --from xiaohongshu-automation xhs-mcp\n\n# \u8fd0\u884c\u7279\u5b9a\u811a\u672c\uff08\u5982\u679c\u5305\u63d0\u4f9b\uff09\nuvx --from xiaohongshu-automation --help\n\n# \u6307\u5b9a\u7248\u672c\u8fd0\u884c\nuvx --from xiaohongshu-automation==1.0.0 xhs-server\n\n# \u4ece TestPyPI \u8fd0\u884c\uff08\u6d4b\u8bd5\u7248\u672c\uff09\nuvx --index-url https://test.pypi.org/simple/ --from xiaohongshu-automation xhs-server\n```\n\n#### \u5f00\u53d1\u8005\u4f7f\u7528 uvx\n\n```bash\n# \u4ece\u672c\u5730\u6784\u5efa\u7684\u5305\u8fd0\u884c\nuvx --from ./dist/xiaohongshu_automation-1.0.0-py3-none-any.whl xhs-server\n\n# \u4ece Git \u4ed3\u5e93\u76f4\u63a5\u8fd0\u884c\nuvx --from git+https://github.com/A1721/xiaohongshu-automation.git xhs-server\n```\n\n### \u65b9\u5f0f\u4e09\uff1a\u4ece\u6e90\u7801\u5b89\u88c5\n\n```bash\n# \u514b\u9686\u9879\u76ee\ngit clone <repository-url>\ncd xiaohongshu-automation\n\n# \u4f7f\u7528 uv \u5b89\u88c5\nuv pip install -e .\n\n# \u6216\u4f7f\u7528 pip \u5b89\u88c5\npip install -e .\n```\n\n## \ud83d\udee0\ufe0f \u6545\u969c\u6392\u9664\n\n### \u5e38\u89c1\u95ee\u9898\uff1aMCP\u8c03\u7528\u6210\u529f\u4f46AI\u663e\u793a\u5931\u8d25\n\n**\u75c7\u72b6**: MCP\u670d\u52a1\u8c03\u7528\u6210\u529f\uff0c\u4f46AI\u6267\u884c\u7ed3\u679c\u663e\u793a\u5931\u8d25\n**\u539f\u56e0**: FastAPI\u540e\u7aef\u670d\u52a1\u672a\u8fd0\u884c\n**\u89e3\u51b3**: \u8fd0\u884c `python main.py` \u542f\u52a8\u540e\u7aef\u670d\u52a1\n\n\u8be6\u7ec6\u6545\u969c\u6392\u9664\u6307\u5357\u8bf7\u53c2\u8003\uff1a[TIMEOUT_TROUBLESHOOTING.md](TIMEOUT_TROUBLESHOOTING.md)\n\n### \u5feb\u901f\u8bca\u65ad\n\n```bash\n# \u8fd0\u884c\u8bca\u65ad\u5de5\u5177\npython test_timeout_improvements.py\n\n# \u6216\u5728MCP\u4e2d\u8c03\u7528\nxiaohongshu_timeout_diagnostic\n```\n\n## \u2699\ufe0f \u529f\u80fd\u7279\u6027\n\n### \ud83c\udfaf \u6838\u5fc3\u5de5\u5177\n\n1. **xiaohongshu_publish** - \u53d1\u5e03\u5185\u5bb9\u5230\u5c0f\u7ea2\u4e66\n   - \u652f\u6301\u591a\u5f20\u56fe\u7247\uff081-18\u5f20\uff09\n   - \u5185\u5bb9\u8d28\u91cf\u5206\u6790\u548c\u4f18\u5316\u5efa\u8bae\n   - \u667a\u80fd\u8bdd\u9898\u6807\u7b7e\u548c@\u7528\u6237\u68c0\u6d4b\n\n2. **xiaohongshu_get_comments** - \u83b7\u53d6\u8bc4\u8bba\u5206\u6790\n   - \u60c5\u611f\u5206\u6790\u548c\u5173\u952e\u8bcd\u63d0\u53d6\n   - \u8bc4\u8bba\u7edf\u8ba1\u548c\u4e92\u52a8\u5206\u6790\n\n3. **xiaohongshu_reply_comments** - \u6279\u91cf\u56de\u590d\u8bc4\u8bba\n   - \u667a\u80fd\u56de\u590d\u5efa\u8bae\u548c\u5185\u5bb9\u4f18\u5316\n   - \u6279\u91cf\u5904\u7406\u548c\u8bed\u8c03\u8c03\u6574\n\n4. **xiaohongshu_monitor** - \u7cfb\u7edf\u76d1\u63a7\n   - \u5065\u5eb7\u72b6\u6001\u8bc4\u5206\n   - \u670d\u52a1\u72b6\u6001\u68c0\u67e5\n   - \u5386\u53f2\u8bb0\u5f55\u5206\u6790\n\n5. **xiaohongshu_timeout_diagnostic** - \u8d85\u65f6\u8bca\u65ad \ud83c\udd95\n   - \u7f51\u7edc\u8fde\u63a5\u6d4b\u8bd5\n   - \u6027\u80fd\u5206\u6790\n   - \u914d\u7f6e\u5efa\u8bae\n\n6. **xiaohongshu_search_notes** - \u641c\u7d22\u7b14\u8bb0 \ud83c\udd95\n   - \u6839\u636e\u5173\u952e\u8bcd\u641c\u7d22\u76f8\u5173\u7b14\u8bb0\n   - \u652f\u6301\u7ed3\u679c\u6570\u91cf\u9650\u5236\uff081-20\u6761\uff09\n   - \u8fd4\u56de\u7b14\u8bb0\u6807\u9898\u548c\u94fe\u63a5\n\n7. **xiaohongshu_get_note_content** - \u83b7\u53d6\u7b14\u8bb0\u5185\u5bb9 \ud83c\udd95\n   - \u6293\u53d6\u7b14\u8bb0\u7684\u8be6\u7ec6\u5185\u5bb9\n   - \u63d0\u53d6\u6807\u9898\u3001\u4f5c\u8005\u3001\u53d1\u5e03\u65f6\u95f4\u548c\u6b63\u6587\n   - \u667a\u80fd\u533a\u5206\u6b63\u6587\u548c\u8bc4\u8bba\u5185\u5bb9\n\n8. **xiaohongshu_analyze_note** - \u5206\u6790\u7b14\u8bb0\u5185\u5bb9 \ud83c\udd95\n   - \u6df1\u5ea6\u5206\u6790\u7b14\u8bb0\u5185\u5bb9\u8d28\u91cf\u548c\u9886\u57df\u5f52\u5c5e\n   - \u667a\u80fd\u63d0\u53d6\u5173\u952e\u8bcd\u548c\u4e3b\u9898\u6807\u7b7e\n   - \u751f\u6210\u5185\u5bb9\u8d28\u91cf\u8bc4\u4f30\u62a5\u544a\n\n9. **xiaohongshu_post_comment** - \u53d1\u5e03\u8bc4\u8bba\u5185\u5bb9 \ud83c\udd95\n   - \u6307\u5b9a\u67d0\u4e2a\u7b14\u8bb0\u4e0b\u9762\u53d1\u5e03\u7f6e\u9876\u8bc4\u8bba\u5185\u5bb9\n   \n### \ud83d\udcda \u8d44\u6e90\n\n- **xiaohongshu://monitor/status** - \u5b9e\u65f6\u76d1\u63a7\u72b6\u6001\n- **xiaohongshu://posts/history** - \u53d1\u5e03\u5386\u53f2\u8bb0\u5f55\n- **xiaohongshu://tools/info** - \u5de5\u5177\u4fe1\u606f\u603b\u89c8\n\n### \ud83c\udfa8 \u63d0\u793a\u6a21\u677f\n\n- **xiaohongshu_content_template** - \u5185\u5bb9\u521b\u4f5c\u6a21\u677f\n- **xiaohongshu_reply_template** - \u8bc4\u8bba\u56de\u590d\u6a21\u677f\n- **xiaohongshu_optimization_tips** - \u4f18\u5316\u5efa\u8bae\u6a21\u677f\n\n## \ud83d\udccb API \u63a5\u53e3\n\n### \u53d1\u5e03\u5185\u5bb9\n```http\nPOST /publish\nContent-Type: application/json\n\n{\n  \"pic_urls\": [\"https://example.com/image1.jpg\"],\n  \"title\": \"\u6807\u9898\",\n  \"content\": \"\u5185\u5bb9\u6587\u672c\"\n}\n```\n\n### \u83b7\u53d6\u8bc4\u8bba(\u6682\u672a\u5b8c\u5584)\n```http\nGET /get_comments?url=https://www.xiaohongshu.com/explore/xxxxx\n```\n\n### \u56de\u590d\u8bc4\u8bba(\u6682\u672a\u5b8c\u5584)\n```http\nPOST /post_comments?url=https://www.xiaohongshu.com/explore/xxxxx\nContent-Type: application/json\n\n{\n  \"comment_id_1\": [\"\u56de\u590d\u5185\u5bb91\", \"\u56de\u590d\u5185\u5bb92\"],\n  \"comment_id_2\": [\"\u56de\u590d\u5185\u5bb93\"]\n}\n```\n\n### \u641c\u7d22\u7b14\u8bb0 \ud83c\udd95\n```http\nGET /search_notes?keywords=\u7f8e\u98df&limit=5\n```\n\n### \u83b7\u53d6\u7b14\u8bb0\u5185\u5bb9 \ud83c\udd95\n```http\nGET /get_note_content?url=https://www.xiaohongshu.com/explore/xxxxx\n```\n\n### \u5206\u6790\u7b14\u8bb0 \ud83c\udd95\n```http\nGET /analyze_note?url=https://www.xiaohongshu.com/explore/xxxxx\n```\n\n## \u2699\ufe0f \u914d\u7f6e\u9009\u9879\n\n### \u8d85\u65f6\u914d\u7f6e\n\n```bash\n# \u57fa\u672c\u8d85\u65f6\u8bbe\u7f6e\nexport FASTAPI_TIMEOUT=30          # \u9ed8\u8ba4\u8d85\u65f6\nexport PUBLISH_TIMEOUT=60          # \u53d1\u5e03\u64cd\u4f5c\u8d85\u65f6\nexport COMMENTS_TIMEOUT=30         # \u8bc4\u8bba\u64cd\u4f5c\u8d85\u65f6\nexport MONITOR_TIMEOUT=15          # \u76d1\u63a7\u64cd\u4f5c\u8d85\u65f6\nexport CONTENT_TIMEOUT=60          # \u5185\u5bb9\u83b7\u53d6\u8d85\u65f6 \ud83c\udd95\nexport ANALYSIS_TIMEOUT=70         # \u5185\u5bb9\u5206\u6790\u8d85\u65f6 \ud83c\udd95\nexport HEALTH_CHECK_TIMEOUT=5      # \u5065\u5eb7\u68c0\u67e5\u8d85\u65f6\n\n# \u91cd\u8bd5\u673a\u5236\nexport ENABLE_AUTO_RETRY=true      # \u542f\u7528\u81ea\u52a8\u91cd\u8bd5\nexport MAX_RETRIES=3               # \u6700\u5927\u91cd\u8bd5\u6b21\u6570\nexport RETRY_DELAY=2               # \u91cd\u8bd5\u95f4\u9694\uff08\u79d2\uff09\n\n# \u65e5\u5fd7\u914d\u7f6e\nexport LOG_LEVEL=INFO              # \u65e5\u5fd7\u7ea7\u522b\nexport DETAILED_ERROR_MSG=true     # \u8be6\u7ec6\u9519\u8bef\u4fe1\u606f\n```\n\n### \u73af\u5883\u914d\u7f6e\u793a\u4f8b\n\n#### \u672c\u5730\u5f00\u53d1\n```bash\nexport FASTAPI_TIMEOUT=30\nexport PUBLISH_TIMEOUT=60\nexport ENABLE_AUTO_RETRY=true\nexport MAX_RETRIES=3\n```\n\n#### \u751f\u4ea7\u73af\u5883\n```bash\nexport FASTAPI_TIMEOUT=60\nexport PUBLISH_TIMEOUT=120\nexport ENABLE_AUTO_RETRY=true\nexport MAX_RETRIES=5\nexport RETRY_DELAY=3\n```\n\n### \u5185\u5bb9\u83b7\u53d6\u914d\u7f6e\n\n```bash\n# \u5185\u5bb9\u83b7\u53d6\u8d85\u65f6\u8bbe\u7f6e\nexport CONTENT_TIMEOUT=60          # \u7b14\u8bb0\u5185\u5bb9\u83b7\u53d6\u8d85\u65f6\n```\n\n## \ud83e\uddea \u6d4b\u8bd5\n\n### \u8fd0\u884c\u6d4b\u8bd5\u5957\u4ef6\n\n```bash\n# \u57fa\u7840\u529f\u80fd\u6d4b\u8bd5\npython test_mcp_server.py\n\n# \u8d85\u65f6\u548c\u8bca\u65ad\u6d4b\u8bd5\npython test_timeout_improvements.py\n\n# \u53d1\u5e03\u529f\u80fd\u4e13\u9879\u6d4b\u8bd5\npython test_publish_fix.py\n\n# \u641c\u7d22\u529f\u80fd\u6d4b\u8bd5 \ud83c\udd95\npython test_search_functionality.py\n\n# \u5185\u5bb9\u6293\u53d6\u529f\u80fd\u6d4b\u8bd5 \ud83c\udd95\npython test_content_functionality.py\n\n# \u5185\u5bb9\u5206\u6790\u529f\u80fd\u6d4b\u8bd5 \ud83c\udd95\npython test_analyze_functionality.py\n```\n\n### \u6027\u80fd\u76d1\u63a7\n\n```bash\n# \u542f\u7528\u8be6\u7ec6\u65e5\u5fd7\nexport LOG_LEVEL=DEBUG\npython mcp_server.py\n\n# \u76d1\u63a7\u7cfb\u7edf\u72b6\u6001\nxiaohongshu_monitor\n```\n\n## \ud83c\udfd7\ufe0f \u9879\u76ee\u7ed3\u6784\n\n```\nxiaohongshu-automation/\n\u251c\u2500\u2500 main.py                     # FastAPI \u4e3b\u670d\u52a1\n\u251c\u2500\u2500 mcp_server.py              # MCP \u670d\u52a1\u5668\n\u251c\u2500\u2500 config.py                  # \u914d\u7f6e\u7ba1\u7406\n\u251c\u2500\u2500 adapters/\n\u2502   \u2514\u2500\u2500 xiaohongshu_adapter.py # \u670d\u52a1\u9002\u914d\u5668\n\u251c\u2500\u2500 tools/                     # MCP \u5de5\u5177\n\u2502   \u251c\u2500\u2500 base_tool.py          # \u57fa\u7840\u5de5\u5177\u7c7b\n\u2502   \u251c\u2500\u2500 publish_tool.py       # \u53d1\u5e03\u5de5\u5177\n\u2502   \u251c\u2500\u2500 comments_tool.py      # \u8bc4\u8bba\u5de5\u5177\n\u2502   \u251c\u2500\u2500 monitor_tool.py       # \u76d1\u63a7\u5de5\u5177\n\u2502   \u251c\u2500\u2500 timeout_diagnostic_tool.py # \u8bca\u65ad\u5de5\u5177 \ud83c\udd95\n\u2502   \u251c\u2500\u2500 search_tool.py        # \u641c\u7d22\u5de5\u5177 \ud83c\udd95\n\u2502   \u251c\u2500\u2500 content_tool.py       # \u5185\u5bb9\u6293\u53d6\u5de5\u5177 \ud83c\udd95\n\u2502   \u251c\u2500\u2500 analysis_tool.py      # \u5185\u5bb9\u5206\u6790\u5de5\u5177 \ud83c\udd95\n\u2502   \u2514\u2500\u2500 tool_manager.py       # \u5de5\u5177\u7ba1\u7406\u5668\n\u251c\u2500\u2500 xiaohongshu_tools.py       # \u6838\u5fc3\u529f\u80fd\u6a21\u5757\n\u251c\u2500\u2500 unti.py                    # \u5de5\u5177\u51fd\u6570\n\u251c\u2500\u2500 requirements.txt           # Python \u4f9d\u8d56\n\u251c\u2500\u2500 TIMEOUT_TROUBLESHOOTING.md # \u6545\u969c\u6392\u9664\u6307\u5357 \ud83c\udd95\n\u2514\u2500\u2500 README.md                  # \u9879\u76ee\u6587\u6863\n```\n\n## \ud83d\udd12 \u4f9d\u8d56\n\n- Python 3.8+\n- FastAPI - Web \u6846\u67b6\n- MCP (Model Context Protocol) - AI \u96c6\u6210\u534f\u8bae\n- httpx - HTTP \u5ba2\u6237\u7aef\n- pydantic - \u6570\u636e\u9a8c\u8bc1\n- selenium - \u6d4f\u89c8\u5668\u81ea\u52a8\u5316\n- requests - HTTP \u8bf7\u6c42\n\n## \ud83d\udcc8 \u7248\u672c\u5386\u53f2\n\n### v1.0.0 (2025-06-01)\n- \u2705 \u57fa\u7840 MCP \u670d\u52a1\u5668\u5b9e\u73b0\n- \u2705 \u6838\u5fc3\u5de5\u5177\u96c6\uff08\u53d1\u5e03\u3001\u8bc4\u8bba\u3001\u76d1\u63a7\uff09\n- \u2705 \u667a\u80fd\u91cd\u8bd5\u548c\u8d85\u65f6\u914d\u7f6e\n- \u2705 \u8d85\u65f6\u8bca\u65ad\u5de5\u5177\n- \u2705 \u7b14\u8bb0\u641c\u7d22\u529f\u80fd \ud83c\udd95\n- \u2705 \u7b14\u8bb0\u5185\u5bb9\u6293\u53d6\u529f\u80fd \ud83c\udd95\n- \u2705 \u7b14\u8bb0\u5185\u5bb9\u5206\u6790\u529f\u80fd \ud83c\udd95\n- \u2705 \u8be6\u7ec6\u7684\u6545\u969c\u6392\u9664\u6307\u5357\n\n## \ud83e\udd1d \u8d21\u732e\n\n\u6b22\u8fce\u63d0\u4ea4 Issue \u548c Pull Request \u6765\u6539\u8fdb\u9879\u76ee\u3002\n\n## \ud83d\udcc4 \u8bb8\u53ef\u8bc1\n\nMIT License\n\n---\n\n## \ud83c\udd98 \u83b7\u53d6\u5e2e\u52a9\n\n\u5982\u679c\u9047\u5230\u95ee\u9898\uff1a\n\n1. **\u67e5\u770b\u6545\u969c\u6392\u9664\u6307\u5357**: [TIMEOUT_TROUBLESHOOTING.md](TIMEOUT_TROUBLESHOOTING.md)\n2. **\u8fd0\u884c\u8bca\u65ad\u5de5\u5177**: `python test_timeout_improvements.py`\n3. **\u68c0\u67e5\u670d\u52a1\u72b6\u6001**: \u786e\u4fdd `python main.py` \u6b63\u5728\u8fd0\u884c\n4. **\u67e5\u770b\u65e5\u5fd7**: \u542f\u7528 `LOG_LEVEL=DEBUG` \u83b7\u53d6\u8be6\u7ec6\u4fe1\u606f\n\n**\u5feb\u901f\u68c0\u67e5\u6e05\u5355**:\n- [ ] FastAPI \u670d\u52a1\u5df2\u542f\u52a8 (`python main.py`)\n- [ ] MCP \u670d\u52a1\u5668\u5df2\u542f\u52a8 (`python mcp_server.py`)\n- [ ] \u53ef\u4ee5\u8bbf\u95ee http://localhost:8000/docs\n- [ ] AI \u5ba2\u6237\u7aef\u6b63\u786e\u914d\u7f6e\u4e86 MCP \u8fde\u63a5\n\n---\n\n*\u6700\u540e\u66f4\u65b0: 2025-06-01* ",
    "bugtrack_url": null,
    "license": null,
    "summary": "\u57fa\u4e8e Model Context Protocol (MCP) \u7684\u5c0f\u7ea2\u4e66\u81ea\u52a8\u5316\u89e3\u51b3\u65b9\u6848",
    "version": "2.0.7",
    "project_urls": {
        "Homepage": "https://github.com/A1721/xiaohongshu-automation",
        "Issues": "https://github.com/A1721/xiaohongshu-automation/issues",
        "Repository": "https://github.com/A1721/xiaohongshu-automation.git"
    },
    "split_keywords": [
        "automation",
        " fastapi",
        " mcp",
        " xiaohongshu"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2087316639a8ebe2912a3cd0a4b94000e4d81a2ce8450aa76c550c0e015df4d8",
                "md5": "29ea7301a71f8707b6b74fef67091760",
                "sha256": "350959a74c1461dcbc927b838702b4ae85056708f4a19ee9931dac442fa1cc58"
            },
            "downloads": -1,
            "filename": "xiaohongshu_automation-2.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "29ea7301a71f8707b6b74fef67091760",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 213767,
            "upload_time": "2025-08-19T14:13:58",
            "upload_time_iso_8601": "2025-08-19T14:13:58.902768Z",
            "url": "https://files.pythonhosted.org/packages/20/87/316639a8ebe2912a3cd0a4b94000e4d81a2ce8450aa76c550c0e015df4d8/xiaohongshu_automation-2.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-19 14:13:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "A1721",
    "github_project": "xiaohongshu-automation",
    "github_not_found": true,
    "lcname": "xiaohongshu-automation"
}
        
Elapsed time: 2.31590s