Spaces:
Running
Running
Add Space config and hackathon metadata
Browse files
README.md
CHANGED
|
@@ -1,220 +1,37 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
- **Multiple Vector Stores**: Qdrant (default) or ChromaDB
|
| 11 |
-
- **Configurable**: All settings via environment variables
|
| 12 |
-
- **Docker Ready**: One-command setup with docker-compose
|
| 13 |
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
| 19 |
-
docker compose up -d qdrant-service
|
| 20 |
-
```
|
| 21 |
|
| 22 |
-
|
|
|
|
| 23 |
|
| 24 |
-
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
{
|
| 28 |
-
"mcpServers": {
|
| 29 |
-
"rag-mcp": {
|
| 30 |
-
"command": "uvx",
|
| 31 |
-
"args": ["--from", "/path/to/Rag-MCP", "rag-mcp-qdrant"],
|
| 32 |
-
"env": {
|
| 33 |
-
"MODEL_NAME": "jinaai/jina-embeddings-v2-base-code",
|
| 34 |
-
"MODEL_DEVICE": "cpu",
|
| 35 |
-
"QDRANT_HOST": "localhost",
|
| 36 |
-
"QDRANT_PORT": "6333"
|
| 37 |
-
}
|
| 38 |
-
}
|
| 39 |
-
}
|
| 40 |
-
}
|
| 41 |
-
```
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
### 3. Use the Tools
|
| 46 |
-
|
| 47 |
-
- **Ingest**: `ingest_documents(collection="docs", documents=[{"text": "..."}])`
|
| 48 |
-
- **Search**: `search(collection="docs", query="find this", top_k=5)`
|
| 49 |
-
- **Get Chunk**: `get_chunk(collection="docs", chunk_id="...")`
|
| 50 |
-
- **List Docs**: `get_list(collection="docs")`
|
| 51 |
-
- **Delete**: `delete(collection="docs", doc_id="...")`
|
| 52 |
-
|
| 53 |
-
## Installation
|
| 54 |
-
|
| 55 |
-
### Method 1: uvx (Recommended)
|
| 56 |
-
|
| 57 |
-
```bash
|
| 58 |
-
uvx --from /path/to/Rag-MCP rag-mcp-qdrant
|
| 59 |
-
```
|
| 60 |
-
|
| 61 |
-
First run downloads ~800MB of dependencies and may take 2-3 minutes.
|
| 62 |
-
|
| 63 |
-
**Pre-install to avoid timeout:**
|
| 64 |
-
```bash
|
| 65 |
-
uvx --from /path/to/Rag-MCP rag-mcp-qdrant --help
|
| 66 |
-
```
|
| 67 |
-
|
| 68 |
-
### Method 2: pip
|
| 69 |
-
|
| 70 |
-
```bash
|
| 71 |
-
python3 -m venv .venv
|
| 72 |
-
source .venv/bin/activate
|
| 73 |
-
pip install torch --index-url https://download.pytorch.org/whl/cpu
|
| 74 |
-
pip install -e .
|
| 75 |
-
```
|
| 76 |
-
|
| 77 |
-
Then use this MCP config:
|
| 78 |
-
```json
|
| 79 |
-
{
|
| 80 |
-
"mcpServers": {
|
| 81 |
-
"rag-mcp": {
|
| 82 |
-
"command": "/path/to/Rag-MCP/.venv/bin/rag-mcp-qdrant",
|
| 83 |
-
"args": [],
|
| 84 |
-
"env": {
|
| 85 |
-
"QDRANT_HOST": "localhost"
|
| 86 |
-
}
|
| 87 |
-
}
|
| 88 |
-
}
|
| 89 |
-
}
|
| 90 |
-
```
|
| 91 |
-
|
| 92 |
-
### Method 3: Docker
|
| 93 |
-
|
| 94 |
-
```bash
|
| 95 |
-
docker compose up -d qdrant-service
|
| 96 |
-
docker compose run --rm mcp
|
| 97 |
-
```
|
| 98 |
-
|
| 99 |
-
## Environment Variables
|
| 100 |
-
|
| 101 |
-
| Variable | Default | Description |
|
| 102 |
-
|----------|---------|-------------|
|
| 103 |
-
| `MODEL_NAME` | `jinaai/jina-embeddings-v2-base-code` | HuggingFace embedding model |
|
| 104 |
-
| `MODEL_DEVICE` | `cpu` | Device: `cpu`, `cuda`, `mps` |
|
| 105 |
-
| `VECTOR_STORE` | `qdrant` | Backend: `qdrant` or `chroma` |
|
| 106 |
-
| `QDRANT_HOST` | `localhost` | Qdrant server host |
|
| 107 |
-
| `QDRANT_PORT` | `6333` | Qdrant server port |
|
| 108 |
-
| `QDRANT_HTTPS` | `false` | Use HTTPS |
|
| 109 |
-
| `QDRANT_API_KEY` | `None` | API key for Qdrant Cloud |
|
| 110 |
-
| `CHROMA_PERSIST_DIRECTORY` | `./chroma_data` | ChromaDB storage path |
|
| 111 |
-
| `COLLECTION_PREFIX` | `` | Prefix for collection names |
|
| 112 |
-
| `CHUNK_SIZE` | `500` | Text chunk size |
|
| 113 |
-
| `CHUNK_OVERLAP` | `50` | Overlap between chunks |
|
| 114 |
-
|
| 115 |
-
## MCP Client Configuration
|
| 116 |
-
|
| 117 |
-
### LM Studio
|
| 118 |
-
|
| 119 |
-
File: Settings → MCP Servers
|
| 120 |
-
|
| 121 |
-
```json
|
| 122 |
-
{
|
| 123 |
-
"mcpServers": {
|
| 124 |
-
"rag-mcp": {
|
| 125 |
-
"command": "uv",
|
| 126 |
-
"args": ["run", "--directory", "/path/to/Rag-MCP", "rag-mcp-qdrant"],
|
| 127 |
-
"env": {
|
| 128 |
-
"MODEL_DEVICE": "cpu",
|
| 129 |
-
"QDRANT_HOST": "localhost",
|
| 130 |
-
"QDRANT_PORT": "6333"
|
| 131 |
-
}
|
| 132 |
-
}
|
| 133 |
-
}
|
| 134 |
-
}
|
| 135 |
-
```
|
| 136 |
-
|
| 137 |
-
### Claude Desktop (macOS)
|
| 138 |
-
|
| 139 |
-
File: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
| 140 |
-
|
| 141 |
-
```json
|
| 142 |
-
{
|
| 143 |
-
"mcpServers": {
|
| 144 |
-
"rag-mcp": {
|
| 145 |
-
"command": "uvx",
|
| 146 |
-
"args": ["--from", "/path/to/Rag-MCP", "rag-mcp-qdrant"],
|
| 147 |
-
"env": {
|
| 148 |
-
"MODEL_DEVICE": "cpu",
|
| 149 |
-
"QDRANT_HOST": "localhost"
|
| 150 |
-
}
|
| 151 |
-
}
|
| 152 |
-
}
|
| 153 |
-
}
|
| 154 |
-
```
|
| 155 |
-
|
| 156 |
-
### Claude Desktop (Windows)
|
| 157 |
-
|
| 158 |
-
File: `%APPDATA%\Claude\claude_desktop_config.json`
|
| 159 |
-
|
| 160 |
-
Same configuration as macOS.
|
| 161 |
-
|
| 162 |
-
## Usage Examples
|
| 163 |
-
|
| 164 |
-
### Python API
|
| 165 |
-
|
| 166 |
-
```python
|
| 167 |
-
from rag_core.config import get_config
|
| 168 |
-
from rag_core.model import Model
|
| 169 |
-
from rag_core.vector_store import QdrantVectorStore
|
| 170 |
-
from rag_core.search import RagService
|
| 171 |
-
|
| 172 |
-
cfg = get_config()
|
| 173 |
-
model = Model(model_name=cfg.model_name)
|
| 174 |
-
store = QdrantVectorStore.from_config(cfg)
|
| 175 |
-
rag = RagService(model=model, vector_store=store, config=cfg)
|
| 176 |
-
|
| 177 |
-
docs = [{"text": "Hello world", "metadata": {"source": "demo"}}]
|
| 178 |
-
rag.ingest(collection="demo", documents=docs)
|
| 179 |
-
|
| 180 |
-
hits = rag.search(collection="demo", query="hello", top_k=3)
|
| 181 |
-
print(hits)
|
| 182 |
-
```
|
| 183 |
-
|
| 184 |
-
### MCP Tool Calls
|
| 185 |
-
|
| 186 |
-
```python
|
| 187 |
-
ingest_documents(
|
| 188 |
-
collection="knowledge",
|
| 189 |
-
documents=[{"text": "AI is transforming industries."}],
|
| 190 |
-
chunking={"chunk_size": 500, "overlap": 50}
|
| 191 |
-
)
|
| 192 |
-
|
| 193 |
-
search(
|
| 194 |
-
collection="knowledge",
|
| 195 |
-
query="AI transformation",
|
| 196 |
-
top_k=5,
|
| 197 |
-
score_threshold=0.5
|
| 198 |
-
)
|
| 199 |
-
```
|
| 200 |
-
|
| 201 |
-
## Troubleshooting
|
| 202 |
-
|
| 203 |
-
### Connection Refused
|
| 204 |
-
```bash
|
| 205 |
-
docker compose up -d qdrant-service
|
| 206 |
-
curl http://localhost:6333/health
|
| 207 |
-
```
|
| 208 |
-
|
| 209 |
-
### Model Download Slow
|
| 210 |
-
First run downloads the embedding model from HuggingFace (~400MB).
|
| 211 |
-
|
| 212 |
-
### GPU Support
|
| 213 |
-
```bash
|
| 214 |
-
pip install torch --index-url https://download.pytorch.org/whl/cu121
|
| 215 |
-
# Set MODEL_DEVICE=cuda in config
|
| 216 |
-
```
|
| 217 |
-
|
| 218 |
-
## License
|
| 219 |
-
|
| 220 |
-
MIT
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: RAG-MCP Agent
|
| 3 |
+
emoji: 🧠
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: blue
|
| 6 |
+
sdk: gradio
|
| 7 |
+
app_file: app.py
|
| 8 |
+
pinned: false
|
| 9 |
+
---
|
| 10 |
|
| 11 |
+
# 🧠 RAG-MCP Agent
|
| 12 |
|
| 13 |
+
## Hackathon Track
|
| 14 |
|
| 15 |
+
Tracks:
|
| 16 |
+
- "building-mcp-track-consumer"
|
| 17 |
+
- "mcp-in-action-track-consumer"
|
| 18 |
|
| 19 |
+
## Overview
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
RAG-MCP is a minimal MCP (Model Context Protocol) server with built-in Retrieval-Augmented Generation.
|
| 22 |
+
This Space demonstrates the same RAG engine wrapped with a Gradio agent UI.
|
| 23 |
|
| 24 |
+
Users can ingest documents, query collections, and experiment with a working MCP-style RAG system.
|
| 25 |
|
| 26 |
+
## Project Structure
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
- Core MCP server:
|
| 29 |
+
https://github.com/DataOpsFusion/Rag-MCP
|
| 30 |
|
| 31 |
+
- Demo UI:
|
| 32 |
+
This Hugging Face Space (`rag-mcp-agent`) shows RAG-MCP in action.
|
| 33 |
|
| 34 |
+
## Demo & Social
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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