arxiv-mcp
Provides a clean interface for AI agents to search arXiv papers, fetch metadata, read full text, and download PDFs/source, with rate-limiting, on-disk caching, and session pinning to avoid duplicate fetches.
README
arxiv-mcp
An efficient, well-behaved Model Context Protocol server for arXiv. It gives AI agents a clean interface to search papers, fetch metadata, read full text, and download PDFs/source — with rate-limiting, on-disk caching, and session pinning built in so the same paper is never fetched twice.
Built on the official MCP Python SDK (2.x). Runs over stdio.
Contents
- Why
- Install
- Run
- Wire into an agent
- Quickstart: a research flow
- Tools reference
- Sessions & caching
- Configuration
- Architecture
- Development & testing
- Troubleshooting
- License
Why
- Respects arXiv. One request every 3 s over a single connection (the
Terms-of-Use floor), with 503
Retry-Afterback-off and a descriptiveUser-Agent. A single global limiter gates every outbound call, so no combination of tools can exceed the rate. - Fast for repeat queries. Three-tier cache (metadata / extracted text / raw files) keyed by normalized id + version. Concurrent identical fetches collapse to one request (single-flight dedup).
- Bounded disk. LRU eviction by paper count and disk size — whichever ceiling trips first. Papers pinned to an open session are exempt.
- Context-safe reads.
read_paperis paginated so a 40-page paper never overflows the model's context. Extraction prefers clean arXiv HTML / LaTeX source and falls back to the PDF for older or PDF-only papers. - Any id form. New (
2401.12345v2), old (hep-th/9901001),arXiv:prefix,arxiv.org/abs/...URLs, and10.48550/arXiv...DOIs all normalize.
Install
Requires Python ≥ 3.11 and uv.
git clone https://github.com/Himasnhu-AT/arxiv-mcp.git
cd arxiv-mcp
uv venv --python 3.11
uv pip install -e . # add ".[fast]" for PyMuPDF (AGPL) extraction
The default install uses pypdf (BSD) for PDF text extraction. The optional
fast extra pulls in PyMuPDF — much faster and higher quality, but AGPL-3.0, so
it is opt-in:
uv pip install -e ".[fast]"
Run
uv run arxiv-mcp # starts the stdio MCP server
Normally you don't run this yourself — your MCP client launches it (below).
Wire into an agent
Add to your MCP client config (.mcp.json, Claude Desktop config, etc.). See
.mcp.json.example:
{
"mcpServers": {
"arxiv": {
"command": "uv",
"args": ["run", "--directory", "/ABSOLUTE/PATH/TO/arxiv-mcp", "arxiv-mcp"],
"env": {
"ARXIV_MCP_MAX_PAPERS": "200",
"ARXIV_MCP_MAX_DISK_MB": "2048"
}
}
}
}
Claude Code, at user (global) scope:
claude mcp add arxiv --scope user -- \
uv run --directory /ABSOLUTE/PATH/TO/arxiv-mcp arxiv-mcp
claude mcp list # should show: arxiv ... ✔ Connected
Tools then appear to the agent as mcp__arxiv__search_papers, mcp__arxiv__read_paper, etc.
The skill/SKILL.md file teaches an agent how to use these
tools well (query construction, reading economically, session hygiene). Drop it
wherever your agent loads skills.
Quickstart: a research flow
The intended pattern for a multi-step task:
start_session(session_id="rlhf-review")— open a session.search_papers(title="...", category="cs.LG", session_id="rlhf-review")— discover.get_paper(paper_id="2203.02155", session_id="rlhf-review")— inspect metadata.read_paper(paper_id="2203.02155", page=1, session_id="rlhf-review")— read, page by page.end_session(session_id="rlhf-review")— release pinned papers.
Passing the same session_id throughout pins every fetched paper so nothing
refetches across calls or intervals, and protects them from eviction mid-task.
Tools reference
search_papers
Search arXiv; returns compact metadata plus total_results for paging.
| Param | Type | Default | Notes |
|---|---|---|---|
query |
str | – | Raw arXiv field syntax, e.g. au:hinton AND cat:cs.LG. |
category |
str | – | Shortcut → cat:<value> (e.g. cs.LG). |
author |
str | – | Shortcut → au:<value> (quoted if it contains spaces). |
title |
str | – | Shortcut → ti:<value>. |
abstract |
str | – | Shortcut → abs:<value>. |
id_list |
list[str] | – | Fetch specific ids instead of searching. |
start |
int | 0 | Pagination offset. |
max_results |
int | 10 | Capped at 2000/call; total window 30000. |
sort_by |
str | relevance |
or submittedDate, lastUpdatedDate. |
sort_order |
str | descending |
or ascending. |
session_id |
str | – | Pin returned papers to this session. |
Shortcuts are AND-combined with query. Booleans in raw queries are AND,
OR, ANDNOT (not NOT). For "latest N on X", use
sort_by="submittedDate".
get_paper
get_paper(paper_id, session_id=None) — full metadata for one id (any form).
Served from cache when possible. Returns normalized metadata plus derived
pdf_url / abs_url / html_url / source_url.
read_paper
read_paper(paper_id, page=1, page_size=15000, session_id=None) — paginated full
text. Extraction is HTML/source-first with a PDF fallback; the result is cached
permanently per exact version. The response includes method
(html/ar5iv/pdf/cache), page, total_pages, total_chars, and
has_more. Pin a version with 2401.12345v1; a bare id reads the latest.
download_paper
download_paper(paper_id, fmt="pdf", session_id=None) — download the raw pdf
or source (LaTeX tarball) into the cache; returns the local path.
Sessions
start_session(session_id)— open a session (pins its papers).end_session(session_id)— close it, unpinning its papers.session_status(session_id)— list the papers pinned to it.
Cache
cache_stats()— paper count, disk usage, limits, open sessions.list_cached()— cached papers (most-recent first) with size and pin state.clear_cache(drop_pinned=False)— evict papers (keeps open-session papers unlessdrop_pinned).
Categories
list_categories(group=None)— the bundled arXiv taxonomy. Pass a group prefix (cs) to narrow, or a full id (cs.AI) for its description.
Sessions & caching
Content is addressed by normalized id + version, so two sessions requesting the same paper share one copy on disk — never a double fetch. Open a session, do your research across as many tool calls / intervals as you like (nothing refetches), then close it to release its papers for eviction.
Between and during sessions the cache stays bounded automatically by two
independent ceilings — paper count and disk size — with least-recently-
accessed papers evicted first (ARXIV_MCP_MAX_PAPERS, ARXIV_MCP_MAX_DISK_MB).
Papers pinned to an open session are never evicted, so an in-flight task can't
lose a paper mid-work. When reclaiming space, a paper's heavy raw PDF/source is
dropped before its cheap extracted text and metadata.
Configuration
All via environment variables:
| Var | Default | Meaning |
|---|---|---|
ARXIV_MCP_HOME |
~/.arxiv-mcp |
Cache root directory. |
ARXIV_MCP_MAX_PAPERS |
200 |
Max cached papers before LRU eviction. |
ARXIV_MCP_MAX_DISK_MB |
2048 |
Max cache disk (MB) before LRU eviction. |
ARXIV_MCP_META_TTL_S |
86400 |
TTL (s) for "latest" (unversioned) metadata. |
Architecture
src/arxiv_mcp/
server.py MCPServer + the 11 tool definitions (stdio entry point)
client.py Atom query API + content fetch; all traffic rate-limited
rate_limiter.py global ≥3s limiter + 503 back-off + single-flight dedup
cache.py 3-tier disk cache, sessions, LRU eviction (count AND size)
extract.py HTML/ar5iv-source-first text extraction, pypdf fallback
ids.py id normalization (new/old schemes, URL/DOI) + URL builders
categories.py bundled arXiv subject taxonomy
Request path. Every tool that touches the network goes through
ArxivClient, whose _get acquires the shared RateLimiter before each call,
honors Retry-After on 503, and retries transient failures. Identical
in-flight fetches are deduplicated by SingleFlight. Results land in Cache,
keyed by ArxivId.key (normalized id + version), and every write triggers a
bounded LRU eviction pass that skips session-pinned papers.
Extraction order. read_paper → arxiv.org/html (LaTeXML) →
ar5iv.labs.arxiv.org → PDF. HTML sources are accepted only when they carry a
real render; arXiv serves a 200-status stub (or 404) for papers without native
HTML, so short/stub responses are rejected and fall through to the PDF, which is
always available.
Development & testing
uv pip install -e .
# Offline unit tests (id normalization, cache eviction & pinning) — no network:
uv run python -m pytest tests/ -q
# or without pytest:
uv run python tests/test_offline.py
# Live end-to-end smoke test against arXiv (needs network, ~30s, polite 3s spacing):
uv run python tests/test_live.py
test_offline.py is deterministic and network-free. test_live.py performs a
handful of real requests (search, metadata, extraction, cache-hit) and asserts a
few well-known papers resolve correctly.
Troubleshooting
claude mcp listshows "Failed to connect". Ensureuvis on PATH and the--directorypath is correct and absolute. Runuv run arxiv-mcpin the repo to see startup errors directly (it will wait for stdio input; Ctrl-C to exit).- A paper won't read / returns a short stub. Older or PDF-only papers have no
arXiv HTML; the server falls back to the PDF automatically. If the PDF itself is
a scan with no text layer, extraction may be sparse — install the
fastextra for better results. - Cache growing? It can't exceed
ARXIV_MCP_MAX_PAPERS/ARXIV_MCP_MAX_DISK_MBexcept for papers pinned to open sessions. Callend_sessionwhen done, orclear_cache. - Rate-limited by arXiv. The server already spaces requests ~3 s apart; avoid
launching large fan-outs of
read_paperacross many papers at once.
License
MIT — see LICENSE. The optional fast extra (PyMuPDF) is AGPL-3.0;
the default install avoids it.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。