rag-pipeline
RAG Pipeline
Локальный конвейер извлечения с GPU-ускорением для научных статей — разбирает PDF с учетом структуры layout, получает реальные библиографические метаданные (DOI → CrossRef), создает гибридные dense + sparse эмбеддинги и хранит всё в Qdrant для гибридного поиска с реранкингом. Создан для запросов напрямую из Claude через MCP-сервер.
Зачем
Если просто складывать PDF в папку, они невидимы для поиска. Этот проект превращает кучу PDF во что-то доступное для запросов: правильные чанки с учетом разделов/абзацев (а не наивное разбиение по символам), готовые к цитированию метаданные, автоматически подтянутые из CrossRef, и гибридный dense+sparse поиск, чтобы работали и семантические запросы, и точное совпадение терминов — всё это доступно как MCP-инструменты, так что Claude может напрямую искать и загружать статьи.
Related MCP server: Personal Research Assistant MCP
Возможности
Разбор PDF с учетом layout через Docling — разбиение на чанки по абзацам/разделам вместо наивного деления по символам; для каждого чанка сохраняются номера страниц и заголовки разделов.
Настоящие библиографические метаданные — DOI извлекается с первой страницы с помощью регулярных выражений, полные данные цитирования (название, авторы, журнал, год, том/выпуск/страницы) получаются через CrossRef API; если DOI не найден, используются метаданные самого PDF.
Гибридные эмбеддинги — dense (
BAAI/bge-m3) + sparse (SPLADE,prithvida/Splade_PP_EN_v1) векторы для каждого чанка, хранятся вместе в Qdrant для гибридного поиска.Фоновая загрузка — воркер Redis + RQ, чтобы большие PDF не блокировали запрос; Docker-контейнер с GPU для эмбеддингов.
MCP-сервер с двумя инструментами для Claude —
search_papers(гибридный поиск с реранкингом) иingest_paper(добавление PDF прямо в индекс) — предназначен для работы как память о научных статьях, к которой Claude может обращаться напрямую.Полная контейнеризация — контейнеры Qdrant + Redis + API/воркер с GPU через
docker-compose.
Технологический стек
Python · Docling (разбор PDF) · sentence-transformers (dense-эмбеддинги BGE-M3) · fastembed (sparse-эмбеддинги SPLADE) · Qdrant (гибридный векторный поиск) · Redis + RQ (фоновая очередь задач) · FastAPI (планируемый слой API) · MCP (сервер Model Context Protocol для Claude) · Docker Compose, GPU-контейнер CUDA 12.9.
Статус
В разработке — пока не полностью связан в единый конвейер.
Уже работает: ingest.py запускается автономно из CLI — разбирает PDF, получает метаданные, создает эмбеддинги (dense + sparse) и загружает в Qdrant. Укажите запущенный экземпляр Qdrant — и всё работает.
Чего не хватает: main.py — сервис FastAPI, который должен предоставлять /search, /ingest и /health. Dockerfile копирует его, healthcheck в Docker Compose пингует его, RQ-воркер ожидает, что кто-то будет ставить для него задачи в очередь, а оба инструмента Claude в mcp_server.py обращаются к нему по HTTP на localhost:8000. Без него воркеру нечего обрабатывать, инструментам MCP не с чем общаться, а docker-compose up не соберется (на этапе сборки образа API/воркера копируется несуществующий файл).
В docker-compose.yml bind-монтирования по-прежнему указывают на путь Windows (S:\RAG-data\...) из более ранней настройки — измените их на нужное расположение данных Qdrant/Redis/кэша моделей перед запуском.
Запуск (на данный момент)
uv sync
# Qdrant needs to be running somewhere ingest.py can reach:
docker run -p 6333:6333 qdrant/qdrant
python ingest.py path/to/paper.pdfПолный конвейер (стек Docker Compose, API /search и /ingest, инструменты MCP) заработает, когда появится main.py.
Available Tools
2 toolsingest_paperA
Ingest a PDF file from the local filesystem into the search index. The file is chunked, embedded (dense + sparse), and stored in Qdrant.
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | Absolute or relative path to the PDF file. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden of disclosing effects. It clearly explains the processing pipeline: the file is chunked, embedded with dense + sparse vectors, and stored in Qdrant. This lets an agent anticipate side effects. It does not mention idempotence, duplicate handling, or failure behavior, but the core mutation is transparently described.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two tight sentences with no filler. The first sentence states the primary action and target, the second adds the important processing steps. Every word earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a single-parameter ingest operation, the description covers the core workflow and storage destination. It does not describe the return value or failure behavior, but given the simple input and lack of output schema, the definition is reasonably complete for an agent to invoke it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema already provides 100% coverage for the single parameter file_path, including its type and that it is an absolute or relative path. The description adds little beyond the schema, reinforcing that the file is a local PDF. That meets the baseline of 3 but does not exceed it.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb ('Ingest'), a clear resource ('PDF file'), and a destination ('search index'). It also names the sibling (search_papers) implicitly by its focus on adding to an index, so an agent can distinguish ingest from search without extra context.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies when to use this tool (when a PDF needs to be added to the search index) versus the sibling search_papers (when querying is needed), but it never explicitly states 'use this when... use search_papers when...' or mentions any exclusions or prerequisites.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_papersA
Search the ingested paper collection using a natural-language query. Returns the most relevant passages with page numbers and sources, ranked by a cross-encoder reranker.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of results to return (default 5). | |
| query | Yes | The search query in natural language. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden of behavioral disclosure. It reveals that results are passages rather than full papers, include page numbers and sources, and are ranked by a cross-encoder reranker, which meaningfully describes behavior beyond the tool name.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two sentences with the main action front-loaded. The second sentence efficiently packs return format and ranking behavior. No unnecessary words or redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple two-parameter search tool with no output schema, the description adequately conveys what results include (passages, page numbers, sources, ranked order) and the scope (ingested collection). It does not specify the exact result data structure, but that is minor given the straightforward contract and the clear sibling relationship.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, so the baseline is 3. The description reinforces that the query is natural-language but adds no new detail about the limit parameter or query formatting. It does not need to compensate for schema gaps.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb ('search') and resource ('ingested paper collection'), and clarifies that queries are natural-language. It also distinguishes itself from the sibling 'ingest_paper' by focusing on retrieval of already-ingested content rather than adding papers.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase 'ingested paper collection' clearly implies this is for searching papers previously added, giving the agent a strong contextual signal about when to use it. However, it does not explicitly name the alternative or state exclusions, so it falls short of full routing guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
2 tool updates
v0.1.0- First observed
ingest_paper - First observed
search_papers
TDQS
Scored across 2 tools
The two tools have completely distinct roles: one adds documents to the index, the other queries it. There is no overlap or ambiguity between ingestion and search.
Both tools follow a verb_noun pattern and are recognizable at a glance. The only minor inconsistency is that one uses the plural 'papers' while the other uses singular 'paper'.
Two tools is a thin surface, falling below the typical 3-15 well-scoped range. Each tool is essential for the core RAG workflow, but the set still feels minimal for anything beyond basic ingest-and-query usage.
The core ingest and search operations are present, giving agents the main RAG loop. However, there is no way to list, delete, or update ingested papers, which leaves obvious workflow gaps around managing the collection.
Maintenance
Related MCP Connectors
Search arXiv/Semantic Scholar/OpenAlex + medical evidence (PubMed/Europe PMC) + LaTeX/PDF tools.
Research paper search with real citations and reference formatting for AI assistants
Search arXiv and ACL Anthology, retrieve citations and references, and browse web sources to accel…
Search 340M+ academic papers — citation graphs, semantic similarity, and AI literature reviews.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables Claude to perform hybrid search across local documents by combining semantic vector retrieval and BM25 keyword matching for optimal context recovery. It supports multiple file formats including PDF, CSV, and Markdown, leveraging local Ollama models for private and efficient document querying.4MIT
- FlicenseNot gradedqualityDmaintenanceEnables semantic search and conversational querying across a personal research library of PDFs, DOCX, and other documents using a vector database. It provides tools for document summarization, finding related papers, and high-accuracy retrieval for AI clients like Claude Desktop.-
- AlicenseBqualityCmaintenanceA second brain for researchers — gives Claude persistent memory of your papers, field, and working history, with answers cited from your own indexed library2834AGPL 3.0
- AlicenseNot gradedqualityDmaintenanceEnables Claude Code to index and semantically search through PDFs, code, and documents with exact citations and zero hallucinations.MIT