zhihu-scraper-mcp
# 知乎 Scraper MCP Server
一个 MCP Server,为 MCP 客户端提供**知乎全文正文、完整评论树、分类型搜索**的读取能力。
它是对 [`zhihu-toolkit` CLI](https://github.com/KrisTHL181/zhihu-cli)(`zhihu` 命令)的薄封装:每个工具都调用 CLI 的 `--json` 接口,把结果裁剪成精简结构再返回,避免头像/HTML/冗余时间戳等字段撑爆模型上下文。
> 它专注三块能力:**回答/文章全文**、**完整评论树**、**按类型的精确搜索**——适合需要精确列表、抓正文、抓评论的场景。
## 能力概览
| 工具 | 作用 |
| --- | --- |
| `search_questions` | 按关键词搜索问题(标题/描述/回答数/浏览量/关注数/URL) |
| `search_articles` | 按关键词搜索文章(专栏) |
| `search_users` | 按关键词搜索用户 |
| `search_topics` | 按关键词搜索话题 |
| `get_fulltext` | 传入 URL,返回回答/文章的完整正文(Markdown);问题 URL 返回其下全部回答的合并全文 |
| `get_comments` | 返回任意内容下的完整评论树(含嵌套子评论、点赞、作者、时间) |
## 环境要求
- Python `3.12+`
- [uv](https://github.com/astral-sh/uv)
- 一份知乎登录态(Cookie),通过 `zhihu auth paste` 导入;本 Server **不管理、不存储**凭据。
## 快速开始
见 [`INSTALL.md`](INSTALL.md)(面向 Claude Code / Agent 自安装)。工具的详细参数与使用建议见 [`USAGE.md`](USAGE.md)。
一句话版本:
```bash
git clone https://github.com/luyanhexay/zhihu-scraper-mcp.git
cd zhihu-scraper-mcp
uv sync --locked
.venv/bin/zhihu auth paste # 粘贴浏览器 DevTools 复制的 cURL,Ctrl+D 结束
```
然后在 Claude Code 中注册(把 `<ABS>` 换成本仓库绝对路径):
```bash
claude mcp add zhihu-scraper -- <ABS>/.venv/bin/zhihu-scraper-mcp
```
## 凭据与隐私
- 认证信息由 `zhihu` CLI 存放在 `~/.zhihu-cli/`,**不在本仓库内**。
- 本仓库不包含任何 Cookie;`.gitignore` 额外拦截 `cookies.json` 等文件以防误提交。
- 分发本仓库不会泄露你的知乎账号。使用者需自行导入自己的登录态。
## 已知问题
- 单篇回答的 HTML 端点常被知乎风控(`__zse_ck`)拦截。`get_fulltext` 会自动回退到"从问题 API 中挑出对应回答"的路径,因此请尽量传**含 `/question/<id>/answer/<id>` 的完整回答 URL**。
- 搜索关键词要精简(≤3 词),过长易返回空。
- 触发风控时先在浏览器完成验证,再重新 `zhihu auth paste` 刷新登录态。
## 致谢
- [zhihu-toolkit / zhihu-cli](https://github.com/KrisTHL181/zhihu-cli)
- [Model Context Protocol](https://modelcontextprotocol.io/)
## License
MIT
TDQS
Scored across 6 tools
Each of the 6 tools has a unique, non-overlapping purpose: four discovery endpoints (questions/articles/users/topics) and two retrieval endpoints (full text/comments). The overlap-prone tool is get_fulltext, which gracefully handles multiple URL types through explicit, well-documented auto-detection rather than ambiguity. The distinct search_* endpoints use the resource type (question/article/user/topic) as an unambiguous differentiator.
All tools consistently follow a lowercase snake_case verb_noun convention. The 'search_' prefix uniformly denotes list-returning queries, while 'get_' denotes content retrieval with a specific identifier, which is a clear and conventional semantic split. No mixing of casing styles or verb forms exists, creating a predictable, learnable API.
Six tools is a well-scoped number for this domain: each tool serves a distinct, non-overlapping function, avoiding both under-powered overloading and needless fragmentation. The search endpoints could theoretically be merged, but keeping them separate preserves type-specific return schemas (e.g., questions include answer count, articles include author/abstract) without parameter bloat. Similarly, get_fulltext's auto-detection responsibly consolidates several potential get_* tools into one ergonomic interface.
For a read-only scraper, the surface is well-considered, covering discovery (all four primary Zhihu entities), full-content retrieval, and comment trees, which addresses the core use cases end-to-end. Minor gaps exist, such as no dedicated structured user profile endpoint or trending/hot-topic access, but these fall outside the stated purpose. Overall, the 4 search + 2 fetch design is coherent and fully functional for its intended role.