zhihu-mcp: Instructions file for Claude Code

CLAUDE.md

zhihu-mcp CLAUDE.md is an instructions file for Claude Code 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 for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: mentions CLAUDE.md.

This is alizeeblack-code/zhihu-mcp's own configuration. It tells Claude Code how to work on zhihu-mcp itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything zhihu-mcp configures →

Reuse

Borrowing it

Nothing to install: this file belongs to alizeeblack-code/zhihu-mcp. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/alizeeblack-code/zhihu-mcp/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/alizeeblack-code/zhihu-mcp

Made for: Claude Code.

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/github.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/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for zhihu-mcp CLAUDE.md

Your own site · 80×15
<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="Reviewed on agentmods" width="80" 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. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00827 $0.00827
Opus 5.5 $0.00331 $0.00331
Sonnet 5.5 $0.00165 $0.00165
Haiku 4.5 $0.00083 $0.00083

Measured 2mo ago against content hash 80962bf073b6, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 2mo 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. 2mo 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 (5 stars, last pushed 8mo ago), licensed MIT. It adds 827 tokens to every session, about $0.0033 per session on Opus 5.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

zhihu-mcp CLAUDE.md compared with instructions from other repositories

zhihu-mcp CLAUDE.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
zhihu-mcp CLAUDE.mdalizeeblack-code/zhihu-mcpInstructions file58mo agoMITA827Claude Code
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA9,719GitHub Copilot
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA5,516GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143kyesterdayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149ktodayMITA4,680Codex, OpenCode
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA3,093GitHub Copilot
vscode model-prompts.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA2,022GitHub Copilot