Skip to main content

Astron-Tieba-MCP: 基于百度贴吧游客态公开接口的自包含 MCP Server,支持匿名热榜、吧内信息流、全站帖子搜索、帖子详情和作者主页能力。

Project description

百度贴吧公开内容 MCP Server

概述

Astron-tieba-mcp 是一个基于 MCP 协议的百度贴吧工具服务,直接调用贴吧游客态公开接口获取公开内容,不依赖额外的 Astron 后端服务,也不依赖 Playwright 等浏览器运行时。

当前工程形态:

  • 使用 MCP Python SDK
  • 使用单文件 server.py 承载工具定义和 HTTP / protobuf 调用
  • 通过独立 pyproject 打包
  • 支持 uvx 一键启动
  • 通过环境变量配置超时和 User-Agent

当前提供 6 个原子工具:

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

工具列表

1. 获取热榜 get_hot_list

  • 描述:读取贴吧热议榜单。
  • 参数:
    • limit:返回条数,默认 20
    • refresh:是否刷新,默认 False

2. 获取信息流 get_feed_list

  • 描述:读取指定贴吧的移动端公开帖子流。
  • 参数:
    • channel:贴吧名,支持传 PythonPython吧
    • cursor:分页游标,默认空,内部按页码处理
    • limit:返回条数,默认 20
    • refresh:是否刷新,默认 False

3. 搜索内容 search_content

  • 描述:通过贴吧匿名 app 搜索接口读取全站帖子结果。
  • 参数:
    • query:搜索词,必填
    • cursor:分页游标,默认空,内部按页码处理
    • limit:返回条数,默认 20

4. 获取内容详情 get_content_detail

  • 描述:读取贴吧热榜话题详情或普通帖子详情。
  • 参数:
    • content_id:内容 ID,可以是 topic_idtid
    • url:内容完整 URL

5. 获取作者主页 get_author_profile

  • 描述:读取贴吧作者公开主页。
  • 参数:
    • author_id:作者用户名或用户 ID
    • url:作者主页 URL

6. 获取作者作品列表 get_author_content_list

  • 描述:读取贴吧作者公开发帖列表。
  • 参数:
    • author_id:作者用户名或用户 ID
    • url:作者主页 URL
    • cursor:分页游标,默认空,内部按页码处理
    • limit:返回条数,默认 20

环境变量

这个包默认不需要认证信息。

可选环境变量:

export TIEBA_MCP_TIMEOUT_SECONDS="30"
export TIEBA_MCP_USER_AGENT="Mozilla/5.0 ..."

说明:

  • TIEBA_MCP_TIMEOUT_SECONDS 控制公开接口请求超时。
  • TIEBA_MCP_USER_AGENT 用于覆盖默认请求头。

安装与启动

推荐方式:使用 uvx 一键启动

uvx --from astron-tieba-mcp astron-tieba-mcp

如果你还没有安装 uv / uvx,可先执行:

curl -fsSL https://install.astral.sh/uv | bash

使用 pip 安装

pip install astron-tieba-mcp
tieba-mcp

本地源码运行

cd MCP/tieba-mcp
PYTHONPATH=src python3 -m tieba_mcp.server

客户端配置

使用 uvx

{
  "mcpServers": {
    "tieba-mcp": {
      "command": "uvx",
      "args": ["--from", "astron-tieba-mcp", "astron-tieba-mcp"],
      "env": {
        "TIEBA_MCP_TIMEOUT_SECONDS": "30"
      }
    }
  }
}

使用本地源码

{
  "mcpServers": {
    "tieba-mcp": {
      "command": "python3",
      "args": ["-m", "tieba_mcp.server"],
      "env": {
        "PYTHONPATH": "/path/to/MCP/tieba-mcp/src",
        "TIEBA_MCP_TIMEOUT_SECONDS": "30"
      }
    }
  }
}

平台差异说明

  1. 这个 MCP 直接请求贴吧游客态公开接口,不依赖额外的 Astron 后端服务。
  2. 当前仅面向公开内容能力,不包含登录态、私有内容或用户专属数据。
  3. 搜索、帖子详情、作者主页和作者发帖列表都走匿名 app 端公开接口,不需要浏览器抓取。
  4. 返回结果尽量保持结构化 JSON,便于 Cursor、Claude Desktop 等客户端继续消费。
  5. 游客态公开接口可能受网络、地区或平台风控影响,偶发失败时建议稍后重试。

发布说明

cd MCP/tieba-mcp
rm -rf build dist src/*.egg-info
python3 -m build --no-isolation
python3 -m twine check dist/*
python3 -m twine upload dist/*

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_tieba_mcp-0.1.6.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

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

astron_tieba_mcp-0.1.6-py3-none-any.whl (38.2 kB view details)

Uploaded Python 3

File details

Details for the file astron_tieba_mcp-0.1.6.tar.gz.

File metadata

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

File hashes

Hashes for astron_tieba_mcp-0.1.6.tar.gz
Algorithm Hash digest
SHA256 a4dbc4c801e6abe20c50a07b0145bdac0090bbbfb858160c1d4a853f513f4943
MD5 bcd7f65779bda2cbea2e8be2a141de7a
BLAKE2b-256 8b0cb41eeaf1363571781e9b7232f3907ef929a7849bb5cb6da4d0aa71e12a8a

See more details on using hashes here.

File details

Details for the file astron_tieba_mcp-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for astron_tieba_mcp-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7ffe11d57e22fb71617333880d74959bb31791ce8e5e751efbc82e644b12732f
MD5 cf5fe3e231009e0397a025e00d2b4c08
BLAKE2b-256 ec9c94619e10fc18ec1ee5b5a88de86acf4f8457b31b1e0a336334b7a37c0aa8

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