Skip to main content
Glama
paper-retrieval

paper-retrieval

by zhangleiniu

License: MIT Python 3.12

Paper search for coding agents. mustcite-mcp indexes a corpus of AI/ML papers (full text and the citation graph between them) and serves it to Claude Code, Codex, or any MCP client. One find_papers call runs the whole retrieval pipeline and returns ranked papers, each with the passage that matches the question and its official URL.

mustcite.com lets people search the corpus that OpenPapers collects; mustcite-mcp gives agents the same corpus, searched in depth. paperlevelup, an agent skill for organizing topic folders of papers and finding the ones you are missing, uses it as its main library search.

Step

Tool

Output

Collect

OpenPapers

PDFs and metadata (official URL, OpenReview id, DOI) for 15 AI/ML venues

Extract

masterset-toolkit

GROBID full text, citation contexts, a paper table with references matched to papers in the corpus

Index and serve

mustcite-mcp (this repository)

indexes, a search engine, and the MCP tools

Work with papers

paperlevelup (optional)

an agent workflow on top of the tools

No data ships with this repository: you build your corpus with the first two tools, on your own machine.

What a search looks like

Ask the agent in plain words; it passes your question to find_papers verbatim and reports every result:

This is a real call on a corpus of about 185k papers. The service ranks; judging which results fit your intent stays with the agent and with you. Other requests it handles:

You ask

Tool

"papers on X", "which papers do X?"

find_papers, with filters on venue, year, and authors

"work related to this paper", "baselines for Y"

find_related_papers (by id, URL, or title + abstract)

"does this paper use dataset Z?"

search_passages, exact_search, get_paper(section=...)

"who cites it, and why?"

get_citation_neighbors, with the citing sentence

"summarize this paper"

get_research_profile (key passages; the agent writes the summary)

Related MCP server: paper-search-mcp

How search works

  • Three text channels: BM25 over full-text passages, dense retrieval over titles and abstracts (Qwen3-Embedding-4B) and over passages (Qwen3-Embedding-0.6B), fused by reciprocal-rank fusion.

  • Reranking: the top 50 papers are reranked with Qwen3-Reranker-4B.

  • Citation graph: personalized PageRank and co-citation, seeded from the reranked top, add well-cited work the text missed.

  • The verbatim question: agents pass the user's words as original_query. Its results are merged into every follow-up call, so a narrowed query cannot lose them.

  • Evidence: each result carries its passage closest to the query; the agent quotes it.

  • Optional: a citation-intent model, for relation_type="baseline" (papers cited as baselines), and an LLM judge (any OpenAI-compatible endpoint) for llm_judge=true.

The configuration was chosen by evaluation on test sets built from the corpus itself (a citation sentence → the papers it cites; a paper → its references). The commands are included (see Evaluation).

Requirements

  • Linux, Python 3.12, uv.

  • An NVIDIA GPU with about 20 GB of free memory, for building the embeddings and for serving. The server loads the models on first use and releases the GPU after an idle period.

  • For about 185k papers: about 30 GB of disk for snapshot and indexes, and about 40 GB of RAM for the server. Smaller corpora need proportionally less.

Setup

  1. Collect papers with OpenPapers for the venues and years you want.

  2. Extract full text and references with masterset-toolkit: GROBID full text, citation contexts, and the dataframe builder (preprocessing/dataframe_builder/), which writes all_papers_with_refs.parquet. Keep PAPER_UUID_NAMESPACE the same in both tools.

  3. Configure: cp .env.example .env and set

    • PR_DATA_ROOT: where snapshots, indexes, and logs go;

    • PR_CORPUS_PARQUET: the toolkit's all_papers_with_refs.parquet (may contain {run_id});

    • PR_FULLTEXT_ROOT: the toolkit's data directory (the parquet's path column is relative to it);

    • PR_METADATA_DIR: OpenPapers' metadata/ directory;

    • PR_SNAPSHOT_RUN_ID: a name for this corpus version, e.g. 2026-11;

    • PR_CORPUS_DESCRIPTION: how the tools describe your corpus to agents (optional).

  4. Build:

    uv sync
    uv run paper-retrieval snapshot              # paper table, links, citation edges
    uv run paper-retrieval passages              # full text -> passages with citation markers
    uv run paper-retrieval build --build full    # chunks, BM25, citation graph, embeddings (GPU)

    Every step is resumable and writes a manifest.json (inputs, parameters, counts) next to its output.

  5. Serve (binds to 127.0.0.1 only):

    uv run paper-retrieval-server --build full --no-llm
  6. Connect an agent. The MCP adapter is a thin stdio process that forwards calls to the server; it registers as paper-retrieval. On the same machine:

    claude mcp add paper-retrieval -- /path/to/mustcite-mcp/.venv/bin/paper-retrieval-mcp

    From another machine, run the adapter over SSH (no port is exposed):

    claude mcp add paper-retrieval -- ssh <server> /path/to/mustcite-mcp/.venv/bin/paper-retrieval-mcp

    For Codex, in ~/.codex/config.toml:

    [mcp_servers.paper-retrieval]
    command = "ssh"
    args = ["<server>", "/path/to/mustcite-mcp/.venv/bin/paper-retrieval-mcp"]
  7. Give the agent the guide. agent/SKILL.md tells it how to call the tools and report results (pass the question verbatim, report every result in order, cite the URL). Install it as a skill, or use paperlevelup, which carries the same rules.

When the corpus grows, paper-retrieval rebuild --run-id <new run> runs snapshot, passages, and the full build for the new run (unchanged papers' vectors are reused) and reloads the running server.

The repository is named after the corpus it was built for; the Python package, the commands, and the MCP server are named paper-retrieval.

Optional components

  • Citation intent: set PR_INTENT_MODEL to a directory holding a trained model (model.json + model.npz; see src/paper_retrieval/intent.py). Without one, relation_type="baseline" ranks like any (the response says so), and citation neighbors carry no baseline probability.

  • LLM judge: start the server without --no-llm and set PR_LLM_BASE_URL, PR_LLM_MODEL, and PR_LLM_API_KEY for an OpenAI-compatible endpoint (e.g. vLLM). find_papers(llm_judge=true) then adds a relevance judgment to each result.

Evaluation

uv run paper-retrieval build --build eval                # papers up to 2024 only
uv run paper-retrieval testsets --version v1             # test queries from 2025 papers
uv run paper-retrieval evaluate --tasks t1 t2 --splits dev --retrievers bm25-paper "rrf:bm25-paper+dense-papers-qwen3-emb-0.6b"

T1 asks for the papers a 2025 citation sentence cites; T2 for a 2025 paper's references. Retriever specs are described in src/paper_retrieval/retrievers.py; the configuration the server runs is in src/paper_retrieval/serving.py.

Development

This repository is exported from the authors' working repository at each release, so its history has one commit per release (see CHANGELOG.md). Issues and pull requests are welcome: accepted pull requests are applied upstream and appear in the next release, with credit.

uv run pytest                    # no GPU or data needed; includes an end-to-end run on a synthetic corpus
python3 docs/make_figures.py     # regenerate the figures

License

MIT (see LICENSE).

Available Tools

7 tools
find_papersA

Search the paper corpus (with full text and an in-corpus citation graph) for papers matching a research question. Runs the full pipeline: keyword and embedding search over titles, abstracts and full-text passages, citation-graph expansion, and cross-encoder reranking. This is the main entry point. ALWAYS pass the user's question verbatim, unchanged, as original_query on every call. Put your own rewrite or sub-question in query. On the first call pass the verbatim question as both. Results for the original question are always fused in, so a narrow rewrite cannot lose them. Each result has paper_id, title, venue, year, url (cite this), ranks per retrieval channel, and an evidence passage: judge relevance yourself from the title and the passage. If the results clearly miss the question, rephrase and search again.

Inputs: query (required), k, filters, llm_judge, +2 more.

get_citation_neighborsB

In-corpus citation neighbors of a paper: refs (papers it cites) or cited_by (papers citing it), each with P(baseline) of the citation (a classifier of citation intent: baseline / direct comparison / core reference) and the citing sentence. intent: baseline keeps only edges classified as baseline, other the rest.

Inputs: paper_id (required), k, intent, direction.

get_paperA

Metadata, abstract, and section list of a paper. With section (a heading or its number as listed), the full text of that section.

Inputs: paper_id (required), section.

get_research_profileA

The passages to read for a research profile of a paper (problem, method, assumptions, findings, limitations): its abstract, the start of the introduction, method sections, and the conclusion, in document order with passage ids (about 14,000 characters). Summarize them yourself, citing passage ids.

Inputs: paper_id (required).

search_passagesA

Passage-level search over full text (keyword + embedding). Use it to verify a candidate or find where a paper discusses something, optionally restricted to given papers. Returns passages with paper_id, section, text.

Inputs: query (required), k, paper_ids.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 7 tools

    Disambiguation4/5

    The tools have mostly distinct retrieval goals: broad question search, passage search, exact term matching, related-paper discovery, metadata/section retrieval, citation neighbors, and research-profile extraction. There is some conceptual overlap between search_passages, exact_search, and get_paper with section retrieval, but the descriptions provide clear boundaries for when to use each.

    Naming Consistency4/5

    Most names follow a clear verb_noun pattern such as find_papers, search_passages, get_paper, and get_citation_neighbors. exact_search is the main deviation, using an adjective_noun form, but it is still readable and consistent enough overall.

    Tool Count5/5

    Seven tools is a well-scoped set for a paper retrieval server, with each tool covering a distinct retrieval mode or evidence-gathering need. No tool appears redundant or out of place.

    Completeness4/5

    The server covers semantic search, passage verification, exact matching, related work, metadata, citation context, and research-profile extraction. Minor gaps might include author/venue filtering or batch paper comparison, but the core retrieval lifecycle is well represented.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      Enables agents to search papers across Semantic Scholar and arXiv, read and extract text from arXiv PDFs, align records across sources, and produce structured literature-analysis digests.
      10
      1
      -
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to search and retrieve academic papers from arXiv and PubMed with citation-grade extraction, providing clean citations and summaries.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to search scholarly works, authors, institutions, venues, and concepts, retrieve detailed metadata, and explore citation networks through natural-language requests.
      112 npm
      MIT