ArXiv研究情报——MCP服务器
ArXiv上的无矢量RAG——BM25+RRF+上下文压缩——作为Claude的MCP服务器。
  
______________________________________________________________________
这是什么
一个MCP服务器,为Claude提供实时工具来搜索ArXiv、下载和索引完整论文,并从您的个人论文库中回答研究问题——所有这些都不需要嵌入式、GPU或模型下载。
______________________________________________________________________
无矢量RAG——为什么以及如何
大多数RAG管道将每个文本块嵌入一个神经模型,存储向量,并通过余弦相似度进行检索。这是可行的,但有实际成本:GPU或CPU推理速度慢,约90MB的模型下载,嵌入漂移,以及对精确技术术语的处理不佳,如 LoRA, RLHF, KV-cache.
v2将嵌入步骤完全替换为Okapi BM25 --与为Elasticsearch和学术搜索引擎提供动力的算法相同。零模型下载,即时索引,完美处理精确术语。
完整的管道
Your question
│
▼
Query expansion ── generates keyword variants to maximize BM25 recall
│
▼
Multi-query BM25 ── each variant scored against all chunks independently
│
▼
RRF fusion ── Reciprocal Rank Fusion merges ranked lists
score = Σ 1/(60 + rank) — no score normalization needed
│
▼
Contextual compression ── sentence-level BM25 extracts only the 2–3
sentences per chunk that answer the question
│
▼
Cited context returned to Claudev1与v2比较
| v1(向量RAG) | v2(无向量RAG | |
|---|---|---|
| 索引 | 用神经模型对每个块进行编码 | 纯文本,即时 |
| 检索 | 嵌入上的余弦相似性 | Okapi BM25 |
| 多查询 | 仅单查询 | 3种变体+RRF融合 |
| 压缩 | 交叉编码器重排序器 | 语句级BM25 |
| 需要GPU | 是(或CPU速度慢) | 否 |
| 模型下载 | 首次运行时约90MB | 无 |
| 精确术语(LoRA、RLHF) | 有时会错过 | 总是能抓住 |
______________________________________________________________________
没有克劳德·普罗?完全从您的终端使用它
Claude Pro仅适用于Claude Desktop聊天界面。完整的管道——搜索、获取、索引、RAG查询——在本地运行 test_local.py 和 test_mcp.py.
设置
git clone https://github.com/RatnamOjha/arvix-mcp-server
cd arvix-mcp-server
python3 -m venv .venv && source .venv/bin/activate
pip install -e .Anaconda用户: 始终使用完整的venv路径运行以避免冲突: /path/to/arvix-mcp-server/.venv/bin/python3 test_local.py ...______________________________________________________________________
查找您的纸张ID
ID是任何ArXiv URL末尾的数字:
https://arxiv.org/abs/2301.07041
^^^^^^^^^^^^^ this is your paper ID______________________________________________________________________
所有命令
每面旗帜都有一个简短的别名。用你喜欢的任何一种。
# Search ArXiv live
python3 test_local.py -s
# Fetch and index a paper (direct CDN download — no rate limiting)
python3 test_local.py -f -i 2301.07041
# Query your whole library — full output
python3 test_local.py -q -F
# Query one specific paper only
python3 test_local.py -q -p 2301.07041 -Q "what are the limitations?" -F
# Build a multi-paper library and query across all of them
python3 test_local.py -f -i 2301.07041
python3 test_local.py -f -i 2305.10601
python3 test_local.py -f -i 2005.11401
python3 test_local.py -q -Q "how do these papers approach retrieval?" -F
# See everything indexed
python3 test_local.py -l
# Run edge case tests
python3 test_local.py -e
# Run everything at once
python3 test_local.py -a| 短 | 长 | 描述 |
|---|---|---|
-s | --search | 搜索ArXiv |
-f | --fetch | 获取并索引一篇论文 |
-q | --query | RAG查询 |
-l | --library | 显示库 |
-e | --edge | 边缘案例测试 |
-a | --all | 运行一切 |
-i ID | --arxiv-id ID | 要获取的纸张ID |
-p ID | --paper ID | 将查询限制为一篇论文 |
-Q "..." | --question "..." | 要问的问题 |
-F | --full | 未截断的完整输出 |
-n | --no-generate | 跳过LLM答案生成 |
一切都在坚持 ~/.arxiv-mcp/ 两次运行之间——取一次,永远查询。
______________________________________________________________________
启用LLM答案生成(免费)
默认情况下,管道显示检索上下文。要获得完整引用的法学硕士答案,请设置 自由 Groq钥匙——不需要信用卡。
# 1. Get a free key at https://console.groq.com (takes 60 seconds)
# 2. Set it
export GROQ_API_KEY=gsk_your_key_here
# 3. Run — you now get retrieval + generated answer
python3 test_local.py -q -p 2005.11401 -Q "what is the main contribution?" -FGroq的免费套餐:每天14400个请求 llama-3.1-8b-instant.人类学(ANTHROPIC_API_KEY)如果你愿意,它可以作为后备方案。
______________________________________________________________________
直接测试MCP协议(无需Claude)
test_mcp.py 将服务器作为子进程生成,并向其发送真正的JSON-RPC 消息——与Claude Desktop发送的消息完全相同。如果这有效, Claude Desktop集成也将起作用。
# Test all tools
python3 test_mcp.py
# Test specific tools
python3 test_mcp.py --tool search_papers
python3 test_mcp.py --tool fetch_paper --arxiv-id 2005.11401
python3 test_mcp.py --tool query_library --question "what is BM25?" --paper 2005.11401
python3 test_mcp.py --tool list_library______________________________________________________________________
使用Claude Pro——MCP集成
配置Claude桌面
编辑 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"arxiv-research": {
"command": "/absolute/path/to/.venv/bin/python",
"args": ["-m", "src.server"],
"cwd": "/absolute/path/to/arvix-mcp-server"
}
}
}使用 完全绝对路径 给你的 .venv Python——避免与Anaconda或系统Python冲突。重新启动克劳德桌面(Cmd+Q,然后重新打开)。这🔨 锤子图标将显示6个新工具。
示例提示
Search for recent papers on speculative decoding
Fetch paper 2305.10601 and add it to my library
What does my library say about KV cache optimization?
What does paper 2507.07171 say about the evaluation? (uses arxiv_id_filter automatically)
Summarize paper 2305.10601
Show me my reading list______________________________________________________________________
MCP工具
| 工具 | 参数 | 描述 |
|---|---|---|
search_papers | query, max_results?, category? | 实时ArXiv搜索 |
fetch_paper | arxiv_id, add_to_reading_list? | 下载+BM25索引 |
query_library | question, top_k?, use_expansion?, arxiv_id_filter? | 无矢量RAG查询 |
summarize_paper | arxiv_id | 结构化论文摘要 |
list_library | -- | 所有索引论文 |
get_reading_list | -- | 已保存的阅读列表 |
这 arxiv_id_filter 参数打开 query_library 将搜索限制在一篇特定的论文上——当你在问题中提到论文ID时,克劳德会自动使用它。
______________________________________________________________________
已知的边缘案例及其处理方式
ArXiv API速率限制(HTTP 429)
API允许约1个请求/3秒。如果你快速运行多个搜索,你会得到429。
修复: PDF下载无速率限制——我们直接访问 https://arxiv.org/pdf/{id} 它是一个没有限制的CDN。元数据(标题、作者)是单独提取的,如果API不可用,则会正常回退。即使有占位符元数据,该论文仍然可以完全索引和查询。
LaTeX PDF中的乱码文本
物理和数学论文使用LaTeX渲染的字体,pdfplumber会误读,产生类似的输出 b e a h A b r ξ o a s α v t.
修复: 我们使用 pymupdf (fitz)作为主要提取器——它从字形位置重建读取顺序,并正确处理多列布局。后处理步骤过滤平均令牌长度\<1.8个字符的行(加密LaTeX字体的统计签名)。如果未安装pymupdf,pdfplumber仍将作为后备方案。
Anaconda覆盖了venv Python
如果你看到 (base) 和 (.venv) 在你的提示中,conda正在获胜。
修复:
conda deactivate
source .venv/bin/activate
which python3 # must show .venv pathVS代码中的黄色波浪
VS Code使用了错误的解释器。
修复: Ctrl+Shift+P → “Python:选择解释器”→ 选择 .venv.
测试脚本使用了错误的python
始终使用完整的venv路径:
/path/to/project/.venv/bin/python3 test_local.py --fetch --arxiv-id 2005.11401______________________________________________________________________
项目结构
arxiv-mcp-server/
├── src/
│ ├── server.py # MCP server — registers all 6 tools
│ ├── arxiv_client.py # ArXiv search + direct PDF download/extraction
│ ├── vectorless_rag.py # BM25 + RRF + contextual compression
│ └── reading_list.py # JSON-backed reading list
├── web/
│ └── index.html # Live landing page (GitHub Pages)
├── tests/
│ └── test_core.py # pytest suite (runs on every push via CI)
├── test_local.py # Standalone demo — no Claude needed
└── pyproject.toml______________________________________________________________________
技术栈
| 组件 | 库 | 角色 |
|---|---|---|
| MCP协议 | mcp | stdio服务器框架 |
| ArXiv | arxiv | 论文搜索+元数据 |
| PDF下载 | httpx | 直接CDN下载,无速率限制 |
| PDF提取 | pymupdf (主要) | 处理LaTeX,多列 |
| PDF提取 | pdfplumber (回退) | 一般提取 |
| 检索 | BM25(内置) | 无矢量关键字搜索 |
| 融合 | RRF(内置) | 多查询结果合并 |
| 压缩 | 句子BM25(内置) | 提取相关句子 |
| 持久性 | JSON | BM25索引+读取列表 |
零ML依赖性用于检索。 没有PyTorch,没有句子转换器,没有RAG管道的模型下载。
______________________________________________________________________
发展
pip install -e ".[dev]"
pytest tests/ -v --asyncio-mode=auto
ruff check src/路线图
- \[\]适用于大型库的Qdrant/ChromaDB后端选项
- \[\]LLM驱动的查询扩展(取代基于规则的回退)
- \[\]共享纸质库的多用户支持
- \[\]语义学者+PubMed作为额外来源
- \[\]引文图遍历-获取引用或被论文引用的论文
许可证
麻省理工学院-由 拉特南·奥哈
