A local project that combines Retrieval-Augmented Generation (RAG) with the Model Context Protocol (MCP) so you can:
- Upload documents (PDF, DOCX, TXT, MD, CSV) via a web GUI.
- Chat with your documents using an LLM powered by OpenRouter.
- Connect any MCP-compatible LLM (Claude Desktop, Cursor, Cline, etc.) to your personal knowledge base via the included MCP server.
┌─────────────────────────────────────────────┐
│ Gradio Web GUI │
│ Upload ▸ Manage ▸ Chat ▸ MCP Server Info │
└────────────────────┬────────────────────────┘
│
┌────────────▼────────────┐
│ RAG Pipeline │
│ document_processor.py │ ← text extraction + chunking
│ vector_store.py │ ← ChromaDB (local, persistent)
└────────────┬────────────┘
│
┌────────────▼────────────┐ ┌──────────────────────────┐
│ llm/openrouter.py │ │ mcp_server.py │
│ OpenRouter API │ │ MCP tools (stdio) │
│ openrouter/auto │ │ search / list / add / │
└─────────────────────────┘ │ delete documents │
└──────────────────────────┘
pip install -r requirements.txtcp .env.example .env
# Edit .env and set your OPEN_ROUTER_API_KEYpython main.py
# Open http://localhost:7860 in your browserIn a separate terminal:
python mcp_server.py| Tab | What you can do |
|---|---|
| 📤 Upload Documents | Upload PDF / DOCX / TXT / MD / CSV files; configure chunk size & overlap |
| 🗂️ Manage Documents | View all stored documents and delete individual ones |
| 💬 Chat | Ask questions answered with RAG context from your uploaded files |
| 🔌 MCP Server | Instructions for connecting the MCP server to your LLM |
The MCP server exposes your knowledge base as tools via the stdio transport.
| Tool | Description |
|---|---|
search_knowledge_base |
Find relevant chunks by query |
list_documents |
List all uploaded documents |
add_document_text |
Add raw text to the knowledge base |
delete_document |
Remove a document |
Add this to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"rag-knowledge-base": {
"command": "python",
"args": ["/absolute/path/to/RAGwithMCP/mcp_server.py"]
}
}
}mcp dev mcp_server.py| Variable | Default | Description |
|---|---|---|
OPEN_ROUTER_API_KEY |
(required) | Your OpenRouter API key |
OPENROUTER_MODEL |
openrouter/auto |
Model to use (e.g. openrouter/auto) |
CHROMA_DB_PATH |
./chroma_db |
Path to the ChromaDB persistent store |
PORT |
7860 |
Port for the Gradio web interface |
RAGwithMCP/
├── main.py # Entry point (Gradio GUI)
├── mcp_server.py # MCP server (stdio transport)
├── requirements.txt
├── .env.example
├── rag/
│ ├── document_processor.py # File reading + text chunking
│ └── vector_store.py # ChromaDB wrapper
├── llm/
│ └── openrouter.py # OpenRouter API client
└── gui/
└── app.py # Gradio interface