doc/rag-documentation.md
ProxySQL's RAG subsystem provides retrieval capabilities for LLM-powered applications. It allows you to:
To enable RAG functionality, you need to enable the GenAI module and RAG features:
-- Enable GenAI module
SET genai.enabled = true;
-- Enable RAG features
SET genai.rag_enabled = true;
-- Configure RAG parameters (optional)
SET genai.rag_k_max = 50;
SET genai.rag_candidates_max = 500;
SET genai.rag_timeout_ms = 2000;
The RAG subsystem provides the following MCP tools via the /mcp/rag endpoint:
rag.search_fts - Keyword search using FTS5
{
"query": "search terms",
"k": 10
}
rag.search_vector - Semantic search using vector embeddings
{
"query_text": "semantic search query",
"k": 10
}
rag.search_hybrid - Hybrid search combining FTS and vectors
{
"query": "search query",
"mode": "fuse", // or "fts_then_vec"
"k": 10
}
rag.get_chunks - Fetch chunk content by chunk_id
{
"chunk_ids": ["chunk1", "chunk2"],
"return": {
"include_title": true,
"include_doc_metadata": true,
"include_chunk_metadata": true
}
}
rag.get_docs - Fetch document content by doc_id
{
"doc_ids": ["doc1", "doc2"],
"return": {
"include_body": true,
"include_metadata": true
}
}
rag.fetch_from_source - Refetch authoritative data from source database
{
"doc_ids": ["doc1"],
"columns": ["Id", "Title", "Body"],
"limits": {
"max_rows": 10,
"max_bytes": 200000
}
}
{}
The RAG subsystem uses the following tables in the vector database (/var/lib/proxysql/ai_features.db):
You can test the RAG functionality using the provided test scripts:
# Test RAG functionality via MCP endpoint
./scripts/mcp/test_rag.sh
# Test RAG database schema
cd test/rag
make test_rag_schema
./test_rag_schema
The RAG subsystem includes several security features:
Recommended performance settings: