Skip to main content

Astron-Zhihu-MCP: 基于知乎游客态公开接口的自包含 MCP Server,支持 MCP 协议和 uvx 一键启动。

Project description

知乎公开内容 MCP Server

概述

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

当前提供 6 个原子工具:

  • get_hot_list
  • get_feed_list
  • search_content
  • get_content_detail
  • get_author_profile
  • get_author_content_list

工具列表

1. 获取热榜 get_hot_list

  • 参数:limitrefresh

2. 获取信息流 get_feed_list

  • 参数:channelcursorlimitrefresh

3. 搜索内容 search_content

  • 参数:querycursorlimit

4. 获取内容详情 get_content_detail

  • 参数:content_idurl

5. 获取作者主页 get_author_profile

  • 参数:author_idurl

6. 获取作者内容列表 get_author_content_list

  • 参数:author_idurlcursorlimit

环境变量

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/suggestraw.source=suggest)与热榜/推荐流,尽量优先返回与查询语义相关的公开数据。
  3. 作者内容列表回退链支持 members/{id}/pinsraw.source=member_pins_api)与热榜/推荐流作者聚合。
  4. 内置轻量本地缓存(单文件 JSON),在风控场景下可用于回退返回历史公开数据。
  5. 内容详情与作者内容列表在强风控下可能返回最小结构(如 fallback_minimal / empty_fallback),用于保证工具可调用与响应结构稳定。
  6. 仅面向公开内容能力,不包含登录态与私有数据。

License

Apache License 2.0. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

astron_zhihu_mcp-0.1.2.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

astron_zhihu_mcp-0.1.2-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file astron_zhihu_mcp-0.1.2.tar.gz.

File metadata

  • Download URL: astron_zhihu_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0rc1

File hashes

Hashes for astron_zhihu_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 df67444a4483fb6a43fbf0e002985d72016ed593176eccc6de846ce985083ebc
MD5 447c9cd74441f42be5a2125a8f372401
BLAKE2b-256 2dc021a40afef17feba9099b527c4fef54791b7242f819b1da2ad776bb84c0c8

See more details on using hashes here.

File details

Details for the file astron_zhihu_mcp-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for astron_zhihu_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b82a8d745dc77e859db21316189ad21aeb0515f2e4c0bac841185c6589aac600
MD5 07798876b08e8bc4bc561a52a54b5219
BLAKE2b-256 ec7657c8a809e53779624c145aae9196391b9c42a740f727c99d3f2528551a89

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page