Langgraph RAG MCP
This repo shows how to build a retrieval-augmented generation (RAG) System using LangGraph documentation and then expose it as a tool using the Model Context Protocol (MCP).
Installation
npx langgraph-rag-mcpAsk AI about Langgraph RAG MCP
Powered by Claude Β· Grounded in docs
I know everything about Langgraph RAG MCP. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
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)
