LangGraph RAG MCP
Retrieval-Augmented Generation system serving LangGraph documentation through the Model Context Protocol, enabling semantic search and context-aware responses.
README
LangGraph RAG MCP
A Retrieval-Augmented Generation (RAG) system that serves LangGraph documentation through the Model Context Protocol (MCP).
Overview
This project builds a documentation retrieval system that:
- Collects and processes LangGraph documentation from the official website
- Creates a vector database from this documentation for semantic search
- Exposes this knowledge through the Model Context Protocol (MCP)
- Integrates with MCP-compatible hosts like VS Code, Cursor, Claude Desktop, or Windsurf
How It Works
1. Documentation Collection and Processing (Context)
- Recursively scrapes and cleans LangGraph documentation from multiple website URLs using
RecursiveUrlLoaderand BeautifulSoup. - Splits text into manageable chunks using
RecursiveCharacterTextSplitterwithtiktokenfor accurate token counting. - Embeds chunks into vector representations using
BAAI/bge-large-en-v1.5embeddings. - Stores vectors in an
SKLearnVectorStorefor efficient retrieval.
2. Retrieval System (Tool)
- Implements a retrieval function that finds the most relevant documentation chunks for a given query.
- Integrates this function with language models like Claude to provide context-aware responses.
- Returns formatted responses that include source attribution and relevant context.
3. MCP Server Integration
- Wraps the retrieval tool in an MCP server using the
fastmcplibrary. - Exposes the retrieval function as a tool that MCP-compatible hosts can use.
- Provides access to both the retrieval system and additional resources (like the full documentation file).
Requirements
- Python 3.10+
- Docker and Docker Compose (recommended)
- Anthropic API key (for Claude models)
Installation and Setup
You can run this project either with Docker (recommended) or in a local Python environment.
Using Docker (Recommended)
-
Clone this repository:
git clone https://github.com/yourusername/langraph-rag-mcp.git cd langraph-rag-mcp -
Set up your API keys in a
.envfile: Create a.envfile in the project root and add your Anthropic API key:echo "ANTHROPIC_API_KEY=your_api_key_here" > .envThe
docker-compose.ymlfile will automatically load this environment variable.
Local Environment (without Docker)
-
Clone this repository:
git clone https://github.com/yourusername/langraph-rag-mcp.git cd langraph-rag-mcp -
Create and activate a virtual environment:
conda create -n mcp python=3.13 conda activate mcp -
Install the required packages:
pip install -r requirements.txt -
Set up your API keys in a
.envfile:echo "ANTHROPIC_API_KEY=your_api_key_here" > .env
Usage
The process involves two main steps: first, generating the vector store, and second, running the MCP server.
Step 1: Generate the Vector Store
You only need to do this once, or whenever you want to update the documentation.
- Open and run the
rag-tool.ipynbnotebook in a Jupyter environment. - This will:
- Download the latest LangGraph documentation.
- Save the full documentation to
llms_full.txt. - Split the documents into chunks.
- Create and persist a vector store at
sklearn_vectorstore.parquet.
Step 2: Run the MCP Server
With Docker
The easiest way to run the server is using the provided shell script, which wraps Docker Compose.
bash run-mcp-docker.sh
This script will build the Docker image if it doesn't exist, start the container, and then execute the MCP server inside it, correctly handling standard I/O for MCP communication.
Without Docker
If you are not using Docker, you can run the MCP server directly in dev mode through the command:
mcp dev langgraph-mcp.py
Configuring MCP Hosts
To use this MCP server with a compatible editor, you need to configure it.
VS Code
- Open your VS Code
settings.jsonfile. (You can find it via the command palette:Preferences: Open User Settings (JSON)). - Add the following configuration to the file. Make sure to replace
<path-to-your-project>with the absolute path to thelangraph-rag-mcpdirectory on your machine.
"mcp.servers": [
{
"name": "langgraph-mcp",
"command": [
"/bin/bash",
"<path-to-your-project>/run-mcp-docker.sh"
],
"env": {
"ANTHROPIC_API_KEY": "<your-anthropic-api-key>"
}
}
]
If you are not using Docker, change the command to:
"command": [
"<path-to-your-conda-env>/bin/python",
"<path-to-your-project>/langgraph-mcp.py"
]
System Architecture
(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)
Resources
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。