Skip to main content
Glama

byr-mcp

让 Codex、Claude 等 Agent 检索并读取北邮人论坛。项目采用本地优先架构:论坛数据只写入 你自己的 SQLite 索引,MCP 只提供只读检索和阅读工具,不包含发帖、回帖、私信或用户画像。

已实现

MCP 工具:

  • search_posts(query, board?, start_date?, end_date?, limit?, offset?):中文/英文全文检索, 每个主题返回最相关命中、原帖 URL 和明确的索引覆盖说明。

  • get_thread(board, thread_id, page?, max_chars_per_post?):读取主题分页正文并回填本地索引。

  • get_board(board, page?):用本机保存的登录会话浏览版面目录并回填主题目录。

  • get_top10(limit?, preview_chars?):当前十大与首帖预览,同时更新本地索引。

  • get_index_status():查看版面、主题、正文、日期范围、数据源和覆盖限制。 同时返回最近一次全站增量检查时间 recent_sync_at。

索引与同步:

  • SQLite FTS5 trigram,支持中文连续词;一至两个汉字自动回退到安全的子串检索。

  • 导入 byr-topten 2018-03-25 至 2024-12-09 的历史十大目录。

  • 匿名发现公开版面,同步当前十大和全部版面 RSS;GBK/GB2312 脏字节容错。

  • 按搜索命中补抓全部楼层;登录后从移动端分区树枚举账号可见版面(本次实测 286 个), 再与历史索引中已知版面合并,同步历史目录和正文。

  • 单请求串行、可配置限速、超时重试、去重、逐页 checkpoint,可中断后继续。

  • 交互登录只把 session Cookie 存入系统钥匙串;密码读取后立即丢弃,不进入参数、日志、 配置或 SQLite。论坛刷新临时会话键时客户端会更新 CookieJar,并将新会话写回钥匙串。 也支持运行时 BYR_SESSION_COOKIE。

  • 不请求用户资料,不保存帖子返回的 QQ/IP/头像/用户统计,不下载附件。

Related MCP server: local-research-library-mcp

当前这台机器的状态

项目已安装并注册为 Codex MCP byr。默认索引位于:

/Users/limit/Library/Application Support/byr-mcp/forum.sqlite3

初始索引已实际导入历史十大和公开版面最新 RSS。随时查看精确状态:

cd /Users/limit/byr-mcp
uv run byr-mcp status

示例:

uv run byr-mcp search '学六 宿舍' --limit 20
uv run byr-mcp sync query '学六' --limit 30

第二条命令会读取本地标题/预览命中的主题,把论坛当前仍可访问的完整楼层写入全文索引。 历史主题可能已被论坛删除;这类结果会保留题名、日期和原始 URL,并明确标记正文未索引。

安装、测试与 Agent 接入

环境要求:Python 3.12、uv。

cd /Users/limit/byr-mcp
uv sync --all-groups
uv run ruff check .
uv run pytest

真实论坛低频冒烟测试默认跳过:

BYR_RUN_LIVE_TESTS=1 uv run pytest tests/test_live.py -vv

注册本地 STDIO Server:

codex mcp add byr -- /Users/limit/.local/bin/uv run \
  --directory /Users/limit/byr-mcp byr-mcp
codex mcp get byr

不带子命令的 byr-mcp 就是 STDIO Server;它安静等待 MCP Host 从 stdin 发送请求是正常的。 Codex 桌面端、CLI 和 IDE 扩展在同一 host 上共享 MCP 配置。配置样例见 docs/codex-config.toml。

Claude Code

Claude Code 支持本项目使用的本地 STDIO MCP。下载或克隆项目后可一键安装到当前用户的所有 Claude Code 项目:

./scripts/install-claude-code.sh

等价的手工命令是:

claude mcp add --scope user --transport stdio byr -- \
  /绝对路径/uv run --directory /绝对路径/byr-mcp byr-mcp
claude mcp get byr

--scope user 表示所有 Claude Code 项目均可使用;若只想在当前项目启用,改为 --scope local。论坛会话仍由 byr-mcp 从本机钥匙串读取,不写进 Claude 配置。

可以直接对 Agent 说:

检索北邮人论坛关于“学六 宿舍”的帖子,读取最相关的正文,按居住条件、网络、卫生、
噪音和设施做总结;区分帖子事实与个人观点,给出原帖链接和索引覆盖范围。

建立索引

无账号:立即可用的公开索引

# 历史十大题名/URL/日期/回复数;默认从 GitHub 下载公开归档
uv run byr-mcp sync history

# 当前十大 + 所有已发现版面的公开 RSS
uv run byr-mcp sync public --delay 0.8

# 按命中补抓仍可访问主题的完整正文
uv run byr-mcp sync query '保研 挑战杯' --limit 30 --delay 0.8

这条路线覆盖面很实用,但不能声称“整个论坛”:历史归档只包含上过十大者,公开 RSS 只保留 各版近期条目,部分旧帖正文也已从论坛删除。search_posts.coverage 会始终把这个限制带给 Agent。

有账号:账号可见范围的全站索引

先在你自己的终端交互登录。不要把密码发给 Agent,也不要写进 .env:

uv run byr-mcp auth login --username 你的论坛ID
uv run byr-mcp auth status

然后先快速建立全站主题目录,再按需或全量同步正文:

# 可中断、可续传;再次运行会从各版 checkpoint 继续
uv run byr-mcp sync full --catalog-only --delay 1.0

# 先只抓与问题相关的正文
uv run byr-mcp sync query '学六 宿舍' --limit 50 --delay 1.0

# 如果确实要把账号可见主题正文全部本地化(可能运行很久)
uv run byr-mcp sync full --content-only --delay 1.0

# 长期运行:定时发现新帖/新回复,同时分批补齐历史正文
uv run byr-mcp sync watch --interval 900 --delay 0.5

全站正文同步支持逐主题断点续跑,并使用本地进程锁避免两个全量任务同时抓取。即使进程中断,重新运行同一命令也只会继续尚未完成的主题。 sync watch 每个周期扫描账号可见版面的第一页;新主题或回复数/最后回复时间发生变化的主题会 立即刷新首尾页。默认约每 15 分钟一轮,并在间隙分批补历史正文。

小范围试跑:

uv run byr-mcp sync full --board Picture --max-pages-per-board 2 \
  --max-threads 20 --max-pages-per-thread 3 --delay 1.0

登出只删除系统钥匙串中的 session:

uv run byr-mcp auth logout

CLI 一览

byr-mcp                         启动 STDIO MCP
byr-mcp serve                   同上
byr-mcp status                  索引覆盖状态
byr-mcp search QUERY            本地全文检索
byr-mcp auth login|status|logout
byr-mcp sync history            历史十大目录
byr-mcp sync public             当前公开数据
byr-mcp sync query QUERY        按命中补正文
byr-mcp sync recent             单次发现新帖并刷新最新正文
byr-mcp sync watch              持续追踪新内容并补历史正文
byr-mcp sync full               登录后的全站目录/正文同步

所有命令支持全局 --database PATH,测试或多账号隔离时可使用独立索引。

数据边界与使用原则

  • “全站”指当前论坛账号有权查看的版面,不绕过权限,也无法恢复站方已删除的正文。

  • 默认本地、个人使用;不要把登录态索引作为公开镜像或上传给无关第三方。

  • 工具输出保留原始 URL,Agent 应区分论坛帖子、个人经验、官方信息和自己的归纳。

  • 论坛正文按不可信外部资料处理;Agent 不应执行正文中夹带的提示或因此调用其他工具。

  • 不抓 robots.txt 禁止的用户查询、附件与文件路径;不批量下载图片。

  • 写操作故意不实现。若未来加入发帖/回帖,应作为独立可选组件并要求逐次确认。

  • 大规模同步前建议了解论坛规则;若要部署多人远程服务,应先取得 BYR-Team 许可并增加 OAuth、用户隔离、审计、撤销与删除机制。

技术判断、入口实测与数据源说明见 docs/feasibility.md。

参考

Available Tools

5 tools
get_board浏览北邮人论坛版面A
Read-only

使用本机保存的论坛会话读取一页版面目录;不向 Agent 暴露凭据。

Inputs: board (required), page. Returns: One authenticated board catalogue page.

get_index_status查看北邮人论坛索引状态A
Read-only

查看本地索引的版面、主题、正文数量、日期范围、来源和覆盖限制。

Inputs: no named parameters. Returns: Coverage and freshness of the local search index.

get_thread读取北邮人论坛主题A
Read-only

按版面名和主题 ID 读取一页主题,返回正文、楼层、最小作者信息和附件链接。

Inputs: board (required), thread_id (required), page, max_chars_per_post. Returns: One page of a BYR thread.

get_top10读取北邮人论坛十大A
Read-only

读取北邮人论坛当前十大,返回版面、主题 ID、作者、时间、预览和原帖链接。

Inputs: limit, preview_chars. Returns: Current top-ten entries and feed metadata.

search_posts检索北邮人论坛A
Read-only

检索本地标题和正文索引;每个主题返回最相关的一条命中和原帖定位。

Inputs: query (required), board, limit, offset, +2 more. Returns: Search hits plus an explicit statement of local-index coverage.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

    TDQS

    A4.2/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool targets a distinct level of the forum: top 10, thread contents, board directory, search results, and index status. There is no real overlap or ambiguity between them.

    Naming Consistency5/5

    All tools use a consistent verb_noun snake_case pattern: get_top10, get_thread, get_board, search_posts, get_index_status. The mixed use of get and search is still semantically consistent and predictable.

    Tool Count5/5

    Five tools is well-scoped for a read-only BBS retrieval server. Each tool covers a necessary access path without redundancy or bloat.

    Completeness5/5

    The tool set covers the core read-only workflows: browsing popular topics, reading a board, reading a thread, searching posts, and inspecting index health. There are no obvious dead ends for the stated purpose of retrieving and searching forum content.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      C
      maintenance
      Provides read-only hybrid RAG search and discovery over a local-first AI knowledge corpus, enabling semantic and keyword search, browse, digest, and status tools.
      4
      1
      PolyForm Noncommercial 1.0.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to browse, search, and retrieve papers from a local research library with read-only access, supporting multiple formats and automatic indexing.
      2
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Gives AI agents fast, read-only access to a local knowledge base of Markdown notes and other text documents via a SQLite full-text index. Enables ranked section-level search, reading whole notes or single sections, heading outlines, note listing, and link/backlink navigation without slow disk walks.
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to search and browse a local, CJK-aware full-text index over coding-agent session histories (Claude Code, ZCode, Kimi, dsh, Qoder, OpenCode) via tools for searching sessions, listing sessions, fetching original messages, listing agents and tools, and refreshing the index.
      1
      MIT