
Store and retrieve entities, relations and observations in a persistent local knowledge graph.

A Python MCP server that indexes documents in multiple formats and provides vector-based retrieval tools over JSON-RPC on stdio.
MCP RAG Server: an MCP-compliant Python server with RAG retrieval is cataloged as an MCP server attributed to karaage0703. A Python MCP server that indexes documents in multiple formats and provides vector-based retrieval tools over JSON-RPC on stdio. It is categorized under ai agents-models. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.
Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.
Catalog license label: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.
Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.
No reviewed records to display. This does not establish that upstream lacks this capability.
No reviewed records to display. This does not establish that upstream lacks this capability.
No reviewed records to display. This does not establish that upstream lacks this capability.
Email delivery is not connected. This page does not collect email addresses or create subscriptions.
Browse the registry for current listings instead.
Reviews for MCP RAG Server: an MCP-compliant Python server with RAG retrieval are not available yet
Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.
Markdown, text, PowerPoint, Word, and PDF files are supported.
It can include chunks before and after the hit chunks, adjustable via context_size, or include the full document when full_document is enabled.
README.md · d407ed5817a1 · Fetched 2026-11-13 09:04:36 UTC
Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.
Showing the last retrieved documentation snapshot; check the source for current changes.
MCP RAG Serverは、Model Context Protocol (MCP)に準拠したRAG(Retrieval-Augmented Generation)機能を持つPythonサーバーです。マークダウン、テキスト、パワーポイント、PDFなど複数の形式のドキュメントをデータソースとして、multilingual-e5-largeモデルを使用してインデックス化し、ベクトル検索によって関連情報を取得する機能を提供します。
このプロジェクトは、MCPサーバーの基本的な実装に加えて、RAG機能を提供します。複数形式のドキュメントをインデックス化し、自然言語クエリに基づいて関連情報を検索することができます。
MCPサーバーの基本実装
RAG機能
ツール
# uvがインストールされていない場合は先にインストール
# pip install uv
# 依存関係のインストール
uv sync
# pgvectorを含むPostgreSQLコンテナを起動
docker run --name postgres-pgvector -e POSTGRES_PASSWORD=password -p 5432:5432 -d pgvector/pgvector:pg17
PostgreSQLコンテナを起動した後、以下のコマンドでデータベースを作成します:
# ragdbデータベースの作成
docker exec -it postgres-pgvector psql -U postgres -c "CREATE DATABASE ragdb;"
-- pgvectorエクステンションをインストール
CREATE EXTENSION vector;
.envファイルを作成し、以下の環境変数を設定します:
# PostgreSQL接続情報
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=password
POSTGRES_DB=ragdb
# ドキュメントディレクトリ
SOURCE_DIR=./data/source
PROCESSED_DIR=./data/processed
# エンベディングモデル設定
EMBEDDING_MODEL=intfloat/multilingual-e5-large
EMBEDDING_DIM=1024
EMBEDDING_PREFIX_QUERY="query: "
EMBEDDING_PREFIX_EMBEDDING="passage: "
このサーバーでは、環境変数でエンベディングモデルを選択できます。
EMBEDDING_MODEL=intfloat/multilingual-e5-large
EMBEDDING_DIM=1024
EMBEDDING_PREFIX_QUERY="query: "
EMBEDDING_PREFIX_EMBEDDING="passage: "
EMBEDDING_MODEL=cl-nagoya/ruri-v3-30m
EMBEDDING_DIM=256
EMBEDDING_PREFIX_QUERY="検索クエリ: "
EMBEDDING_PREFIX_EMBEDDING="検索文書: "
多くのエンベディングモデル(特にE5系)では、テキストの種類に応じてプレフィックスを付けることで性能が向上します:
EMBEDDING_PREFIX_QUERY - ユーザーの検索クエリに自動で追加EMBEDDING_PREFIX_EMBEDDING - インデックス化される文書に自動で追加プレフィックスは自動で処理されるため、MCPクライアントは意識する必要がありません。
エンベディングモデルを変更した場合は、ベクトル次元が変わる可能性があるため、既存のインデックスをクリアして再作成してください:
python -m src.cli clear
python -m src.cli index
uv run python -m src.main
オプションを指定する場合:
uv run python -m src.main --name "my-rag-server" --version "1.0.0" --description "My RAG Server"
python -m src.main
インデックスのクリアとインデックス化を行うためのコマンドラインツールが用意されています。
python -m src.cli --help
python -m src.cli clear
# デフォルト設定でインデックス化(./data/source ディレクトリ)
python -m src.cli index
# 特定のディレクトリをインデックス化
python -m src.cli index --directory ./path/to/documents
# チャンクサイズとオーバーラップを指定してインデックス化
python -m src.cli index --directory ./data/source --chunk-size 300 --chunk-overlap 50
# または短い形式で
python -m src.cli index -d ./data/source -s 300 -o 50
# 差分インデックス化(新規・変更ファイルのみを処理)
python -m src.cli index --incremental
# または短い形式で
python -m src.cli index -i
python -m src.cli count
MCPホスト(Claude Desktop、Cline、Cursorなど)でこのサーバーを使用するには、以下のような設定を行います。設定するjsonファイルについては、各MCPホストの ドキュメントを参照してください。
{
"mcpServers": {
"mcp-rag-server": {
"command": "uv",
"args": [
"run",
"--directory",
"/path/to/mcp-rag-server",
"python",
"-m",
"src.main"
]
}
}
}
command: uv(推奨)またはpythonargs: 実行引数の配列/path/to/mcp-rag-server: このリポジトリの実際のパスに置き換えてくださいuvがインストールされていない環境では、通常のPythonを使用できます:
{
"command": "python",
"args": [
"-m",
"src.main"
],
"cwd": "/path/to/mcp-rag-server"
}
ベクトル検索を行います。
{
"jsonrpc": "2.0",
"method": "search",
"params": {
"query": "Pythonのジェネレータとは何ですか?",
"limit": 5,
"with_context": true,
"context_size": 1,
"full_document": false
},
"id": 1
}
query: 検索クエリ(必須)limit: 返す結果の数(デフォルト: 5)with_context: 前後のチャンクも取得するかどうか(デフォルト: true)context_size: 前後に取得するチャンク数(デフォルト: 1)full_document: ドキュメント全体を取得するかどうか(デフォルト: false)このツールは以下の機能により、より良い検索結果を提供します:
前後のチャンク取得機能:
with_contextパラメータで有効/無効を切り替え可能context_sizeパラメータで前後に取得するチャンク数を調整可能ドキュメント全文取得機能:
full_documentパラメータで有効/無効を切り替え可能結果の整形改善:
インデックス内のドキュメント数を取得します。
{
"jsonrpc": "2.0",
"method": "get_document_count",
"params": {},
"id": 2
}
ドキュメントファイルを data/source ディレクトリに配置します。サポートされるファイル形式は以下の通りです:
CLIコマンドを使用してドキュメントをインデックス化します:
# 初回は全件インデックス化
python -m src.cli index
# 以降は差分インデックス化で効率的に更新
python -m src.cli index -i
MCPサーバーを起動します:
uv run python -m src.main
searchツールを使用して検索を行います。
インデックス化したデータベースを別のPCで使用するには、以下の手順でバックアップと復元を行います。
単純に他のPCでRAG検索機能を使いたいだけなら、PostgreSQLデータベースのバックアップだけで十分です。ベクトル化されたデータはすべてデータベースに保存されているためです。
PostgreSQLデータベースをバックアップするには、Dockerコンテナ内でpg_dumpコマンドを使用します:
# Dockerコンテナ内でデータベースをバックアップ
docker exec -it postgres-pgvector pg_dump -U postgres -d ragdb -F c -f /tmp/ragdb_backup.dump
# バックアップファイルをコンテナからホストにコピー
docker cp postgres-pgvector:/tmp/ragdb_backup.dump ./ragdb_backup.dump
これにより、PostgreSQLデータベースのバックアップファイル(例:239MB)がカレントディレクトリに作成されます。
# Dockerを使用する場合
docker run --name postgres-pgvector -e POSTGRES_PASSWORD=password -p 5432:5432 -d pgvector/pgvector:pg17
# データベースを作成
docker exec -it postgres-pgvector psql -U postgres -c "CREATE DATABASE ragdb;"
# バックアップファイルをコンテナにコピー
docker cp ./ragdb_backup.dump postgres-pgvector:/tmp/ragdb_backup.dump
# コンテナ内でデータベースを復元
docker exec -it postgres-pgvector pg_restore -U postgres -d ragdb -c /tmp/ragdb_backup.dump
新しいPCでは、.envファイルのPostgreSQL接続情報が正しく設定されていることを確認してください。
python -m src.cli count
これにより、インデックス内のドキュメント数が表示されます。元のPCと同じ数が表示されれば、正常に復元されています。
将来的に新しいドキュメントを追加する予定がある場合や、差分インデックス化機能を使用したい場合は、以下の追加バックアップも行うと良いでしょう:
処理済みドキュメントディレクトリをバックアップします:
# 処理済みドキュメントディレクトリをZIPファイルにバックアップ
zip -r processed_data_backup.zip data/processed/
.envファイルをバックアップします:
# .envファイルをコピー
cp .env env_backup.txt
新しいPCには以下のソフトウェアがインストールされている必要があります:
PostgreSQLデータベースを上記の「最小限の復元手順」で復元します。
処理済みドキュメントを復元します:
# ZIPファイルを展開
unzip processed_data_backup.zip -d /path/to/mcp-rag-server/
# .envファイルを復元
cp env_backup.txt /path/to/mcp-rag-server/.env
必要に応じて、新しいPC環境に合わせて.envファイルの設定(特にPostgreSQL接続情報)を編集します。
python -m src.cli count
sentence-transformers、psycopg2-binaryなど)をインストールしておく必要があります。mcp-rag-server/
├── data/
│ ├── source/ # 原稿ファイル(階層構造対応)
│ │ ├── markdown/ # マークダウンファイル
│ │ ├── docs/ # ドキュメントファイル
│ │ └── slides/ # プレゼンテーションファイル
│ └── processed/ # 処理済みファイル(テキスト抽出済み)
│ └── file_registry.json # 処理済みファイルの情報(差分インデックス用)
├── docs/
│ └── design.md # 設計書
├── logs/ # ログファイル
├── src/
│ ├── __init__.py
│ ├── document_processor.py # ドキュメント処理モジュール
│ ├── embedding_generator.py # エンベディング生成モジュール
│ ├── example_tool.py # サンプルツールモジュール
│ ├── main.py # メインエントリーポイント
│ ├── mcp_server.py # MCPサーバーモジュール
│ ├── rag_service.py # RAGサービスモジュール
│ ├── rag_tools.py # RAGツールモジュール
│ └── vector_database.py # ベクトルデータベースモジュール
├── tests/
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_document_processor.py
│ ├── test_embedding_generator.py
│ ├── test_example_tool.py
│ ├── test_mcp_server.py
│ ├── test_rag_service.py
│ ├── test_rag_tools.py
│ └── test_vector_database.py
├── .env # 環境変数設定ファイル
├── .gitignore
├── LICENSE
├── pyproject.toml
└── README.md
このプロジェクトはMITライセンスの下で公開されています。詳細はLICENSEファイルを参照してください。
Claim this server with your GitHub account to request manual ownership verification.
Link to the catalog listing for MCP RAG Server: an MCP-compliant Python server with RAG retrieval from your README. This badge does not certify ownership, compatibility or security.
[](https://awesome-mcp.com/servers/mcp-rag-server)Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.
Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.
No reviewed package or image identity; download statistics are not listed yet.
Alternative and complementary servers in the same category

Store and retrieve entities, relations and observations in a persistent local knowledge graph.

Organize problem solving into revisable, branching thought steps through an MCP tool.

Query-aware context compression with an MCP plugin for coding agents, plus Python and HTTP interfaces for reducing the context sent to a language model.