shuge-mcp-server
# shuge-mcp-server
[书格](https://new.shuge.org)(shuge.org)MCP Server —— 让 AI 助手直接检索和浏览中国古籍数字图书馆。
书格是一个自由开放的在线古籍图书馆,收录 700+ 部高清古籍资源(PDF),涵盖经、史、子、集四部分类。本项目通过 [Model Context Protocol](https://modelcontextprotocol.io) 将书格的公开 API 封装为结构化工具,供 Claude Code、Claude Desktop 等 MCP 客户端调用。
## 功能
提供 7 个工具:
| 工具 | 功能 |
|------|------|
| `shuge_search` | 按关键词搜索古籍 |
| `shuge_get_book` | 获取单本古籍详情(HTML 自动清洗为纯文本) |
| `shuge_list_categories` | 列出所有分类(四部分类、朝代等) |
| `shuge_browse_category` | 按分类浏览古籍列表 |
| `shuge_get_tags` | 获取标签列表 |
| `shuge_get_download_links` | 获取古籍 PDF 下载链接 |
| `shuge_latest` | 获取最新发布的古籍 |
### 特性
- **HTML → 纯文本**:自动清洗 WordPress 富文本,节省 token
- **分页支持**:所有列表工具支持 `page` + `per_page` 参数
- **分类缓存**:分类数据内存缓存 30 分钟
- **内容截断**:超长内容优雅截断至 25000 字符
- **无需认证**:书格 API 完全公开
## 安装
```bash
git clone https://github.com/Mocooa/shuge-mcp-server.git
cd shuge-mcp-server
npm install
npm run build
```
### 注册到 Claude Code
```bash
claude mcp add shuge -- node /path/to/shuge-mcp-server/dist/index.js
```
### 注册到 Claude Desktop
编辑 `~/Library/Application Support/Claude/claude_desktop_config.json`:
```json
{
"mcpServers": {
"shuge": {
"command": "node",
"args": ["/path/to/shuge-mcp-server/dist/index.js"]
}
}
}
```
## 使用示例
注册后重启客户端,即可用自然语言调用:
- "搜索书格上的山海经"
- "看看书格最近更新了什么古籍"
- "列出书格的所有分类"
- "帮我找到《本草纲目》的下载链接"
## 技术栈
- TypeScript + Node.js
- [`@modelcontextprotocol/sdk`](https://github.com/modelcontextprotocol/typescript-sdk) — MCP 协议 SDK
- stdio 传输(标准 MCP 接入方式)
- 原生 `fetch`(Node.js 内置)
## 数据来源
所有数据来自 [书格](https://new.shuge.org) 的公开 WordPress REST API。本项目仅作为 API 的结构化封装,不存储任何古籍内容。
## License
MIT
TDQS
Scored across 7 tools
Most tools have clearly distinct purposes: detail retrieval (get_book), discovery by keyword (search), by category (browse_category), by recency (latest), plus two taxonomy listings and a download-link fetcher. The only mild overlap is between list_categories and get_tags, since both surface taxonomy-like ID lists, but the descriptions (四部分类/朝代 vs. 主题标签) make the distinction workable.
All names share the shuge_ namespace prefix and 5 of 7 follow a verb_noun pattern (get_book, list_categories, browse_category, get_tags, get_download_links). shuge_latest is a bare noun/adjective and shuge_search is a bare verb with no object, which are minor deviations from the otherwise predictable scheme.
Seven tools is a well-scoped surface for a digital archive: one detail fetch, three list/browse entry points, two taxonomy helpers, and one asset-link tool. No tool looks redundant or filler, and nothing essential seems crammed in.
The lifecycle is mostly covered (discover via search/category/latest, inspect via get_book, download via get_download_links), but get_tags is a dead end: tags are listed for '关联浏览' yet there is no browse-by-tag tool analogous to browse_category. Search may partially compensate, but an agent following a tag cannot proceed.