langgraph-mcp
LangGraph RAG MCP
LangGraph のドキュメントを Model Context Protocol(MCP)を通じて提供する、検索拡張生成(RAG)システムです。
概要
このプロジェクトは、以下を行うドキュメント検索システムを構築します。
公式ウェブサイトから LangGraph ドキュメントを収集・処理します。
このドキュメントからセマンティック検索用のベクトルデータベースを作成します。
この知識を Model Context Protocol(MCP)を通じて公開します。
VS Code、Cursor、Claude Desktop、Windsurf などの MCP 互換ホストと統合します。
Related MCP server: groq-docs-mcp
動作の仕組み
1. ドキュメントの収集と処理(コンテキスト)
RecursiveUrlLoaderと BeautifulSoup を使用して、複数のウェブサイト URL から LangGraph ドキュメントを再帰的にスクレイピングおよびクレンジングします。テキストを分割します。
RecursiveCharacterTextSplitterとtiktokenを使用して、正確なトークン数を計算しながら管理可能なチャンクに分割します。チャンクをベクトル表現に埋め込み、
BAAI/bge-large-en-v1.5の埋め込みを使用します。ベクトルを
SKLearnVectorStoreに保存し、効率的な検索を実現します。
2. 検索システム(ツール)
指定されたクエリに対して最も関連性の高いドキュメントチャンクを検索する関数を実装します。
この関数を Claude などの言語モデルと統合し、コンテキストに即した応答を提供します。
ソースの帰属と関連コンテキストを含むフォーマット済みの応答を返します。
3. MCP サーバー統合
fastmcpライブラリを使用して検索ツールを MCP サーバーとしてラップします。検索関数を、MCP 互換ホストが使用できるツールとして公開します。
検索システムと追加リソース(完全なドキュメントファイルなど)の両方へのアクセスを提供します。
要件
Python 3.10+
Docker および Docker Compose(推奨)
Anthropic API キー(Claude モデル用)
インストールとセットアップ
このプロジェクトは、Docker(推奨)またはローカル Python 環境のどちらでも実行できます。
Docker を使用する場合(推奨)
このリポジトリをクローンします。
git clone https://github.com/yourusername/langraph-rag-mcp.git cd langraph-rag-mcp.envファイルに API キーを設定します。.envファイルをプロジェクトルートに作成し、Anthropic API キーを追加してください。echo "ANTHROPIC_API_KEY=your_api_key_here" > .envdocker-compose.ymlファイルはこの環境変数を自動的に読み込みます。
ローカル環境(Docker を使用しない場合)
このリポジトリをクローンします。
git clone https://github.com/yourusername/langraph-rag-mcp.git cd langraph-rag-mcp仮想環境を作成して有効化します。
conda create -n mcp python=3.13 conda activate mcp必要なパッケージをインストールします。
pip install -r requirements.txt.envファイルに API キーを設定します。echo "ANTHROPIC_API_KEY=your_api_key_here" > .env
使用方法
このプロセスは、最初にベクトルストアを生成し、次に MCP サーバーを実行するという2つの主要なステップで構成されます。
ステップ 1: ベクトルストアを生成する
これは、初回のみ、またはドキュメントを更新したいときに行うだけです。
Jupyter 環境で
rag-tool.ipynbノートブックを開いて実行します。これにより次の処理が行われます。
最新の LangGraph ドキュメントをダウンロードします。
ドキュメント全体を
llms_full.txtに保存します。ドキュメントをチャンクに分割します。
sklearn_vectorstore.parquetにベクトルストアを作成して永続化します。
ステップ 2: MCP サーバーを実行する
Docker を使用する場合
サーバーを実行する最も簡単な方法は、Docker Compose をラップした付属のシェルスクリプトを使用することです。
bash run-mcp-docker.shこのスクリプトは、Docker イメージが存在しない場合はビルドし、コンテナを起動して MCP サーバーをその中で実行します。MCP 通信のための標準入出力を正しく処理します。
Docker を使用しない場合
Docker を使用しない場合は、以下のコマンドで MCP サーバーを dev モードで直接実行できます。
mcp dev langgraph-mcp.pyMCP ホストの設定
この MCP サーバーを互換性のあるエディタで使用するには、設定を行う必要があります。
VS Code
VS Code の
settings.jsonファイルを開きます。(コマンドパレットからPreferences: Open User Settings (JSON)で見つけられます。)以下の設定をファイルに追加してください。
<path-to-your-project>は、お使いのマシン上のlangraph-rag-mcpディレクトリへの絶対パスに必ず置き換えてください。
"mcp.servers": [
{
"name": "langgraph-mcp",
"command": [
"/bin/bash",
"<path-to-your-project>/run-mcp-docker.sh"
],
"env": {
"ANTHROPIC_API_KEY": "<your-anthropic-api-key>"
}
}
]Docker を使用しない場合は、command を次のように変更します。
"command": [
"<path-to-your-conda-env>/bin/python",
"<path-to-your-project>/langgraph-mcp.py"
]システム構成
(Phase 1: Data Ingestion - Performed once on Host Machine)
┌─────────────┐ ┌──────────────────┐ ┌───────────────────────────────┐
│ LangGraph │ │ Jupyter Notebook │ │ Vector Store & Full Docs │
│ Docs (Web) │───▶ │ (rag-tool.ipynb) │───▶ │ (.parquet & .txt files) │
└─────────────┘ └──────────────────┘ └───────────────────────────────┘
(Phase 2: Live RAG System - Request/Response Flow)
┌──────────────┐ ┌─────────────┐
│ VS Code │ │ .env file │
│(User Interface)│ │ (API KEY) │
└──────┬───────┘ └──────┬──────┘
│ 1. User Query │ (provides)
▼ │
┌──────┴───────────────────────────────────────────┴───────────────────────────────┐
│ Host Machine Boundary │
│ │
│ ┌────────────────────┐ ┌─────────────────────────────────────────┐ │
│ │ run-mcp-docker.sh │ 2. Execs │ 🐳 Docker Container │ │
│ │ (Entrypoint Script)│────▶ │ │ │
│ └────────────────────┘ │ ┌───────────────────────────────────┐ │ │
│ │ │ 🐍 Python MCP Server │ │ │
│ ▲ ◀─┼──│ (langgraph-mcp.py) │ │ │
│ │ 7. Final Response │ └───────────────┬───────────────────┘ │ │
│ │ │ │ 3. Reads Data From │ │
│ └───────────────────────────────│──────────────────│─────────────────────┘ │
│ │ │ │
│ │ ▼ │
│ │ ┌───────────────────────────────────┐ │
│ (files mounted from Host) ············ │ Mounted Vector Store & Docs │ │
│ │ └───────────────────────────────────┘ │
│ └─────────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────────────────────────┘
│ 4. API Call
│ (sends augmented prompt)
▼
┌────────────────────┐
│ ☁️ Anthropic API │
│ (Claude LLM) │
└──────────┬─────────┘
│ 5. Generation
│
◀························
6. Returns Response
(to MCP Server)リソース
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for langchain documentation, generated by doc2mcp.
Agentic search over your Dewey document collections from any MCP-compatible client.
Cloud or self-hosted knowledge for AI agents: hybrid search, reranking, GraphRAG, scoped MCP tools.
Query any docs site via MCP. Submit a URL, ask questions, get cited answers.
Related MCP Servers
- FlicenseBqualityCmaintenanceRetrieval-Augmented Generation system serving LangGraph documentation through the Model Context Protocol, enabling semantic search and context-aware responses.216-
- AlicenseNot gradedqualityDmaintenanceEnables users to search Groq's API documentation using natural language queries through an MCP-compatible interface.MIT
- FlicenseNot gradedqualityCmaintenanceProvides MCP-compatible hosts with retrieval-augmented access to LangGraph documentation, enabling Claude and other assistants to answer questions with relevant, source-attributed context.-
- FlicenseNot gradedqualityCmaintenanceEnables retrieval-augmented question answering over LangGraph documentation, allowing MCP-compatible hosts to query a semantic vector store and receive context-aware responses with source attribution.-