docrag
Provides RAG (Retrieval Augmented Generation) access to technical documentation through MCP, enabling LLMs to search and retrieve relevant documentation on-demand.
README
DocRAG - AI Documentation RAG System
A lightweight, installable Python package that provides RAG (Retrieval Augmented Generation) access to technical documentation through an MCP (Model Context Protocol) server. This enables LLMs to search and retrieve relevant documentation on-demand.
Features
- 🚀 Single pip-installable package with CLI and MCP server
- 📚 Project-based documentation collections (BrightSign, Venafi, Qumu, web frameworks)
- 🔍 Local vector database with efficient embedding using LanceDB
- 📥 Easy documentation ingestion from local files or scraped sources
- 🤖 Designed for use with Claude Code via MCP
Installation
Prerequisites
- Python 3.10+
- pipx (recommended) or pip
- git (for updates)
Recommended: Install globally with pipx
# Install globally with pipx in editable mode (keeps dependencies isolated)
pipx install -e /opt/claude-ops/doc-rag
# Verify installation
docrag --help
# Optional: Install Playwright browsers (for scraping)
pipx runpip docrag install playwright
pipx run --spec docrag playwright install chromium
Note: The -e flag installs in "editable" mode, which means changes to the source code are immediately reflected without reinstalling.
Alternative: Install from source (development)
# Clone or navigate to the project directory
cd /opt/claude-ops/doc-rag
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate
# Install in development mode
pip install -e ".[dev]"
# Install Playwright browsers (for scraping)
playwright install chromium
Updating DocRAG
Option 1: Using the Update Script (Recommended)
cd /opt/claude-ops/doc-rag
./update.sh
This script will:
- Pull latest changes from git
- Detect your installation method (pipx or pip)
- Reinstall only if necessary (non-editable installs)
- Handle editable installs automatically
Option 2: Using Make
cd /opt/claude-ops/doc-rag
make update
Option 3: Manual Update
For editable installs (installed with -e):
cd /opt/claude-ops/doc-rag
git pull origin main
# No reinstall needed - changes are already active!
For regular installs (installed without -e):
cd /opt/claude-ops/doc-rag
git pull origin main
pipx uninstall docrag && pipx install -e .
# or for pip: pip install -e . --force-reinstall
Verifying Updates
# Check git status
cd /opt/claude-ops/doc-rag
git log -1 --oneline
# Test the installation
docrag --version
docrag --help
Quick Start
1. Initialize DocRAG
docrag init
This creates the configuration directory at ~/.docrag/ with the following structure:
~/.docrag/
├── config.json # Global configuration
├── collections/ # Documentation collections
└── vectordb/ # LanceDB storage
2. Add a Documentation Collection
# Add documentation from a local directory
docrag add brightsign --source /path/to/brightsign/docs --description "BrightSign player documentation"
# Or add without source initially
docrag add venafi --description "Venafi TPP API documentation"
3. List Collections
docrag list
4. Search Documentation (CLI Testing)
# Search across all active collections
docrag search "how to initialize the player"
# Search a specific collection
docrag search "authentication methods" --collection venafi --limit 10
5. Start the MCP Server
docrag serve
The server will listen on stdio for connections from Claude Code.
CLI Commands
docrag init
Initialize DocRAG configuration directory.
docrag add <name>
Add a new documentation collection.
Options:
-s, --source PATH- Source directory containing documentation-d, --description TEXT- Description of the collection
Example:
docrag add qumu --source ~/docs/qumu --description "Qumu video platform docs"
docrag list
List all documentation collections with their status.
docrag update <name> <source>
Update an existing collection with new documents.
Example:
docrag update brightsign ~/docs/brightsign/updated
docrag remove <name>
Remove a documentation collection (with confirmation).
docrag search <query>
Search documentation from the CLI for testing.
Options:
-c, --collection TEXT- Specific collection to search-l, --limit INTEGER- Number of results (default: 5)
Example:
docrag search "websocket connection" --collection brightsign
docrag serve
Start the MCP server for Claude Code integration.
docrag scrape <url>
Scrape documentation from websites.
Options:
-o, --output PATH- Output directory (required)--smart, --use-crawl4ai- Use AI-powered Crawl4AI scraper (recommended)--no-llm- Disable LLM extraction (faster, still better than basic)--llm-provider TEXT- LLM provider (default: openai/gpt-4o-mini)--playwright- Use Playwright for dynamic content (basic scraper)--max-pages INTEGER- Maximum pages to scrape (default: 1000)
Examples:
# Basic scraping
docrag scrape https://docs.example.com --output ./docs
# Smart scraping with AI (recommended)
docrag scrape https://docs.example.com --output ./docs --smart
# Smart scraping without LLM (faster, no API key needed)
docrag scrape https://docs.example.com --output ./docs --smart --no-llm
# Limit pages
docrag scrape https://docs.example.com --output ./docs --max-pages 100
Smart Scraping Features:
- ✨ AI-powered content extraction
- 🎯 Automatically removes navigation and boilerplate
- 📊 Better handling of complex layouts
- 🧠 Semantic understanding of documentation structure
- ⚡ Faster and more accurate than basic scraping
To enable smart scraping:
# Install Crawl4AI
pipx inject docrag crawl4ai
# Optional: Set OpenAI API key for LLM-powered extraction
export OPENAI_API_KEY='your-key-here'
Using with Claude Code
1. Configure Claude Code MCP Settings
Add DocRAG to your Claude Code MCP configuration (~/.config/claude-code/mcp_settings.json or similar):
{
"mcpServers": {
"docrag": {
"command": "docrag",
"args": ["serve"],
"env": {}
}
}
}
If using the full path:
{
"mcpServers": {
"docrag": {
"command": "/home/claude-admin/.local/bin/docrag",
"args": ["serve"],
"env": {}
}
}
}
2. Restart Claude Code
After adding the configuration, restart Claude Code to load the MCP server.
3. Use in Claude Code
Once connected, Claude Code can use two tools:
search_docs: Search through indexed documentation collections
Query: "how to handle authentication in BrightSign"
Collection: (optional) "brightsign"
Limit: (optional) 5
list_collections: List all available documentation collections
Claude will automatically use these tools when working on projects that need documentation access.
Architecture
Core Components
- ConfigManager (
config.py) - Manages configuration and collection metadata - EmbeddingGenerator (
embeddings.py) - Generates embeddings using sentence-transformers - VectorDB (
vectordb.py) - LanceDB wrapper for vector storage and search - DocumentIndexer (
indexer.py) - Intelligent document chunking and indexing - DocRAGServer (
server.py) - MCP server implementation - CLI (
cli.py) - Command-line interface
Technical Stack
- MCP Framework: Official Anthropic MCP package
- Vector Database: LanceDB (lightweight, file-based, performant)
- Embeddings: sentence-transformers with all-MiniLM-L6-v2 model (384 dims, fast, local)
- Text Processing: langchain-text-splitters for intelligent chunking
- CLI: Click for user-friendly commands
- Web Scraping: Playwright + BeautifulSoup4 for scraping
Data Structure
~/.docrag/
├── config.json # Global configuration
│ └── {
│ "active_collections": ["brightsign", "venafi"],
│ "embedding_model": "sentence-transformers/all-MiniLM-L6-v2",
│ "chunk_size": 512,
│ "chunk_overlap": 50
│ }
├── collections/
│ ├── brightsign/
│ │ ├── metadata.json # Collection metadata
│ │ └── source_docs/ # Original documents
│ ├── venafi/
│ └── qumu/
└── vectordb/
└── lancedb/ # Vector storage (one table per collection)
Configuration
Global configuration is stored in ~/.docrag/config.json:
{
"active_collections": ["brightsign", "venafi"],
"embedding_model": "sentence-transformers/all-MiniLM-L6-v2",
"chunk_size": 512,
"chunk_overlap": 50
}
Collection metadata is stored in ~/.docrag/collections/<name>/metadata.json:
{
"name": "brightsign",
"source_type": "local",
"source_path": "/path/to/docs",
"created_at": "2025-10-28T10:00:00",
"updated_at": "2025-10-28T10:00:00",
"doc_count": 150,
"description": "BrightSign player documentation"
}
Development
Project Structure
docrag/
├── docrag/
│ ├── __init__.py
│ ├── cli.py # CLI commands
│ ├── server.py # MCP server
│ ├── indexer.py # Document indexing
│ ├── vectordb.py # Vector database
│ ├── embeddings.py # Embeddings
│ ├── config.py # Configuration
│ └── scrapers/ # Web scrapers
│ ├── __init__.py
│ ├── base.py
│ └── generic.py
├── tests/
├── pyproject.toml
├── README.md
└── DOCRAG_MVP_BUILD_GUIDE.md
Running Tests
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
Code Formatting
# Format with black
black docrag/
# Lint with ruff
ruff check docrag/
Troubleshooting
"DocRAG not initialized"
Run docrag init first to create the configuration directory.
"No collections found"
Add a collection with docrag add <name> --source <path>.
"Model download fails"
The first time you run DocRAG, it will download the sentence-transformers model (~100MB). Ensure you have internet connectivity.
"Playwright not installed"
If using scrapers, run playwright install chromium.
Future Enhancements
- [ ] Web scraper CLI commands
- [ ] Support for more file types (PDF, HTML, RST)
- [ ] Incremental indexing (only index changed files)
- [ ] Collection activation/deactivation
- [ ] Collection statistics and health checks
- [ ] Export/import collections
- [ ] Cloud sync for collections
- [ ] Advanced search filters
License
MIT
Author
Ryan - Built for homelab and Claude Code integration
推荐服务器
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 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。