Skip to main content
Glama

🇵🇱 ポーランド語版

RAG Pipeline

ローカルで動作し、GPU で高速化された、研究論文向けの検索パイプラインです。レイアウトを考慮したチャンキングで PDF を解析し、実際の書誌メタデータ(DOI → CrossRef)を取得し、dense + sparse のハイブリッド埋め込みを生成して、すべてを Qdrant に保存します。リランキング付きのハイブリッド検索も可能で、Claude から MCP サーバー経由で直接クエリできるように設計されています。

なぜ

論文をフォルダに入れただけでは、検索の対象になりません。このパイプラインは、PDF の山を検索可能なものに変えます。単純な文字数分割ではなく、セクション/段落を認識した適切なチャンク、CrossRef から自動取得される引用に使えるメタデータ、意味的検索と完全一致検索の両方に対応する dense + sparse のハイブリッド検索を備えています。これらはすべて MCP ツールとして公開されるため、Claude は論文を直接検索して取り込むことができます。

Related MCP server: Personal Research Assistant MCP

特徴

  • レイアウトを考慮した PDF パース — Docling を使用し、単純な文字数分割ではなく段落/セクション単位でチャンク化します。各チャンクにページ番号とセクション見出しを保持します。

  • 実際の書誌メタデータ — 1 ページ目から DOI を正規表現で抽出し、CrossRef API 経由で完全な引用情報(タイトル、著者、ジャーナル、年、巻/号/ページ)を解決します。DOI が見つからない場合は PDF 自体のメタデータにフォールバックします。

  • ハイブリッド埋め込み — チャンクごとに dense(BAAI/bge-m3)+ sparse(SPLADE、prithvida/Splade_PP_EN_v1)ベクトルを生成し、Qdrant にまとめて保存してハイブリッド検索を実現します。

  • バックグラウンド取り込み — Redis + RQ ワーカーにより、大きな PDF でもリクエストをブロックしません。埋め込み用の GPU 対応 Docker コンテナも含みます。

  • MCP サーバー — Claude に 2 つのツールを公開します。search_papers(リランキング付きハイブリッド検索)と ingest_paper(PDF を直接インデックスに取り込む)です。Claude が直接クエリできる研究論文用メモリとして機能します。

  • Docker 化 — docker-compose により、Qdrant + Redis + GPU 対応 API/ワーカーコンテナを構成します。

技術スタック

Python · Docling(PDF パース) · sentence-transformers(BGE-M3 dense 埋め込み) · fastembed(SPLADE sparse 埋め込み) · Qdrant(ハイブリッドベクトル検索) · Redis + RQ(バックグラウンドジョブキュー) · FastAPI(予定されている API レイヤー) · MCP(Claude 用 Model Context Protocol サーバー) · Docker Compose、CUDA 12.9 GPU コンテナ。

ステータス

作業中です。まだ完全にはエンドツーエンドで接続されていません。

現在動作するもの: ingest.py は CLI から単独で実行できます。PDF を解析し、メタデータを取得し、(dense + sparse で)埋め込みを生成して、Qdrant にアップサートします。起動中の Qdrant インスタンスを指定すれば動作します。

不足しているもの: main.py、つまり /search、/ingest、/health を公開する予定の FastAPI サービスです。Dockerfile はこのファイルをコピーし、Docker Compose のヘルスチェックはこのファイルに ping を送り、RQ ワーカーはジョブを投入する何かを期待しており、mcp_server.py の 2 つの Claude ツールはどちらも localhost:8000 への HTTP でこのファイルを呼び出します。これがないと、ワーカーが消費するものも、MCP ツールが通信するバックエンドもなくなり、docker-compose up はビルドに失敗します(API/ワーカーイメージのビルドステップが存在しないファイルをコピーするため)。

docker-compose.yml のバインドマウントも、以前のセットアップの 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 スタック、/search と /ingest API、MCP ツール)は、main.py が存在すれば動作します。

Available Tools

2 tools
ingest_paperA

Ingest a PDF file from the local filesystem into the search index. The file is chunked, embedded (dense + sparse), and stored in Qdrant.

NameRequiredDescriptionDefault
file_pathYesAbsolute or relative path to the PDF file.

TDQS

A4/5.0
Behavior4/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines3/5

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.

NameRequiredDescriptionDefault
limitNoNumber of results to return (default 5).
queryYesThe search query in natural language.

TDQS

A4.2/5.0
Behavior4/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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.

  1. 2 tool updatesv0.1.0
    • First observedingest_paper
    • First observedsearch_papers

TDQS

A4/5.0

Scored across 2 tools

Disambiguation5/5

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.

Naming Consistency4/5

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'.

Tool Count3/5

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.

Completeness3/5

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

ActivityStale
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables 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.
    5
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables 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.
    -