diff --git a/README.md b/README.md index 11e776b..2bbb12e 100644 --- a/README.md +++ b/README.md @@ -63,12 +63,12 @@ AI Agent 已经能帮你写代码、改文档、管项目——但你让它去 | 🌐 **网页** | 阅读任意网页 | — | 无需配置 | | 📺 **YouTube** | 字幕提取 + 视频搜索 | — | 无需配置 | | 📡 **RSS** | 阅读任意 RSS/Atom 源 | — | 无需配置 | -| 🔍 **全网搜索** | — | 全网语义搜索 | 告诉 Agent「帮我配 Exa 搜索」(免费 Key) | +| 🔍 **全网搜索** | — | 全网语义搜索 | 自动配置(MCP 接入,免费无需 Key) | | 📦 **GitHub** | 读公开仓库 + 搜索 | 私有仓库、提 Issue/PR、Fork | 告诉 Agent「帮我登录 GitHub」 | | 🐦 **Twitter/X** | 读单条推文 | 搜索推文、浏览时间线、发推 | 告诉 Agent「帮我配 Twitter」 | | 📺 **B站** | 本地:字幕提取 + 搜索 | 服务器也能用 | 告诉 Agent「帮我配代理」 | | 📖 **Reddit** | 搜索(通过 Exa 免费) | 读帖子和评论 | 告诉 Agent「帮我配代理」 | -| 📕 **小红书** | — | 阅读、搜索、发帖、评论、点赞 | 告诉 Agent「帮我配置小红书」 | +| 📕 **小红书** | — | 阅读、搜索、发帖、评论、点赞 | `docker run -d -p 18060:18060 xpzouying/xiaohongshu-mcp` 然后告诉 Agent「帮我配置小红书」 | > **不知道怎么配?不用查文档。** 直接告诉 Agent「帮我配 XXX」,它知道需要什么、会一步一步引导你。 > @@ -163,7 +163,7 @@ channels/ | 搜全网 | [Exa](https://exa.ai) via [mcporter](https://github.com/nicepkg/mcporter) | AI 语义搜索,MCP 接入免 Key | | GitHub | [gh CLI](https://cli.github.com) | 官方工具,认证后完整 API 能力 | | 读 RSS | [feedparser](https://github.com/kurtmckee/feedparser) | Python 生态标准选择,2.3K Star | -| 小红书 | [xiaohongshu-mcp](https://github.com/user/xiaohongshu-mcp) | 内部 API,不受反爬限制 | +| 小红书 | [xiaohongshu-mcp](https://github.com/xpzouying/xiaohongshu-mcp) | ⭐9K+,Go 语言,Docker 一键部署 | > 📌 这些都是「当前选型」。不满意?换掉对应文件就行。这正是脚手架的意义。 diff --git a/agent_reach/channels/xiaohongshu.py b/agent_reach/channels/xiaohongshu.py index 634de37..1914bc6 100644 --- a/agent_reach/channels/xiaohongshu.py +++ b/agent_reach/channels/xiaohongshu.py @@ -49,13 +49,16 @@ class XiaoHongShuChannel(Channel): def check(self, config=None): if not shutil.which("mcporter"): return "off", ( - "需要 mcporter + xiaohongshu-mcp。安装:\n" - " npm install -g mcporter\n" - " 详见 https://github.com/user/xiaohongshu-mcp" + "需要 mcporter + xiaohongshu-mcp。安装步骤:\n" + " 1. npm install -g mcporter\n" + " 2. docker run -d --name xiaohongshu-mcp -p 18060:18060 xpzouying/xiaohongshu-mcp\n" + " 3. mcporter config add xiaohongshu http://localhost:18060/mcp\n" + " 详见 https://github.com/xpzouying/xiaohongshu-mcp" ) if not self._mcporter_ok(): return "off", ( "mcporter 已装但小红书 MCP 未配置。运行:\n" + " docker run -d --name xiaohongshu-mcp -p 18060:18060 xpzouying/xiaohongshu-mcp\n" " mcporter config add xiaohongshu http://localhost:18060/mcp" ) try: @@ -74,9 +77,10 @@ class XiaoHongShuChannel(Channel): "⚠️ 小红书需要 mcporter + xiaohongshu-mcp 才能使用。\n\n" "安装步骤:\n" "1. npm install -g mcporter\n" - "2. 安装 xiaohongshu-mcp 服务\n" + "2. docker run -d --name xiaohongshu-mcp -p 18060:18060 xpzouying/xiaohongshu-mcp\n" "3. mcporter config add xiaohongshu http://localhost:18060/mcp\n" - "4. 运行 agent-reach install --env=auto" + "4. 运行 agent-reach doctor 检查状态\n\n" + "详见 https://github.com/xpzouying/xiaohongshu-mcp" ), url=url, platform="xiaohongshu", ) diff --git a/agent_reach/cli.py b/agent_reach/cli.py index 68e1bd7..08173cb 100644 --- a/agent_reach/cli.py +++ b/agent_reach/cli.py @@ -433,7 +433,10 @@ def _install_mcporter(): ) print(" ✅ XiaoHongShu MCP auto-detected and configured") except Exception: - print(" ⬜ XiaoHongShu MCP not detected (optional — install xiaohongshu-mcp for XHS support)") + print(" ⬜ XiaoHongShu MCP not detected (optional)") + print(" Install: docker run -d --name xiaohongshu-mcp -p 18060:18060 xpzouying/xiaohongshu-mcp") + print(" Then: mcporter config add xiaohongshu http://localhost:18060/mcp") + print(" Repo: https://github.com/xpzouying/xiaohongshu-mcp") except Exception: pass diff --git a/agent_reach/guides/setup-exa.md b/agent_reach/guides/setup-exa.md index 01d7b06..c0349d5 100644 --- a/agent_reach/guides/setup-exa.md +++ b/agent_reach/guides/setup-exa.md @@ -1,54 +1,41 @@ # Exa Search 配置指南 ## 功能说明 -Exa 是一个语义搜索引擎,免费提供 1000 次/月搜索。配置后解锁: -- 全网搜索 +Exa 是一个 AI 语义搜索引擎。通过 MCP 接入,**免费、无需 API Key**。配置后解锁: +- 全网语义搜索 - Reddit 搜索(通过 site:reddit.com) - Twitter 搜索(通过 site:x.com) ## Agent 可自动完成的步骤 -1. 检查是否已配置: +`agent-reach install --env=auto` 会自动完成以下步骤,通常不需要手动操作。 + +### 1. 安装 mcporter +```bash +npm install -g mcporter +``` + +### 2. 注册 Exa MCP +```bash +mcporter config add exa https://mcp.exa.ai/mcp +``` + +### 3. 验证 ```bash agent-reach doctor | grep "Web Search" -``` - -2. 如果用户提供了 key,写入配置: -```bash -# 方法1: 通过 setup 命令 -agent-reach setup - -# 方法2: 直接写入配置文件 -python3 -c " -from agent_reach.config import Config -c = Config() -c.set('exa_api_key', '用户提供的KEY') -print('✅ Exa API key saved') -" -``` - -3. 测试是否有效: -```bash -agent-reach search "test query" -n 1 +agent-reach search "test" -n 1 ``` ## 需要用户手动做的步骤 -请告诉用户: +**无。** Exa 通过 MCP 接入,免费、无需注册、无需 API Key。 -> 我需要一个 Exa API Key 来开启搜索功能。完全免费,每月 1000 次搜索。 -> -> 步骤: -> 1. 打开 https://exa.ai -> 2. 点击 "Get API Key" 或 "Sign Up" -> 3. 用 Google 账号或邮箱注册 -> 4. 注册后在 Dashboard 页面复制你的 API Key -> 5. 把 Key 发给我 -> -> 大概 30 秒就能搞定。 +如果 `agent-reach install` 因为网络问题没有自动配置 Exa,手动运行上面两条命令即可。 -## Agent 收到 key 后的操作 +## 常见问题 -1. 写入配置:`config.set("exa_api_key", key)` -2. 测试:运行一次搜索确认可用 -3. 反馈:"✅ 全网搜索已开启!现在我可以帮你搜索全网、Reddit 和 Twitter 了。" +**Q: 有搜索次数限制吗?** +A: MCP 端点由 Exa 官方提供(mcp.exa.ai),当前免费无限制。如果未来有变化,会在 agent-reach 更新中适配。 + +**Q: mcporter 是什么?** +A: MCP 协议的命令行桥接工具,用来调用 MCP Server。Agent Reach 用它来连接 Exa 和小红书。 diff --git a/agent_reach/guides/setup-xiaohongshu.md b/agent_reach/guides/setup-xiaohongshu.md index 69518ab..bca17e4 100644 --- a/agent_reach/guides/setup-xiaohongshu.md +++ b/agent_reach/guides/setup-xiaohongshu.md @@ -1,42 +1,71 @@ # 小红书配置指南 ## 功能说明 -读取小红书笔记内容。需要 Playwright(浏览器自动化)和一次性登录。 +读取和搜索小红书笔记。通过 [xiaohongshu-mcp](https://github.com/xpzouying/xiaohongshu-mcp) 实现(⭐9K+,Go 语言,内置 Chrome 浏览器)。 + +## 前置条件 +- Docker(用来运行 xiaohongshu-mcp 服务) +- mcporter CLI(MCP 协议桥接工具) ## Agent 可自动完成的步骤 -1. 检查 Playwright 是否安装: +### 1. 安装 mcporter ```bash -python3 -c "import playwright; print('installed')" 2>&1 +npm install -g mcporter ``` -2. 安装 Playwright + 浏览器: +### 2. 启动 xiaohongshu-mcp 服务 ```bash -pip install playwright -playwright install chromium +docker run -d \ + --name xiaohongshu-mcp \ + -p 18060:18060 \ + xpzouying/xiaohongshu-mcp ``` -3. 检查是否已有登录态: +> 如需代理(服务器部署推荐): +> ```bash +> docker run -d \ +> --name xiaohongshu-mcp \ +> -p 18060:18060 \ +> -e XHS_PROXY=http://user:pass@ip:port \ +> xpzouying/xiaohongshu-mcp +> ``` + +### 3. 注册到 mcporter ```bash -# 检查 cookie 文件是否存在 -ls ~/.agent-reach/xhs_cookies.json 2>/dev/null +mcporter config add xiaohongshu http://localhost:18060/mcp ``` +### 4. 验证 +```bash +agent-reach doctor +``` + +应该看到小红书显示为 ✅ 或 ⚠️(MCP 已连接但未登录)。 + ## 需要用户手动做的步骤 -请告诉用户: +如果 doctor 显示"MCP 已连接但未登录": > 小红书需要登录一次(之后会记住你的登录状态)。 > -> 我现在会打开一个浏览器窗口,显示小红书登录页面。你需要: -> 1. 用手机小红书 App 扫描屏幕上的二维码 -> 2. 在手机上确认登录 -> 3. 看到首页后告诉我"登录好了" -> -> 之后就不需要再登录了(除非 cookie 过期,大约 1-3 个月)。 +> 打开 http://localhost:18060 ,用手机小红书 App 扫描二维码登录。 +> 登录后 cookie 会自动保存在 Docker 容器内,大约 1-3 个月有效。 -## Agent 收到确认后的操作 +## 常见问题 -1. 保存浏览器 cookie 到 `~/.agent-reach/xhs_cookies.json` -2. 测试:读取一条小红书笔记 -3. 反馈:"✅ 小红书已配置!现在我可以读取小红书笔记了。" +**Q: Docker 容器重启后 cookie 丢了?** +A: 挂载数据卷持久化: +```bash +docker run -d \ + --name xiaohongshu-mcp \ + -p 18060:18060 \ + -v xhs-data:/app/data \ + xpzouying/xiaohongshu-mcp +``` + +**Q: 服务器上小红书提示 IP 风险?** +A: 加代理参数 `-e XHS_PROXY=http://user:pass@ip:port`,推荐住宅代理。 + +**Q: 我不想用 Docker?** +A: 可以从源码编译:https://github.com/xpzouying/xiaohongshu-mcp diff --git a/docs/install.md b/docs/install.md index 787b8a8..976583d 100644 --- a/docs/install.md +++ b/docs/install.md @@ -58,6 +58,19 @@ agent-reach configure twitter-cookies "PASTED_STRING" agent-reach configure proxy http://user:pass@ip:port ``` +**XiaoHongShu / 小红书 (需要 Docker):** +> "小红书需要一个 MCP 服务。需要你的机器上有 Docker。安装好 Docker 后我来搞定剩下的。" + +```bash +docker run -d --name xiaohongshu-mcp -p 18060:18060 xpzouying/xiaohongshu-mcp +mcporter config add xiaohongshu http://localhost:18060/mcp +``` + +> 如果在服务器上,建议加代理避免 IP 风控: +> `docker run -d --name xiaohongshu-mcp -p 18060:18060 -e XHS_PROXY=http://user:pass@ip:port xpzouying/xiaohongshu-mcp` +> +> 首次使用需要扫码登录,打开 http://localhost:18060 操作。 + ### Step 4: Final check Run `agent-reach doctor` one final time and report the results to your user.