BYR Docs 搜索

搜索 BYR Docs 中教材、资料与试题的 API / MCP。

让 AI 一键安装 MCP

把下面这句话发给 Agent:

阅读 https://search.byrdocs.org/llms.txt 安装 BYR Docs 搜索 MCP

试一试

示例:
curl 命令

                    
结果将显示在这里

HTTP API

仅支持 POST,请求体为 JSON。跨域开放(Access-Control-Allow-Origin: *)。

请求参数

字段类型说明
keywordstring?关键词。普通词做分词检索;ISBN / 32 位 MD5 做精确匹配;留空则不过滤。
typeenum?book / doc / test / all,默认 all
jmespathstring?JMESPath 表达式,作用于关键词结果数组做结构化查询 / 投影。
limitnumber?返回条数上限,默认 20,最大 100。
shortenboolean?true 时把结果中的链接转换为 go.byrdocs.org 短链后返回(见短链接)。需带 Authorization: Bearer <token>。默认 false

示例

curl -X POST https://search.byrdocs.org/api/search \
  -H 'content-type: application/json' \
  -d '{"keyword":"高等数学","type":"book","limit":5}'

响应

{
  "total": 42,
  "results": [
    {
      "type": "book",
      "id": "<md5>",
      "url": "https://byrdocs.org/files/<md5>.pdf",
      "data": {
        "title": "高等数学",
        "authors": ["同济大学数学系"],
        "isbn": ["..."],
        "filetype": "pdf"
      }
    }
  ]
}

叠加 JMESPath 时,先执行关键词 / 类型过滤,再对结果数组求值;total 为求值后数组的长度,results 为其前 limit 项。非法表达式返回 400

短链接

shorten: true 且请求头带 Authorization: Bearer <token>tokengo.byrdocs.org 短链服务的 token),则在搜索、JMESPath、limit 全部完成后,把每个结果的 url(及 test 的 data.wiki.url)并发转换为短链后返回,不返回原始链接。相同链接自动去重;转换前的链接已带 filename / f 统计参数,短链跳转仍计入下载统计;缺少 token 或个别链接转换失败时,该条回退为原始链接,整体仍返回 200

curl -X POST https://search.byrdocs.org/api/search \
  -H 'content-type: application/json' \
  -H 'authorization: Bearer <token>' \
  -d '{"keyword":"高等数学","type":"book","shorten":true}'

JMESPath 查询

JMESPath 是一种 JSON 查询语言,作用于关键词 / 类型过滤后的结果数组——数组每一项形如 { type, id, url, data }。可用它做过滤、字段投影、排序、计数等。执行顺序:keyword / type 过滤 → JMESPath 求值 → limit 截断,total 为求值后数组长度。

语法约定

写法含义
data.title用点号访问嵌套字段
'book'字符串字面量用单引号
`2020`数字 / 布尔 / null 等用反引号包裹
[?…]过滤:对数组每一项求布尔表达式,保留为真的项
[]展开数组,配合 .field 做投影
{a: x, b: y}multiselect:把每项重组为新对象
@当前元素(整个数组或迭代项)
|管道:把左侧结果作为右侧表达式的新输入

示例

常用函数:lengthcontainsstarts_withends_withsort_bymax_by / min_byreversekeysto_number。完整规范见 JMESPath Specification

MCP

无状态 Streamable HTTP,端点 https://search.byrdocs.org/mcp,公开免认证。

让 AI 自动安装(推荐)

把下面这句话发给你的 agent:

阅读 https://search.byrdocs.org/llms.txt 安装 BYR Docs 搜索 MCP

手动安装

本服务公开免认证,配置里无需任何 API key。端点均为 https://search.byrdocs.org/mcp;服务名建议用 byrdocs-search。点开你使用的客户端(代码块点击即可复制):

Claude Code
claude mcp add --transport http byrdocs-search https://search.byrdocs.org/mcp
Codex CLI

远程(写入 ~/.codex/config.toml

[mcp_servers.byrdocs-search]
url = "https://search.byrdocs.org/mcp"

或用 CLI(stdio 桥接)

codex mcp add byrdocs-search -- npx -y mcp-remote https://search.byrdocs.org/mcp
Gemini CLI

写入 ~/.gemini/settings.json

{
  "mcpServers": {
    "byrdocs-search": {
      "httpUrl": "https://search.byrdocs.org/mcp",
      "headers": { "Accept": "application/json, text/event-stream" }
    }
  }
}
Cursor

写入 ~/.cursor/mcp.json(或项目内 .cursor/mcp.json

{
  "mcpServers": {
    "byrdocs-search": { "url": "https://search.byrdocs.org/mcp" }
  }
}
VS Code(GitHub Copilot)

写入 .vscode/mcp.json

{
  "servers": {
    "byrdocs-search": { "type": "http", "url": "https://search.byrdocs.org/mcp" }
  }
}
Windsurf
{
  "mcpServers": {
    "byrdocs-search": { "serverUrl": "https://search.byrdocs.org/mcp" }
  }
}
Cline
{
  "mcpServers": {
    "byrdocs-search": { "url": "https://search.byrdocs.org/mcp" }
  }
}
Roo Code
{
  "mcpServers": {
    "byrdocs-search": {
      "type": "streamable-http",
      "url": "https://search.byrdocs.org/mcp"
    }
  }
}
JetBrains AI Assistant

Settings → Tools → AI Assistant → MCP,选 HTTP 标签后粘贴

{
  "mcpServers": {
    "byrdocs-search": { "url": "https://search.byrdocs.org/mcp" }
  }
}
Zed

仅支持 stdio,用 mcp-remote 桥接,写入 Zed settings.json

{
  "context_servers": {
    "byrdocs-search": {
      "source": "custom",
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://search.byrdocs.org/mcp"]
    }
  }
}
Claude Desktop

仅支持 stdio,用 mcp-remote 桥接,编辑 claude_desktop_config.json

{
  "mcpServers": {
    "byrdocs-search": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://search.byrdocs.org/mcp"]
    }
  }
}

未列出的客户端:支持 Streamable HTTP 的直接填端点 URL(字段名各家不同,常见为 url / httpUrl / serverUrl);仅支持 stdio 的一律用 npx -y mcp-remote <端点> 桥接。

装好后试试

连接成功后,可以让 agent 调用 search_files 试几个例子:

工具 search_files

参数与 HTTP API 同构:keyword / type / jmespath / limit / shorten,返回 JSON 文本。工具描述中已内嵌 item 结构与 JMESPath 用法,便于模型直接构造查询。jmespath 写法见上方 JMESPath 查询

使用 shorten 需在连接时通过 HTTP 头 Authorization: Bearer <token> 提供 go.byrdocs.org 短链服务 token,语义同上方短链接

npx mcp-remote https://search.byrdocs.org/mcp --header "Authorization: Bearer <token>"

数据结构

每个搜索结果是一个 item,字段以 TypeScript 类型给出如下——datatype 分为 book / doc / test 三种,点击标签切换查看:

{
  type: "book"
  id: string            // 文件 MD5
  url: string            // 下载链接(已含统计参数)
  data: {
    title: string
    authors: string[]
    translators?: string[]
    edition?: string
    publisher?: string
    publish_year?: string
    isbn: string[]
    filetype: "pdf"
    filesize?: number       // 字节
  }
}