Skip to main content

知乎公开内容 MCP Server

概述

Astron-zhihu-mcp 是一个基于 MCP 协议的知乎工具服务,直接调用知乎游客态公开接口获取公开内容,无需额外部署后端服务。

当前提供 5 个原子工具:

  • get_hot_list
  • get_feed_list
  • search_content
  • get_content_detail
  • get_author_profile

工具列表

1. 获取热榜 get_hot_list

  • 参数:limit、refresh

2. 获取信息流 get_feed_list

  • 参数:channel、cursor、limit、refresh

3. 搜索内容 search_content

  • 参数:query、cursor、limit、real_only、allow_fallback

4. 获取内容详情 get_content_detail

  • 参数:content_id、url

5. 获取作者主页 get_author_profile

  • 参数:author_id、url

环境变量

export ZHIHU_MCP_TIMEOUT_SECONDS="30"
export ZHIHU_MCP_USER_AGENT="Mozilla/5.0 ..."
export ZHIHU_MCP_COOKIE="z_c0=...; d_c0=...; q_c1=..."
export ZHIHU_MCP_PREWARM_HOME="1"
export ZHIHU_MCP_CACHE_PATH="/tmp/zhihu_mcp_cache.json"
export ZHIHU_MCP_CACHE_TTL_SECONDS="1800"
export ZHIHU_MCP_CACHE_MAX_ITEMS="800"
export ZHIHU_MCP_FALLBACK_FEED_SCAN_PAGES="4"
export ZHIHU_MCP_FALLBACK_FEED_PAGE_SIZE="20"

说明:

  • ZHIHU_MCP_COOKIE:可选,知乎登录态 Cookie 原文(key=value; key2=value2),用于降低 401/403 风控概率。
  • ZHIHU_MCP_PREWARM_HOME:是否启用首页预热(默认 1)。预热后再请求公开 API,降低风控触发概率。
  • ZHIHU_MCP_CACHE_PATH:本地轻量缓存文件路径。
  • ZHIHU_MCP_CACHE_TTL_SECONDS:缓存生存时间(秒)。
  • ZHIHU_MCP_CACHE_MAX_ITEMS:缓存内容项上限。
  • ZHIHU_MCP_FALLBACK_FEED_SCAN_PAGES:游客态 fallback 时扫描推荐流页数(1-12)。
  • ZHIHU_MCP_FALLBACK_FEED_PAGE_SIZE:游客态 fallback 每页抓取条数(5-50)。

安装与启动

使用 uvx

uvx --from astron-zhihu-mcp astron-zhihu-mcp

使用 pip 安装

pip install astron-zhihu-mcp
zhihu-mcp

本地源码运行

cd MCP/zhihu-mcp
PYTHONPATH=src python3 -m zhihu_mcp.server

客户端配置

{
  "mcpServers": {
    "zhihu-mcp": {
      "command": "python3",
      "args": ["-m", "zhihu_mcp.server"],
      "env": {
        "PYTHONPATH": "/path/to/MCP/zhihu-mcp/src",
        "ZHIHU_MCP_TIMEOUT_SECONDS": "30",
        "ZHIHU_MCP_COOKIE": "z_c0=...; d_c0=..."
      }
    }
  }
}

平台差异说明

  1. 默认策略为 JSON API 优先,失败后回退 HTML 解析。
  2. search_content 默认只返回真实搜索内容;搜不到时返回结构化空列表。
  3. allow_fallback 当前仅保留兼容参数位,默认实现不再用 suggest、热榜/推荐流、缓存扫描等降级来源顶替搜索结果。
  4. 作者内容列表回退链支持 members/{id}/pins(raw.source=member_pins_api)与热榜/推荐流作者聚合。
  5. 内置轻量本地缓存(单文件 JSON),在风控场景下可用于回退返回历史公开数据。
  6. 内容详情与作者内容列表在强风控下可能返回最小结构(如 fallback_minimal / empty_fallback),用于保证工具可调用与响应结构稳定。
  7. 仅面向公开内容能力,不包含登录态与私有数据。

License

Apache License 2.0. See LICENSE.

Metadata

Release files for astron-zhihu-mcp 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for astron-zhihu-mcp 0.1.5
File Size Uploaded
astron_zhihu_mcp-0.1.5.tar.gz 22.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for astron-zhihu-mcp 0.1.5
File Interpreter ABI Platform
astron_zhihu_mcp-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 46.2 kB

Release files / astron_zhihu_mcp-0.1.5.tar.gz

Download URL astron_zhihu_mcp-0.1.5.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
da9f43c00f404bbcd05fe4a50d57cbcc892079a437bc0cd9ad490d841e67ae83
BLAKE2b-256 checksum
How to use checksums
132cc3e771c1c4eda9d1aa72ea30cee28b220e1dc259c6d0e23990d1274d3b6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0rc1

Release files / astron_zhihu_mcp-0.1.5-py3-none-any.whl

Download URL astron_zhihu_mcp-0.1.5-py3-none-any.whl
Size 23.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
201001508345fddccf34647940555feef801f992cace87f07bd8bd964f53311b
BLAKE2b-256 checksum
How to use checksums
da0d21eec6ab455f375c456986f7bcd1cd8dcd82a0a362f3ac1ac5081728b9a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0rc1

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page