A Model Context Protocol (MCP) server implementation for RAG (Retrieval-Augmented Generation) using Qdrant vector database with support for both Ollama and OpenAI embeddings.
git clone https://github.com/amornpan/py-mcp-qdrant-rag.git cd py-mcp-qdrant-rag2. Setup Conda Environment
# Grant permissions and run installation script chmod +x install_conda.sh ./install_conda.sh # Activate the environment conda activate mcp-rag-qdrant-1.0 # Install Ollama Python client pip install ollama # Pull the embedding model ollama pull nomic-embed-text # Get Python path (save this for later configuration) which python
# Create and activate environment conda create -n mcp-rag-qdrant-1.0 python=3.11 conda activate mcp-rag-qdrant-1.0 # Install required packages pip install ollama # Pull the embedding model ollama pull nomic-embed-text # Get Python path (save this for later configuration) where python3. Start Qdrant Vector Database
Using Docker:
docker run -p 6333:6333 -v $(pwd)/qdrant_storage:/qdrant/storage qdrant/qdrant
Or using Qdrant Cloud:
Locate your Claude Desktop configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/claude/claude_desktop_config.json
Add the following configuration:
{ "mcpServers": { "mcp-rag-qdrant-1.0": { "command": "/path/to/conda/envs/mcp-rag-qdrant-1.0/bin/python", "args": [ "/path/to/py-mcp-qdrant-rag/run.py", "--mode", "mcp" ], "env": { "QDRANT_URL": "http://localhost:6333", "EMBEDDING_PROVIDER": "ollama", "OLLAMA_URL": "http://localhost:11434" } } } }
Important: Replace /path/to/...
with the actual paths from your system.
After saving the configuration, completely restart Claude Desktop to load the MCP server.
Once configured, you can interact with the RAG system directly in Claude Desktop using natural language commands.
From URLs:
"Add documentation from https://docs.python.org/3/tutorial/"
"Index the content from https://github.com/user/repo/blob/main/README.md"
From Local Directories:
"Add all documents from /Users/username/Documents/project-docs"
"Index all files in C:\Projects\Documentation"
"Search for information about authentication methods"
"Find documentation about REST API endpoints"
"What does the documentation say about error handling?"
"Look up information on database configuration"
"List all documentation sources"
"Show me what documents are indexed"
"What sources are available in the knowledge base?"
Variable Description Default Required QDRANT_URL
Qdrant server URL http://localhost:6333
Yes EMBEDDING_PROVIDER
Embedding provider (ollama
or openai
) ollama
Yes OLLAMA_URL
Ollama server URL (if using Ollama) http://localhost:11434
If using Ollama OPENAI_API_KEY
OpenAI API key (if using OpenAI) - If using OpenAI COLLECTION_NAME
Qdrant collection name documents
No CHUNK_SIZE
Text chunk size for splitting 1000
No CHUNK_OVERLAP
Overlap between chunks 200
No EMBEDDING_MODEL
Model name for embeddings nomic-embed-text
(Ollama) or text-embedding-3-small
(OpenAI) No
To use OpenAI embeddings instead of Ollama, update your configuration:
{ "mcpServers": { "mcp-rag-qdrant-1.0": { "command": "/path/to/python", "args": ["/path/to/run.py", "--mode", "mcp"], "env": { "QDRANT_URL": "http://localhost:6333", "EMBEDDING_PROVIDER": "openai", "OPENAI_API_KEY": "sk-your-openai-api-key-here" } } } }
For Qdrant Cloud deployment:
{ "env": { "QDRANT_URL": "https://your-cluster.qdrant.io", "QDRANT_API_KEY": "your-qdrant-api-key", "EMBEDDING_PROVIDER": "ollama", "OLLAMA_URL": "http://localhost:11434" } }
The system automatically processes the following file types:
.txt
, .md
, .markdown
, .rst
.pdf
, .docx
, .doc
, .odt
.py
, .js
, .ts
, .java
, .cpp
, .c
, .h
, .go
, .rs
, .php
, .rb
, .swift
.json
, .yaml
, .yml
, .xml
, .csv
add_documentation(url: str) -> dict
Add documentation from a web URL to the vector database.
Parameters:
url
: The URL to fetch and indexReturns:
add_directory(path: str) -> dict
Recursively add all supported files from a directory.
Parameters:
path
: Directory path to scanReturns:
search_documentation(query: str, limit: int = 5) -> list
Search through stored documentation using semantic similarity.
Parameters:
query
: Search query textlimit
: Maximum number of results (default: 5)Returns:
List all documentation sources in the database.
Returns:
py-mcp-qdrant-rag/
├── run.py # Main entry point
├── mcp_server.py # MCP server implementation
├── rag_engine.py # Core RAG functionality
├── embeddings/
│ ├── base.py # Embedding provider interface
│ ├── ollama.py # Ollama embedding implementation
│ └── openai.py # OpenAI embedding implementation
├── document_loader.py # Document processing and chunking
├── requirements.txt # Python dependencies
├── install_conda.sh # Installation script (Unix)
└── tests/ # Unit tests
For development and testing without Claude Desktop:
conda activate mcp-rag-qdrant-1.0 python run.py --mode standalone
conda activate mcp-rag-qdrant-1.0 pytest tests/
To support additional file types, modify the SUPPORTED_EXTENSIONS
in document_loader.py
and implement the corresponding parser.
which python
docker ps
curl http://localhost:6333/health
ollama list
curl http://localhost:11434/api/tags
\\
or forward slashes /
Enable debug logging by adding to environment:
{ "env": { "LOG_LEVEL": "DEBUG", "QDRANT_URL": "http://localhost:6333", "EMBEDDING_PROVIDER": "ollama" } }
CHUNK_SIZE
for your document typesCHUNK_OVERLAP
for better context preservationlimit
parameter for more resultsWe welcome contributions! Please follow these steps:
git checkout -b feature/amazing-feature
git commit -m 'Add amazing feature'
git push origin feature/amazing-feature
This project is provided for educational purposes. See the LICENSE file for details.
For questions, issues, or feature requests:
Made with ❤️ by amornpan
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4