Skip to main content
Glama
nilab-llc

hybrid-rag-mcp-server

by nilab-llc

hybrid-rag-mcp-server

hybrid-rag-pdf-jp をラップした MCP(Model Context Protocol)サーバーです。 Claude Desktop などの MCP 対応クライアントから、PDF への自然言語検索をツールとして利用できます。


アーキテクチャ

Claude Desktop (MCP クライアント)
        │  MCP (stdio)
        ▼
  server.py(FastMCP)
        │  import
        ▼
  hybrid-rag-pdf-jp/rag.py
        │  load_vectorstore()
        ▼
  ChromaDB(ローカル永続化)
        │  類似チャンク検索 (k=4)
        ▼
  nomic-embed-text(Ollama)

提供ツール

ツール名

引数

説明

search_pdf

query: str

PDF 内をベクトル検索し、上位 4 チャンクを返す

get_pdf_info

なし

ChromaDB の登録チャンク数・ソースファイル情報を返す


Related MCP server: MCP Server Knowledge Engine

前提条件

  • Python 3.11 以上

  • Ollama が起動済みで nomic-embed-text がインストール済み

  • hybrid-rag-pdf-jpchroma_db/ が構築済み(python rag.py を一度実行済み)

  • Anthropic API キーを取得済み

  • Node.js v18以上(MCP Inspector使用時のみ必要) https://nodejs.org/en/download から Prebuilt Installer をインストール

ollama pull nomic-embed-text

セットアップ手順

1. リポジトリのクローン(または配置確認)

project/
├── hybrid-rag-pdf-jp/   ← 既存プロジェクト(chroma_db 構築済み)
└── hybrid-rag-mcp-server/  ← 本プロジェクト

2. 環境変数の設定

cp .env.example .env
# .env を編集して ANTHROPIC_API_KEY を設定

.env の内容:

ANTHROPIC_API_KEY=your_key_here
CHROMA_DB_PATH=../hybrid-rag-pdf-jp/chroma_db
RAG_PROJECT_PATH=../hybrid-rag-pdf-jp

3. 依存パッケージのインストール

pip install -e .

4. 動作確認

python server.py

MCP Inspector を使ったデバッグ:

mcp dev server.py

Claude Desktop への登録方法

claude_desktop_config.json に以下を追記します。

設定ファイルの場所:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "hybrid-rag-pdf-jp": {
      "command": "python",
      "args": [
        "C:\\Users\\pcuser\\Documents\\project\\hybrid-rag-mcp-server\\server.py"
      ],
      "env": {
        "ANTHROPIC_API_KEY": "your_key_here",
        "CHROMA_DB_PATH": "C:\\Users\\pcuser\\Documents\\project\\hybrid-rag-pdf-jp\\chroma_db",
        "RAG_PROJECT_PATH": "C:\\Users\\pcuser\\Documents\\project\\hybrid-rag-pdf-jp"
      }
    }
  }
}

設定後、Claude Desktop を再起動してください。


使い方

Claude Desktop でツールが有効になると、以下のような自然言語で PDF を検索できます。

「FXのリスク管理について教えて」
→ search_pdf("FXのリスク管理") が呼ばれ、PDF の関連箇所を返す

「登録されているPDFの情報を教えて」
→ get_pdf_info() が呼ばれ、チャンク数やファイル名を返す

ライセンス

MIT

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables Claude Desktop to search and query personal document collections (PDF, Word, Markdown, text) using semantic search and conversational AI with full context preservation across exchanges.
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Transforms PDF collections into a searchable knowledge base using TF-IDF indexing and proximity matching. It enables users to search documents, retrieve specific page content, and manage document libraries through natural language via MCP clients.
    5
    -
  • A
    license
    A
    quality
    D
    maintenance
    Enables MCP clients to list indexed PDF document collections and perform semantic search queries on them using locally extracted text and embeddings.
    2
    AGPL 3.0
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables querying enterprise documents (DOCX, PDF, PPTX) using natural language, with hybrid search and MCP integration for Claude Desktop and other agents.
    MIT