rag_mcp

rag_mcp

Enables retrieval-augmented generation by allowing LLMs to search documents in a local folder using vector similarity, supporting multiple file formats.

Category
Visit Server

README

RAG MCP サーバー

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

必要条件

  • Python 3.10 以上
  • uv (パッケージマネージャー)

セットアップ

# 依存関係のインストール
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 サーバーの結合テスト

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured