litMcp
# litMcp
在 MCP 客户端里检索 OpenAlex、arXiv、PubMed 和知网等来源,将论文存入本地文献库,再筛选、下载 PDF 或导出 BibTeX。
## 快速开始
1. 安装 [uv](https://docs.astral.sh/uv/getting-started/installation/),在项目根目录运行 `uv sync --locked`。需要知网时,改用 `uv sync --locked --extra cnki`,并安装 Chrome 或 Edge。
2. 在 ZCode 中使用时,先运行 `uv run --no-sync litMcp --print-config zcode`,将输出的服务条目以 `litMcp` 为键合并到 `~/.zcode/cli/config.json` 的 `mcp.servers`。其他客户端见[配置指南](./docs/MCP_CLIENT_SETUP_zh.md)。
3. 新建会话,输入「调用 `litMcp` 的 `library_stats`」。返回统计或 `Library is empty` 即连接成功。这一步无需 API 密钥。
要检索 OpenAlex,首次配置时可将 [.env.example](./.env.example) 复制为 `.env`,填入 `OPENALEX_API_KEY` 后重连。用户级配置推荐放在 `~/.config/litMcp/.env`,该文件不存在时,服务会回退到旧路径 `~/.config/openalex-mcp/.env`。启动遇到问题时,运行 `uv run --no-sync litMcp --doctor`。
## 工具索引
| 用途 | 工具 |
|---|---|
| 按关键词、研究问题或 DOI 找论文 | `search_keyword`、`search_semantic`、`search_ids` |
| 找预印本和近期论文、中国期刊或知网文献 | `search_multi`、`search_chinese`、`search_cnki` |
| 查作者、期刊或机构等实体的 ID | `autocomplete` |
| 为论点找出处、阅读已入库论文、补 Elsevier 摘要 | `find_literature`、`summarize_paper`、`fetch_elsevier_abstracts` |
| 查库与统计、导出 BibTeX、获取综述写作提示词 | `library_query`、`library_stats`、`library_export`、`literature_review_prompt` |
| 下载 PDF、续办知网检索或下载 | `download_pdf`、`cnki_job` |
| 分析引文、查看引用关系、生成交互图 | `graph_analyze`、`graph_neighbors`、`graph_visualize` |
| 删除指定记录、释放数据库连接 | `library_delete`、`library_close` |
关键词和语义检索默认查 2021 年之后的论文。要包含更早文献,设 `publication_year=""`。知网弹出验证时,在原窗口完成验证后告诉客户端「继续」。
`download_pdf` 先试免费来源。全部失败且 OpenAlex 提供该文 PDF 时,如已配置密钥,工具会尝试 Content API,按每篇 0.01 美元估算费用。检索及阅读工具仅在显式设置 `use_openalex_content_api=true` 时使用该付费回退。
文献库默认位于 `~/.AI-CACHE/openalex/library.db`。同目录的 `pdfs/`、`collections/` 和 `graphs/` 分别存放 PDF、BibTeX 和引文图。[工具原理](./docs/TOOL_INTERNALS_zh.md)
TDQS
Scored across 21 tools
Six search variants coexist (search_keyword, search_semantic, search_ids, search_chinese, search_cnki, search_multi), but each description carries explicit TRIGGER conditions and cross-references telling the agent when to prefer another tool, so routing is learnable. Library tools (library_query vs library_stats vs find_literature vs summarize_paper) are also cleanly separated by task stage; the only residual ambiguity is choosing among the search family under vague requests.
All names are snake_case and grouped by domain prefixes: search_*, library_*, graph_*. Deviations are minor: cnki_job is noun-first, autocomplete has no object, and standalone verbs (summarize_paper, download_pdf, find_literature) break the prefix pattern but remain readable and predictable.
21 tools is on the heavy side, but the server covers a genuinely broad pipeline (multi-source search, SQL library, PDF acquisition, summarization, citation graphs, export), and each tool maps to a distinct step. Only library_close (pure maintenance) and literature_review_prompt feel like marginal additions.
Coverage is unusually thorough: six search backends, SQL screening, BibTeX export, PDF download, abstract backfill, evidence finding, bounded summarization, and a full three-tool citation-graph suite. The main gap is lifecycle management of library records — delete exists but no update/annotate/tag operation, and no non-BibTeX citation styles.