SuperAPIAI Directory

scholar-rag-mcp

github.com · AI developer platforms

Academic paper knowledge base over local PDFs: MinerU parsing, metadata normalization, Qdrant vector search with reranking and paginated full-text reading.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsmacOS · Linux

About this tool

Purpose

scholar-rag-mcp is a publishable MCP tool for an academic paper knowledge base. It targets a local PDF folder, processes each paper through a real parsing pipeline (MinerU), normalizes metadata, annotates section structure, chunks and embeds vectors, and stores everything uniformly in Qdrant. Afterward, an AI agent (or the user themself) can use 11 MCP tools over stdio to semantically retrieve chunks, run PubMed-style document queries, read full text by section, add/remove individual papers, and manage the knowledge base. Embedding, annotation, and reranking run on an OpenAI-compatible model service (e.g., vLLM).

Main capabilities

  • Real ingestion pipeline: MinerU PDF parsing (python/cli/api backends) → metadata extraction (local heuristics, CrossRef, optional GROBID) → cleaning → section annotation → deterministic chunking (configurable 300/1500/100 characters) → embedding.
  • Fast retrieval at scale: embedding initial screening + cross-encoder reranking; optional metadata filtering (doc_id, section, year, journal, etc.) evaluated inside the Qdrant index. It is claimed that at a scale of 100k chunks, p95 query latency is < 1s (see docs/perf-report.md).
  • Asynchronous tasks: create_kb / add_document are background tasks, and progress can be queried via get_job; restart-safe (interrupted tasks are recovered and skipped on rerun).
  • Context-safe reading: paginated get_document_text with a hard size limit; first provide an outline, then fetch pages on demand.
  • 11 stdio MCP tools: list_kbs, create_kb, delete_kb (two-phase), add_document, remove_document, get_document, get_document_text, list_documents, search_documents, search_chunks, get_job.
  • Self-contained storage: the knowledge base resides under a single data directory (the default location varies by platform, see data layout); Qdrant can be started automatically (single binary, version pinned) or connect to an external instance.
  • Two-phase knowledge base deletion: delete_kb returns statistics and a 10-minute-valid confirm_token on the first call, and only the second call carrying that token actually deletes the Qdrant collection, the knowledge base directory, and its task history.

Usage

Platforms supported are Linux x64, Windows x64, and macOS (Intel and Apple Silicon). It has been published to PyPI, and the standard way to run it is with uv (which automatically fetches a suitable Python 3.12), with no need to check out the repository.

One-click install/uninstall:

  • uvx scholar-rag-mcp install installs via uv tool install and interactively guides you through six model endpoint settings (base URL and model name for chat / embed / rerank), unless SCHOLAR_RAG_* values or --chat-base-url / --chat-model / --embed-base-url / --embed-model / --rerank-base-url / --rerank-model arguments are already provided, in which case the defaults listed in "Minimal environment" are used; --yes accepts all defaults without prompting. It then detects four supported MCP clients (Claude Desktop, Claude Code, opencode, Codex) and merges only the scholar-rag-mcp entry into their user-level configuration; --client <name> can specify a single client. Configurations that cannot be parsed are left as-is and a manual snippet is printed.
  • scholar-rag-mcp uninstall removes the entry from detected clients and runs uv tool uninstall; the knowledge base data directory is retained. --purge additionally deletes the data directory after explicit confirmation (--yes can be used to skip the prompt).

Running from source for development requires pixi. At the repository root, the pixi environment is locked for all four supported targets; the project defines two pixi environments, each with its own role. The built-in doctor can be used to verify the environment.

Model deployment: the environment variables (chat, embed, rerank clients) expect OpenAI-compatible HTTP endpoints. scripts/serve_models.sh starts three vLLM instances for the reference model set. SCHOLAR_RAG_CHAT_MODEL, SCHOLAR_RAG_EMBED_MODEL, and SCHOLAR_RAG_RERANK_MODEL are required—if not set, the script will error out and exit. Each value must be the absolute path to a local HuggingFace model directory; vLLM serves the model under the directory basename as its short name, so client settings must use that short name. The ports (CHAT_PORT / EMBED_PORT / RERANK_PORT) and GPU id are optional and have usable defaults. This script is Linux-only (bash + CUDA + vLLM; vLLM does not support Windows); on Windows/macOS you can point *_BASE_URL to any OpenAI-compatible server, such as Ollama (http://127.0.0.1:11434/v1)、LM Studio local server or llama.cpp server, and set each *_MODEL to the model name reported by that server. The rerank endpoint must expose /v1/rerank (or fall back to an embeddings-only approach).

Minimal environment: start from .env.example and at minimum set the model endpoints (using the short names exposed by the serve script, equal to the basename of each model directory). The embedding model dimension is recorded in kb_meta.json when the knowledge base is created, so changing the embedding model later requires creating a new knowledge base.

PDF parsing (MinerU): since v0.4.0 the default parsing backend is api. The recommended approach is to use the managed sidecar, which installs MinerU into an isolated Python 3.12 venv (MinerU requires Python >=3.10,<3.14) and automatically starts mineru-api on first parse. The first parse triggers the MinerU model download; if you need a China-friendly mirror you can set MINERU_MODEL_SOURCE=modelscope. Self-managed alternative: install MinerU in any Python 3.12 environment, run mineru-api --host 127.0.0.1 --port 8010, and keep the default values (SCHOLAR_RAG_MINERU_BACKEND=api, SCHOLAR_RAG_MINERU_API_URL=http://127.0.0.1:8010)。python backend (in-process import) and the cli backend (subprocess per file) are still available via SCHOLAR_RAG_MINERU_BACKEND.

MCP client setup: point the MCP client at the uvx entry point and configure the model endpoints in the env block (any OpenAI-compatible server works). To check whether the server starts, run uvx scholar-rag-mcp in a terminal—it waits for an MCP client on stdio (Ctrl+C to exit). Using Claude (Claude Desktop / claude CLI) as an example; when running from a source checkout, use pixi run scholar-rag-mcp as the command and set the same variables.

Data layout default data_dir: varies by platform and can be overridden with SCHOLAR_RAG_DATA_DIR. Qdrant storage defaults to <data_dir>/qdrant-storage (can be overridden with SCHOLAR_RAG_QDRANT_STORAGE_DIR) and must be on a local filesystem, not a 9p/network mount. Upgrading from v0.1.0 on Linux: the old defaults (~/.scholar-rag and ~/.local/share/scholar-rag/qdrant) are automatically migrated on first startup; if data already exists in the new location, the migration is skipped with a warning and the old files are left untouched.

Use cases

Suitable for researchers or developers who want to build a local academic paper knowledge base and perform semantic retrieval and full-text reading through AI agents; suitable for scenarios requiring PubMed-style document queries, metadata filtering, and low-latency retrieval over large-scale chunks.

Limitations and known constraints

  • Status is preview v0.4.0; interfaces and storage layout may change in future versions.
  • Qdrant is pinned to v1.12.5—this is the highest version that runs on glibc 2.35; automatic startup downloads it on first use. Newer versions can run on glibc >= 2.38, but the data format is not forward-compatible with old knowledge bases.
  • MinerU runs in its own pixi environment because its transformers version is mutually exclusive with vLLM; PDF parsing therefore prefers pixi run -e mineru.
  • MinerU weights (approx. 3.2 GB) is downloaded to ~/.cache/modelscope/ on first parsing.
  • Metadata title heuristic: A title is selected locally only when the MinerU markdown begins with a # / ## heading, so an opening ## Abstract etc. may be misread as the title. This only affects the local heuristic metadata hierarchy; the CrossRef hierarchy (used when a DOI is found) usually corrects it.
  • Tool dispatch: Unknown extra parameters passed to a tool are silently ignored rather than rejected.
  • 9p storage limitation: Qdrant storage must be on a local filesystem.
  • Platform support: Linux x64 / Windows x64 / macOS Intel+Apple Silicon. The vLLM deployment script is Linux-only; Windows/macOS use any OpenAI-compatible server.
  • Windows long paths: Deep data directories may hit the 260-character limit; keep SCHOLAR_RAG_DATA_DIR shallow or enable Windows long path support.
  • macOS x64 CI: Code-level coverage only; GitHub x64 macOS runners require higher billing, so the CI matrix runs macOS arm64 (macos-latest).
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools