zhihu-mcp CLAUDE.md

zhihu-mcp CLAUDE.md is an instructions file for coding agents from alizeeblack-code/zhihu-mcp. It costs 827 tokens per session, scanned A, original, MIT.

Repository instructions for zhihu-mcp, a server that lets AI agents interact with Zhihu, a Chinese question-and-answer website. They describe the project structure, Chinese-language conventions, browser setup, and tested page selectors.

In plain words
What is it for?
Use them when developing, reviewing, or debugging zhihu-mcp, especially its Playwright browser scraping, cookie handling, SQLite storage, and Zhihu page extraction.
Why use it?
They give coding agents the project context and constraints needed to change the server safely. They also prevent invalid browser-page queries when using standard CSS and JavaScript.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/alizeeblack-code/zhihu-mcp/claude-md
Clone the repo
git clone --depth 1 https://github.com/alizeeblack-code/zhihu-mcp

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for zhihu-mcp CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/alizeeblack-code/zhihu-mcp/claude-md.svg)](https://agentmods.dev/instructions/alizeeblack-code/zhihu-mcp/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/alizeeblack-code/zhihu-mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/alizeeblack-code/zhihu-mcp/claude-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 827 This file is loaded in full into every session.
When invoked 827 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00827 $0.00827
Opus 5 $0.00413 $0.00413
Sonnet 5 $0.00165 $0.00165
Haiku 4.5 $0.00083 $0.00083

Measured 4d ago against content hash 80962bf073b6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

zhihu-mcp CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 60 lines

What it actually says

CLAUDE.md

本项目使用中文作为主要沟通语言。提交说明、文档、注释优先使用中文。

项目概述

zhihu-mcp 是一个知乎 MCP 服务器,让 AI Agent 能与知乎交互。基于 Playwright + stealth 反检测驱动 headless Chromium 抓取知乎页面。

关键架构

  • mcp_server.py — FastMCP 入口,注册所有 MCP 工具
  • scraper.py — 核心 DOM 提取,所有 JS 在 page.evaluate() 中执行
  • browser/manager.py — Playwright 浏览器生命周期(persistent/non-persistent context)
  • browser/stealth.py — 反检测 JS 注入(navigator.webdriver 覆盖、Canvas 噪声等)
  • pinchtab_client.py — Pinchtab HTTP 后端(备用,当前未使用)
  • cookies/manager.py — Cookie 加载/保存/提取
  • storage.py — SQLite 活动数据存储
  • config.py — 配置管理(BrowserConfig dataclass)

重要约束

page.evaluate() 只支持标准 CSS/JS

Playwright 伪选择器(:has-text():visible 等)在 page.evaluate() 内无效。必须用标准 DOM API:

// 错误:document.querySelector('button:has-text("评论")')
// 正确:
for (const b of document.querySelectorAll('button')) {
    if (b.textContent.includes('评论')) { b.click(); break; }
}

知乎 DOM 选择器(已验证)

元素 选择器 注意
回答作者 .AuthorInfo-content .UserLink-link 跳过空头像链接(遍历取首个有文本的)
点赞数 button[aria-label*="赞同"] 解析 aria-label 属性,不是 textContent
评论数 .ContentItem-actions button 含 "条评论" 不要用全局 button,会匹配到问题级评论按钮
评论内容 .CommentContent 文本直接在元素内,作者在父元素的兄弟节点 a[href*="/people/"]
回答数 .List-headerText 数字含逗号(1,003),需 replace(/,/g, '')
回答页多按钮 回答页同时显示多个回答 .ContentItem-actions 限定作用域,避免取到其他回答的数据

评论 URL 匹配

get_comments 判断是否需要导航时,必须比较完整路径(url.split('?')[0]),不能截断比较——同一问题下不同回答 URL 前缀相同。

代理绕过

浏览器启动参数包含 --proxy-bypass-list=*.zhihu.com,zhihu.com,*.zhimg.com,访问知乎时不走系统代理。

开发与测试

  • 测试脚本在 tests/ 目录(已 gitignored)
  • tests/test_core.py 是主要的集成测试脚本
  • 默认使用 headless 模式(config.browser.headless = True),调试时可改为 False
  • 需要有效的 cookies.json(含 z_c0 认证 token)才能正常抓取

已知限制

  • 搜索功能(SPA 渲染)不稳定,wait_for_selector 时机问题
  • 问题页仅加载首屏约 5 条回答,更多需要实现滚动加载
  • CSS Modules 类名(如 css-14nvvry)不稳定,不要依赖
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 60 lines · 827 tokens per session scan A 80962bf073b6

Subscribe to this mod's changes

zhihu-mcp CLAUDE.md is an instructions file published in the GitHub repository alizeeblack-code/zhihu-mcp (4 stars, last pushed 6mo ago), licensed MIT. It adds 827 tokens to every session, about $0.0041 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other instructions, from other repositories