Skip to main content
Glama

RAG MCP サーバー

Docs フォルダに配置した文書をベクトル検索し、LLM が回答生成時に参照できるコンテキストを提供する MCP サーバーです。 ローカル LLM からの呼び出しを想定しています。

必要条件

  • Python 3.10 以上

  • uv (パッケージマネージャー)

Related MCP server: RAG MCP Tool

セットアップ

# 依存関係のインストール
uv sync

初回起動時に sentence-transformers (all-MiniLM-L6-v2) のモデルが自動ダウンロードされます (~80MB)。

使い方

1. 文書を配置する

プロジェクトルートの Docs/ フォルダに文書を入れます。対応形式:

形式

拡張子

プレーンテキスト

.txt

Markdown

.md

CSV

.csv

JSON

.json

YAML

.yaml / .yml

PDF

.pdf

2. サーバーを起動する

uv run python -m rag_mcp.server

起動時に Docs/ 内の全ファイルが読み込まれ、ベクトルインデックスが作成されます。 インデックスは .chromadb/ に永続化されます。

3. MCP ツールを使う

MCP クライアント経由で以下のツールが利用できます。

search_docs

文書からクエリに関連する内容を検索します。

パラメータ:
  query    (string, 必須) — 検索クエリ
  top_k    (integer, 省略可) — 返却件数 (デフォルト: 5)

reindex

Docs/ フォルダの全ファイルを再インデックスします。

パラメータ: なし

list_sources

インデックス済みのファイル一覧を表示します。

パラメータ: なし

LLM クライアント設定

Claude Desktop

claude_desktop_config.json に追加:

{
  "mcpServers": {
    "rag-mcp": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "C:\\path\\to\\rag_mcp",
        "python",
        "-m",
        "rag_mcp.server"
      ]
    }
  }
}

Cursor

プロジェクトルートに .cursor/mcp.json を作成:

{
  "mcpServers": {
    "rag-mcp": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "C:\\path\\to\\rag_mcp",
        "python",
        "-m",
        "rag_mcp.server"
      ]
    }
  }
}

設定

src/rag_mcp/config.py で動作をカスタマイズできます。

項目

デフォルト

説明

CHUNK_SIZE

1000

チャンク分割サイズ (文字数)

CHUNK_OVERLAP

200

チャンク間のオーバーラップ (文字数)

EMBEDDING_MODEL

all-MiniLM-L6-v2

埋め込みモデル

TOP_K

5

検索のデフォルト取得件数

COLLECTION_NAME

rag_docs

ChromaDB コレクション名

アーキテクチャ

Docs/ の文書
  ↓ 読み込み (txt / md / csv / json / yaml / pdf)
  ↓ チャンク分割 (1000文字 / 200文字オーバーラップ)
  ↓ 埋め込み (sentence-transformers)
  ↓ 保存
ChromaDB (ベクトルストア)
  ↑ 類似検索
MCP サーバー (search_docs ツール)
  ↑ MCP プロトコル (stdio)
LLM クライアント (Claude Desktop, Cursor など)

開発

# テスト実行
uv run python -m pytest tests/              # 全テスト
uv run python tests/test_rag.py             # RAG エンジンの単体テスト
uv run python tests/test_mcp.py             # MCP サーバーの結合テスト

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to search and query PDF documents through a local RAG system with vector embeddings. Provides semantic document search capabilities while keeping all data stored locally without external dependencies.
      -
    • F
      license
      B
      quality
      D
      maintenance
      Provides intelligent retrieval capabilities for local files by scanning directories, generating vector indexes, and enabling semantic search through RAG (Retrieval Augmented Generation) with incremental indexing support.
      2
      -
    • A
      license
      A
      quality
      Not graded
      maintenance
      Enables searching and retrieving documents from a local folder to ground LLM answers in your files.
      2
      MIT
    • A
      license
      A
      quality
      F
      maintenance
      Provides LLMs with secure, read-only access to local documentation by scanning directories, extracting content from PDF, DOCX, Markdown, and text files, and performing keyword searches.
      3
      6 npm
      MIT