
Simple MCP Server for RAG
概览
A MCP server built with FastMCP 1 and ChromaDB 2 that provides MCP (Model Context Protocol) tools for ingesting documents into a local vector database and retrieving relevant information based on queries. - : Search for relevant documents using semantic similarity - : View all files currently stored in the database - : Reingest all files from the data directory (useful to reindex contents when new files are added) - : Get comprehensive system information including server status, database configuration, data directory status, and environment variables - : Generate structured prompts for analyzing documents on specific topics The server supports flexible configuration for both data and database directories through environment variables: 1. LLAMA_RAG_DATA_DIR environment variable (highest priority) 2. ./data in current working directory (workspace-relative) 3.
README
以下为原文 README 节选,完整内容请查看原文。
RAG MCP Server
A Retrieval Augmented Generation (RAG) MCP server built with FastMCP 1 and ChromaDB 2 that provides MCP (Model Context Protocol) tools for ingesting documents into a local vector database and retrieving relevant information based on queries.
Features
🔧 Tools
query_documents: Search for relevant documents using semantic similaritylist_ingested_files: View all files currently stored in the databasereingest_data_directory: Reingest all files from the data directory (useful to reindex contents when new files are added)get_rag_status: Get comprehensive system information including server status, database configuration, data directory status, and environment variables
📊 Resources
- None currently available
💬 Prompts
rag_analysis_prompt: Generate structured prompts for analyzing documents on specific topics
Quick Start
1. Installation
# Install dependencies
pip install -r requirements.txt
# Or install manually
pip install fastmcp chromadb sentence-transformers
2. Run the Server
# Start the MCP server
python rag_server.py
# Or use FastMCP CLI for development with inspector
fastmcp dev rag_server.py
3. Test the Server
# Run the test suite
python test_rag_server.py
Directory Configuration
The server supports flexible configuration for both data and database directories through environment variables:
Data Directory Configuration:
Priority Order:
LLAMA_RAG_DATA_DIRenvironment variable (highest priority)./datain current working directory (workspace-relative)- Error: If neither is found, the server will log an error and skip auto-ingestion
Important: Unlike the database directory, the data directory requires explicit configuration. If no data directory is found, the server will:
- Log a clear error message with setup instructions
- Skip auto-ingestion (server will still start successfully)
- Require manual configuration before documents can be ingested
Database Directory Configuration:
Priority Order:
LLAMA_RAG_DB_DIRenvironment variable (highest priority)~/.local/share/rag-server(XDG Base Directory standard)./chromarelative to current working directory (fallback)
Usage Examples:
# Using environment variable (recommended)
export LLAMA_RAG_DATA_DIR=/path/to/your/documents
python rag_server.py
# Using current directory data folder
mkdir data
cp your_documents/* data/
python rag_server.py
# Error case - no configuration
# Server starts but logs: "No data directory found. Please either..."
python rag_server.py
# Use custom database directory only
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"rag-server": {
"command": "python",
"args": ["/path/to/your/rag_server.py"],
"cwd": "/path/to/your/mcp-rag"
}
}
}