Py MCP Server with Qdrant RAG
Deploy an MCP server with Qdrant RAG to enable semantic search and document retrieval via local or cloud embeddings across Mac, Linux, and Windows.
npx -y @amornpan/py-mcp-qdrant-ragOverview
Py MCP Server with Qdrant RAG is a lightweight reference implementation that combines a Model Context Protocol (MCP) server with Qdrant vector search to enable Retrieval-Augmented Generation (RAG). It makes it simple to ingest documents, generate embeddings (locally or via cloud APIs), and run semantic search or document retrieval from Mac, Linux, or Windows environments.
This setup is useful for developers building knowledge-enabled assistants, semantic search endpoints, or RAG pipelines that need fast vector similarity search and flexible embedding backends. Qdrant provides a scalable vector database; the MCP server exposes a consistent API surface so models and tools can request context vectors and metadata for downstream use.
Features
- Semantic search backed by Qdrant vector store (local or cloud)
- Support for local embeddings (sentence-transformers) or cloud embeddings (OpenAI)
- Simple MCP-compatible HTTP API for retrieval and context assembly
- Platform-agnostic: runs on macOS, Linux, and Windows
- Docker examples for quick local Qdrant launch
- Configurable via environment variables and .env files
Installation / Configuration
Prerequisites:
- Python 3.10+ (or the version documented in the repo)
- Docker (optional, for running Qdrant locally)
- (Optional) OpenAI API key if using cloud embeddings
Clone the repo and create a virtual environment:
# .venv\Scripts\activate # Windows (PowerShell)
Install dependencies (either from requirements.txt or core packages):
# or
Run Qdrant locally with Docker (default port 6333):
Create a .env file (example):
# Qdrant
QDRANT_URL=http://localhost:6333
QDRANT_API_KEY=
# Collection settings
QDRANT_COLLECTION=documents
# Embedding provider: "local" or "openai"
EMBEDDING_PROVIDER=local
# If using OpenAI for embeddings
OPENAI_API_KEY=sk-...
# Server
MCP_HOST=0.0.0.0
MCP_PORT=8000
Start the MCP server (example using uvicorn):
Adjust the import path (app.main:app) to match the server module in the repository. The server will connect to Qdrant using QDRANT_URL and store/retrieve vectors from QDRANT_COLLECTION.
Available Resources
- GitHub repository: https://github.com/amornpan/py-mcp-qdrant-rag
- Qdrant docs: https://qdrant.tech/documentation/
- OpenAI embeddings: https://platform.openai.com/docs/guides/embeddings
- SentenceTransformers (local embeddings): https://www.sbert.net/
Environment variables (summary):
| Variable | Description | Example |
|---|---|---|
| QDRANT_URL | Qdrant HTTP endpoint | http://localhost:6333 |
| QDRANT_API_KEY | Qdrant API key for secure cloud instances | (blank) |
| QDRANT_COLLECTION | Collection name for storing vectors | documents |
| EMBEDDING_PROVIDER | Which embedding backend to use: local or openai | local |
| OPENAI_API_KEY | API key when EMBEDDING_PROVIDER=openai | sk-… |
| MCP_HOST, MCP_PORT | Host and port for the MCP server | 0.0.0.0, 8000 |
Quick Examples
- Upsert a document (pseudo-cURL; adapt to actual API endpoints in the repo):
The server will compute embeddings (local or OpenAI) and store them in Qdrant.
- Semantic search:
Response contains the top-k matching documents with similarity scores and metadata suitable for RAG context assembly.
- Use local embeddings (Python snippet example):
=
=
When EMBEDDING_PROVIDER=local, the MCP server will use a similar model under the hood.
Use Cases
- Knowledge-enabled chatbot: retrieve relevant documents from a company wiki to provide accurate answers, then pass retrieved context to a language model for generation.
- Semantic search portal: replace keyword search with vector search for better relevance and intent matching.
- Document clustering and filtering: use Qdrant similarity queries to group related content and build discovery UIs.
- Augment LLM prompts: dynamically assemble context passages (RAG) to reduce hallucination and improve factuality.
Concrete scenario:
- A customer support tool ingests product manuals into Qdrant.