This document provides a comprehensive reference for all configuration options available in the Codebase RAG MCP Server.
- Quick Start
- Environment Variables Reference
- High-Speed Indexing with MLX Server
- Performance Recommendations
-
Copy the example configuration file:
cp .env.example .env
-
Edit
.envto customize your settings. The defaults work for most setups. -
Ensure your services are running:
- Qdrant:
docker run -d -p 6333:6333 qdrant/qdrant - Ollama:
ollama serveandollama pull nomic-embed-text
- Qdrant:
| Variable | Default | Description |
|---|---|---|
EMBEDDING_PROVIDER |
ollama |
Embedding provider selection: ollama or mlx_server |
Choose your embedding provider based on your hardware:
ollama: Works on all platforms. Good for general use.mlx_server: 48-161x faster on Apple Silicon (M1/M2/M3/M4). Recommended for large codebases.
For dramatically faster embedding generation on Apple Silicon Macs.
| Variable | Default | Description |
|---|---|---|
MLX_SERVER_URL |
http://localhost:8000 |
MLX embedding server URL |
MLX_BATCH_SIZE |
64 |
Batch size for embedding requests (64-128 recommended) |
MLX_MODEL_SIZE |
small |
Model size: small, medium, large |
MLX_TIMEOUT |
120 |
Request timeout in seconds |
MLX_FALLBACK_TO_OLLAMA |
true |
Auto-fallback to Ollama if MLX is unavailable |
| Method | Speed (emb/s) | vs Ollama |
|---|---|---|
| MLX Server (batch=128) | 1707 | 48x faster |
| MLX Server (batch=64) | 1646 | 47x faster |
| Ollama (nomic-embed-text) | 35 | baseline |
| Codebase Size | Ollama | MLX Server |
|---|---|---|
| 10K chunks | ~5 min | ~6 sec |
| 50K chunks | ~24 min | ~30 sec |
| 100K chunks | ~48 min | ~1 min |
Default embedding provider configuration.
| Variable | Default | Description |
|---|---|---|
OLLAMA_HOST |
http://localhost:11434 |
Ollama server URL |
OLLAMA_DEFAULT_EMBEDDING_MODEL |
nomic-embed-text |
Default embedding model |
nomic-embed-text(recommended, 768 dimensions)mxbai-embed-large(1024 dimensions)- Any other Ollama-compatible embedding model
Configure the cross-encoder reranker for improved search accuracy. The two-stage RAG system improves search accuracy by 22-31% over single-stage vector search.
| Variable | Default | Description |
|---|---|---|
RERANKER_ENABLED |
true |
Enable cross-encoder reranking for two-stage RAG |
RERANKER_PROVIDER |
transformers |
Reranker provider: transformers, ollama, or mlx |
RERANKER_MODEL |
Qwen/Qwen3-Reranker-0.6B |
Cross-encoder model name |
RERANKER_MAX_LENGTH |
512 |
Maximum input length for query + document |
RERANKER_BATCH_SIZE |
8 |
Batch size for reranking operations |
RERANK_TOP_K |
50 |
Number of candidates retrieved in Stage 1 for reranking |
- Stage 1 - Fast Vector Search: Retrieves top-K candidates (default: 50) using approximate nearest neighbor (ANN) search
- Stage 2 - Cross-Encoder Reranking: Evaluates query-document pairs together using Qwen3-Reranker for precise relevance scoring
| Hardware | Reranking Latency (50 candidates) |
|---|---|
| Apple Silicon (MPS) | ~100ms |
| CUDA GPU | ~80-150ms |
| CPU | ~400ms |
Qwen/Qwen3-Reranker-0.6B(default, smallest, fastest)Qwen/Qwen3-Reranker-4B(medium, better quality)Qwen/Qwen3-Reranker-8B(largest, best quality)
For speed-critical applications, disable reranking:
# In your .env file
RERANKER_ENABLED=falseOr disable per-query using the search tool's enable_reranking=false parameter.
Vector database configuration.
| Variable | Default | Description |
|---|---|---|
QDRANT_HOST |
localhost |
Qdrant server hostname |
QDRANT_PORT |
6333 |
Qdrant gRPC port |
# Basic (data not persisted)
docker run -p 6333:6333 qdrant/qdrant
# With persistence (recommended)
docker run -d -p 6333:6333 -p 6334:6334 \
-v "$(pwd)/qdrant_data:/qdrant/storage" \
qdrant/qdrantControl how files are discovered and processed during indexing.
| Variable | Default | Description |
|---|---|---|
MAX_FILE_SIZE_MB |
5 |
Skip files larger than this size (MB) |
MAX_DIRECTORY_DEPTH |
20 |
Maximum directory traversal depth |
FOLLOW_SYMLINKS |
false |
Whether to follow symbolic links |
DETECT_BINARY_FILES |
true |
Auto-detect and skip binary files |
LOG_SKIPPED_FILES |
true |
Log when files are skipped |
Fine-tune indexing performance for your hardware.
| Variable | Default | Description |
|---|---|---|
INDEXING_CONCURRENCY |
4 |
Number of parallel file processing workers |
INDEXING_BATCH_SIZE |
20 |
Files processed per batch |
EMBEDDING_BATCH_SIZE |
10 |
Texts sent to embedding API per call |
QDRANT_BATCH_SIZE |
500 |
Points inserted to database per batch |
High-end workstation (32GB+ RAM, 8+ cores):
INDEXING_CONCURRENCY=8
INDEXING_BATCH_SIZE=50
EMBEDDING_BATCH_SIZE=20
QDRANT_BATCH_SIZE=1000Standard laptop (16GB RAM, 4 cores):
INDEXING_CONCURRENCY=4
INDEXING_BATCH_SIZE=20
EMBEDDING_BATCH_SIZE=10
QDRANT_BATCH_SIZE=500Resource-constrained (8GB RAM):
INDEXING_CONCURRENCY=2
INDEXING_BATCH_SIZE=10
EMBEDDING_BATCH_SIZE=5
QDRANT_BATCH_SIZE=200Control memory usage during large indexing operations.
| Variable | Default | Description |
|---|---|---|
MEMORY_WARNING_THRESHOLD_MB |
1000 |
Warn when memory usage exceeds this |
MEMORY_CLEANUP_INTERVAL |
5 |
Batches between memory cleanup checks |
FORCE_CLEANUP_THRESHOLD_MB |
1500 |
Force garbage collection above this |
Configure database operation behavior and reliability.
| Variable | Default | Description |
|---|---|---|
DB_OPERATION_TIMEOUT |
30 |
Operation timeout in seconds |
DB_RETRY_ATTEMPTS |
3 |
Number of retry attempts on failure |
DB_RETRY_DELAY |
1.0 |
Delay between retries (seconds) |
DB_HEALTH_CHECK_INTERVAL |
50 |
Operations between health checks |
Control MCP tool response behavior.
| Variable | Default | Description |
|---|---|---|
MAX_FILES_IN_RESPONSE |
50 |
Maximum files returned in a single response |
Configure logging verbosity and optional file output.
| Variable | Default | Description |
|---|---|---|
LOG_LEVEL |
INFO |
Log level: DEBUG, INFO, WARNING, ERROR |
LOG_FILE_ENABLED |
false |
Enable file logging for debugging |
LOG_FILE_PATH |
logs/codebase-rag.log |
Path to log file (relative or absolute) |
LOG_FILE_MAX_SIZE |
10 |
Maximum log file size in MB before rotation |
LOG_FILE_BACKUP_COUNT |
5 |
Number of backup log files to keep |
Debugging with File Logging:
To enable file logging for debugging issues:
# In your .env file
LOG_FILE_ENABLED=true
LOG_LEVEL=DEBUG
LOG_FILE_PATH=logs/debug.logLog files are automatically rotated when they reach the maximum size. The logs/ directory will be created automatically if it doesn't exist.
For Apple Silicon users who need maximum indexing performance.
-
Clone the MLX embedding server:
git clone https://github.com/jakedahn/qwen3-embeddings-mlx.git cd qwen3-embeddings-mlx -
Install dependencies:
pip install -r requirements.txt
-
Start the server:
python server.py # Server runs at http://localhost:8000 -
Configure the RAG server:
# In your .env file EMBEDDING_PROVIDER=mlx_server MLX_SERVER_URL=http://localhost:8000 MLX_BATCH_SIZE=64
- Vector Dimensions: MLX uses Qwen3-Embedding (1024 dimensions) vs Ollama's nomic-embed-text (768 dimensions). Collections are created with the correct dimension automatically.
- Requires Re-indexing: If switching providers, you need to re-index your codebase due to different embedding dimensions.
- Apple Silicon Only: MLX Server requires Apple Silicon (M1/M2/M3/M4) Mac.
- Auto-Fallback: If MLX server is unavailable, the system automatically falls back to Ollama (configurable).
- Use MLX Server if on Apple Silicon
- Increase batch sizes:
INDEXING_BATCH_SIZE=50 EMBEDDING_BATCH_SIZE=20
- Use manual indexing tool for initial index:
uv run python manual_indexing.py -d /path/to/repo -m clear_existing
- Use incremental indexing to minimize processing time
- Consider pre-built Qdrant snapshots for faster startup
- Set appropriate timeouts:
DB_OPERATION_TIMEOUT=60 MLX_TIMEOUT=180
- Reduce batch sizes
- Lower memory thresholds:
MEMORY_WARNING_THRESHOLD_MB=500 FORCE_CLEANUP_THRESHOLD_MB=800
- Limit concurrent workers:
INDEXING_CONCURRENCY=2