Easy MCP RAG
An MCP server for RAG using Qdrant that automatically indexes documents from directories and generates search tools for each collection.
README
Easy MCP RAG 🚀
A high-performance Model Context Protocol (MCP) server for RAG using Qdrant. Built for UV/UVX with CPU/GPU support and HTTP transport.
✨ Features
- 🔍 Automatic Document Indexing - Scan directories and index all documents
- 📁 Smart Organization - Each subdirectory becomes its own searchable dataset
- 🛠️ Dynamic MCP Tools - Auto-generated tools for each collection
- 📄 Multi-Format Support - PDF, DOCX, CSV, XLSX, TXT, Markdown, and more
- ⚡ GPU Acceleration - Optional CUDA/MPS support for faster embeddings
- 🌐 HTTP Transport - Run as HTTP server or stdio
- 📦 UV/UVX Ready - Install and run with a single command
- 📊 Verbose Logging - Detailed query tracking and monitoring
🚀 Quick Start
Install with UVX (Recommended)
Run directly from GitHub without installation:
uvx --from git+https://github.com/yourusername/easy_mcp_rag.git easy_mcp_rag --data-dir ./documents
Install with UV
# Install from GitHub
uv pip install git+https://github.com/yourusername/easy_mcp_rag.git
# Or clone and install locally
git clone https://github.com/yourusername/easy_mcp_rag.git
cd easy_mcp_rag
uv pip install -e .
📋 Prerequisites
- Start Qdrant (using Docker):
docker run -p 6333:6333 qdrant/qdrant
- Prepare your documents:
documents/
├── legal_docs/
│ ├── contract.pdf
│ └── terms.docx
├── research/
│ ├── paper1.pdf
│ └── notes.txt
└── data/
└── analysis.csv
💻 Usage
Basic Usage (stdio)
# With UVX
uvx --from git+https://github.com/yourusername/easy_mcp_rag.git easy_mcp_rag --data-dir ./documents
# With UV
uv run easy_mcp_rag --data-dir ./documents
# After installation
easy_mcp_rag --data-dir ./documents
HTTP Mode
easy_mcp_rag --data-dir ./documents --transport http --http-port 8000
GPU Acceleration
# Auto-detect GPU
easy_mcp_rag --data-dir ./documents --device auto
# Force CUDA (NVIDIA GPU)
easy_mcp_rag --data-dir ./documents --device cuda
# Force MPS (Apple Silicon)
easy_mcp_rag --data-dir ./documents --device mps
# Force CPU
easy_mcp_rag --data-dir ./documents --device cpu
Advanced Configuration
easy_mcp_rag \
--data-dir ./documents \
--qdrant-host localhost \
--qdrant-port 6333 \
--device cuda \
--embedding-model all-mpnet-base-v2 \
--chunk-size 1024 \
--chunk-overlap 100 \
--top-k 10 \
--batch-size 64 \
--verbose \
--force-reindex
🔧 Configuration Options
| Flag | Description | Default |
|---|---|---|
--data-dir |
Directory with document subdirectories | Required |
--qdrant-host |
Qdrant server host | localhost |
--qdrant-port |
Qdrant server port | 6333 |
--device |
Device: auto, cpu, cuda, mps | auto |
--transport |
Transport type: stdio, http | stdio |
--http-host |
HTTP server host | 0.0.0.0 |
--http-port |
HTTP server port | 8000 |
--embedding-model |
Sentence transformer model | all-MiniLM-L6-v2 |
--chunk-size |
Text chunk size (chars) | 512 |
--chunk-overlap |
Chunk overlap (chars) | 50 |
--top-k |
Results per search | 5 |
--batch-size |
Embedding batch size | 32 |
--verbose |
Enable verbose logging | False |
--log-level |
Log level | INFO |
--force-reindex |
Force reindex all docs | False |
🎯 MCP Client Configuration
Claude Desktop / Cline / Other MCP Clients
Add to your MCP client config:
{
"mcpServers": {
"rag-server": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/yourusername/easy_mcp_rag.git",
"easy_mcp_rag",
"--data-dir",
"/path/to/your/documents",
"--device",
"auto",
"--verbose"
]
}
}
}
With HTTP Transport
{
"mcpServers": {
"rag-server": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/yourusername/easy_mcp_rag.git",
"easy_mcp_rag",
"--data-dir",
"/path/to/your/documents",
"--transport",
"http",
"--http-port",
"8000"
]
}
}
}
🛠️ How It Works
- Scan - Discovers all subdirectories in your data directory
- Load - Extracts text from all supported file types
- Chunk - Splits documents into overlapping chunks
- Embed - Generates vector embeddings (CPU or GPU)
- Index - Stores in Qdrant (one collection per subdirectory)
- Serve - Creates MCP tools for each collection
Example
documents/
├── legal_docs/ → Creates "legal_docs_search" tool
├── research/ → Creates "research_search" tool
└── data/ → Creates "data_search" tool
📄 Supported File Types
| Category | Extensions |
|---|---|
| Text | .txt, .md, .py, .js, .json, .xml, .html, .css |
.pdf |
|
| Word | .docx, .doc |
| Spreadsheet | .csv, .xlsx, .xls |
🎨 Embedding Models
Choose based on your needs:
| Model | Dimensions | Speed | Quality | Use Case |
|---|---|---|---|---|
all-MiniLM-L6-v2 |
384 | ⚡⚡⚡ | Good | Default, fast |
all-MiniLM-L12-v2 |
384 | ⚡⚡ | Better | Balanced |
all-mpnet-base-v2 |
768 | ⚡ | Best | Quality |
🐛 Troubleshooting
Qdrant Connection Failed
# Check if Qdrant is running
curl http://localhost:6333
# Start Qdrant
docker run -p 6333:6333 qdrant/qdrant
GPU Not Detected
# Check PyTorch GPU support
python -c "import torch; print(torch.cuda.is_available())"
# Install with GPU support
uv pip install -e ".[gpu]"
Out of Memory
# Use smaller model
--embedding-model all-MiniLM-L6-v2
# Reduce batch size
--batch-size 16
# Use CPU
--device cpu
📊 Logging
Enable verbose logging to see detailed information:
easy_mcp_rag --data-dir ./documents --verbose
Output includes:
- ✅ Tool access events
- 🔍 Query details
- 📈 Result counts
- 🎯 Relevance scores
- 📁 Source files
Example:
2024-01-20 10:30:15 - easy_mcp_rag.server - INFO - Tool accessed: legal_docs_search
2024-01-20 10:30:15 - easy_mcp_rag.server - INFO - Query: contract terms
2024-01-20 10:30:15 - easy_mcp_rag.server - INFO - Results returned: 5
2024-01-20 10:30:15 - easy_mcp_rag.server - DEBUG - Result 1: score=0.8542
🔐 Security Notes
- HTTP mode exposes the server on the network
- Use
--http-host 127.0.0.1for local-only access - Consider authentication for production deployments
📝 Development
# Clone repository
git clone https://github.com/yourusername/easy_mcp_rag.git
cd easy_mcp_rag
# Install with dev dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Format code
black src/
# Lint
ruff src/
🤝 Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
📜 License
MIT License - see LICENSE file
🙏 Credits
Built with:
- MCP - Model Context Protocol
- Qdrant - Vector database
- Sentence Transformers - Embeddings
- UV - Package manager
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器