rag-blob-mcp
RAG Blob MCP
Azure Blob Storage に保存されたドキュメントライブラリへの検索アクセスを RAG エージェントに提供する Model Context Protocol (MCP) サーバーと、ドキュメントのアップロードおよびチャットを行うための Streamlit アプリです。
MCP サーバー — Streamable HTTP 上の FastMCP。Azure Blob Storage へのすべてのアクセスを所有し、4 つのツールと 3 つのプロンプトテンプレートを公開します。起動のたびに Blob Storage から再構築されるインメモリベクトルインデックス(OpenAI 埋め込み)を保持します。
Streamlit アプリ — ライブラリタブ(ドキュメントのアップロード / 一覧表示 / 削除)とチャットタブ(サーバーの検索ツールを呼び出す LangGraph ReAct エージェントが質問に回答)を提供します。
クイックスタート
1. 前提条件
Python 3.11 以上(3.13 で開発)
Blob コンテナーを持つ Azure ストレージアカウント(お持ちでない場合は、下の Azure のセットアップ を参照)
OpenAI API キー
2. インストール
リポジトリのルートから:
python -m venv .venv
.venv\Scripts\activate # Windows
pip install -r requirements.txt3. 設定
.env.example(リポジトリのルートにある)を .env にコピーし、値を入力します:
OPENAI_API_KEY=sk-...
AZURE_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=core.windows.net
AZURE_STORAGE_CONTAINER_NAME=rag-documentsその他(OPENAI_MODEL、OPENAI_EMBEDDING_MODEL、MCP_SERVER_HOST/PORT/URL)には動作するデフォルト値があります — 設定 を参照してください。
4. 実行
2 つのプロセス、2 つのターミナル。どちらもリポジトリのルートから:
# Terminal 1 — MCP server
python server/mcp_server.py# Terminal 2 — Streamlit app
streamlit run app/streamlit_app.pyhttp://localhost:8501 を開きます。ライブラリ タブで PDF/DOCX/TXT/MD ファイルをアップロードし、チャット タブでそのファイルについて質問します。
Related MCP server: Legal MCP Server
Azure のセットアップ
ストレージアカウントをまだお持ちでない場合:
Azure Portal → リソースの作成 → ストレージアカウント。Standard パフォーマンス、LRS 冗長性で個人利用には十分です。
新しいアカウントで: データストレージ → コンテナー → + コンテナー。名前を付け(例:
rag-documents)、アクセスレベルは Private にします。セキュリティとネットワーク → アクセスキー → キーの表示 で接続文字列をコピーします。
それを
.envのAZURE_STORAGE_CONNECTION_STRINGに貼り付け、AZURE_STORAGE_CONTAINER_NAMEには選択したコンテナー名を設定します。
プロジェクト構成
.
├── server/
│ ├── mcp_server.py # FastMCP server: tools, prompts, index rebuild, __main__ entrypoint
│ ├── blob_store.py # Azure Blob Storage wrapper
│ ├── indexing.py # text extraction (pdf/docx/txt/md) + chunking
│ ├── vector_index.py # in-memory vector store wrapper
│ └── test_*.py # automated tests (pytest)
├── agent/
│ └── rag_agent.py # LangGraph ReAct agent used by the Chat tab
├── app/
│ ├── mcp_client.py # direct MCP tool-call helpers used by the Library tab
│ └── streamlit_app.py # the UI
├── scripts/
│ └── smoke_test_server.py # manual end-to-end smoke test against a running server
├── docs_build/ # scripts that generate PROJECT.docx / PROJECT.pdf
└── pytest.ini設定
すべての変数はリポジトリのルートにある .env にあります:
変数 | デフォルト | 目的 |
| — (必須) | チャットモデル + 埋め込み |
|
| RAG エージェント用のチャットモデル |
|
| ベクトルインデックス用の埋め込みモデル |
| — (必須) | Blob Storage アクセス |
| — (必須) | ドキュメントが置かれているコンテナー |
|
| MCP サーバーがバインドするインターフェース |
|
| MCP サーバーがバインドするポート |
|
| Streamlit アプリ / エージェントが接続する URL — ポートを変更した場合はこれも更新してください |
使用方法
ライブラリタブ — PDF/DOCX/TXT/MD ファイルをアップロードします(200MB 制限、Streamlit による設定)。各アップロードはチャンク化され、埋め込まれ、検索インデックスに追加されます。ドキュメント一覧には indexed / failed / pending のステータスとチャンク数が表示されます。削除すると、Blob Storage とインデックスの両方からドキュメントが削除されます。
チャットタブ — 平易な英語で質問します。エージェントは検索ツールを呼び出すタイミングを決定し、関連するチャンクを取得し、ソースドキュメントをファイル名で引用して回答します。ライブラリが空または無関係な場合は、推測せずにその旨を伝えます。
テスト
pytest server/ -v29 のテストが、テキスト抽出 / チャンク化、ベクトルインデックス、Azure Blob Storage ラッパー(モック)、および 4 つの MCP ツール + プロンプト(fastmcp.Client をプロセス内で使用し、フェイクを使用 — 実際の Azure / OpenAI 呼び出しなし)をカバーしています。Streamlit UI やライブのエージェント / サーバー配線の自動カバレッジはありません。実際の実行中サーバーに対する手動スモークテストについては、scripts/smoke_test_server.py を参照してください。
既知の制限事項
インメモリインデックス、永続化なし。 サーバーを再起動するたびに、コンテナー内のすべてのドキュメントを再ダウンロード、再抽出、再埋め込みします。小規模な個人ライブラリには問題ありませんが、ライブラリが大きくなるにつれて実際の OpenAI API 呼び出しと起動時間がかかります。
シングルユーザー、ローカルのみ。 認証なし、同時書き込みの安全性なし、どこにもデプロイされていません。
アプリを機能させるには、両方のプロセス(MCP サーバー、Streamlit アプリ)が実行されている必要があります — 詳細は プロジェクト全体のドキュメント を参照してください。
全体像(アーキテクチャ、設計上の決定、既知のバグ、次のステップ)については、PROJECT.md を参照してください(PROJECT.docx / PROJECT.pdf としても入手可能)。
This server cannot be deployed
Maintenance
Related MCP Connectors
Ingest, manage, and retrieve documents for RAG-powered AI applications
Document hosting and encrypted agent memory with multi-tenant persistence.
LLM Orchestration Agent (Langgraph)
Artifact store for AI agents — read, write, and search files by path; share by rendered URL.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI systems to perform full-text and semantic search operations over structured/unstructured data in Azure Cognitive Search, with capabilities for document indexing and management through natural language.325 npm4ISC
- FlicenseNot gradedqualityDmaintenanceEnables legal document analysis using Azure Blob Storage and Anthropic Claude API with streaming capabilities, prompt library management, and document retrieval for PDF files.-
- AlicenseNot gradedqualityDmaintenanceEnables Claude to search and retrieve documents from Azure AI Search indexes with intelligent summarization and analysis using LangGraph workflows and optional Google Gemini integration.MIT
- FlicenseNot gradedqualityDmaintenanceEnables listing image blobs from Azure Blob Storage and generating descriptions using Azure OpenAI's gpt-4o vision model.6-