Hi! 👋 We are doing a big documentation refresh. Help us improve — what's missing or could be better? Let us know! Simply send an email or start a conversation in Google Groups!

RAG Tools (/mcp/rag)

💡Tip

See RAG Overview for an introduction to ProxySQL’s RAG capabilities, architecture, and use cases.

The tools available at the /mcp/rag endpoint are designed for Retrieval Augmented Generation (RAG) workflows, including advanced search and source data retrieval.

Search Tools

ToolDescription
rag.search_ftsPerforms a full-text search across indexed documents.
rag.search_vectorExecutes a vector-based semantic search.
rag.search_hybridCombines full-text and vector search for more relevant results.

rag.search_fts

Performs a full-text search across all indexed document chunks using SQLite FTS5.

Parameters:

ParameterTypeRequiredDescription
querystringyesThe search query string. Standard FTS5 query syntax is supported (e.g., phrase matching with "...", prefix matching with *).
limitintnoMaximum number of chunks to return. Defaults to 10.

Returns: An array of matching document chunks ranked by BM25 relevance score, each including the chunk text, source document identifier, and score.

rag.search_vector

Executes a semantic similarity search using pre-computed vector embeddings. Useful for finding conceptually related content even when exact keywords do not match.

Parameters:

ParameterTypeRequiredDescription
querystringyesNatural-language query. The query is embedded on the fly and compared against the stored embeddings.
limitintnoMaximum number of chunks to return. Defaults to 10.

Returns: An array of semantically similar document chunks ordered by cosine similarity, each including the chunk text, source document identifier, and similarity score.

rag.search_hybrid

Combines full-text and vector search results using Reciprocal Rank Fusion (RRF), giving the best of both lexical and semantic retrieval.

Parameters:

ParameterTypeRequiredDescription
querystringyesThe search query. Applied to both FTS and vector search internally.
limitintnoMaximum number of chunks to return after re-ranking. Defaults to 10.

Returns: An array of re-ranked document chunks with a fused relevance score.

Data Retrieval Tools

ToolDescription
rag.get_chunksRetrieves specific chunks of text from indexed documents.
rag.get_docsFetches metadata or full content for specified documents.
rag.fetch_from_sourceRetrieves the original source data for a given document or chunk.

rag.get_chunks

Retrieves one or more specific chunks by their identifier, without performing a search.

Parameters:

ParameterTypeRequiredDescription
chunk_idsarray of stringsyesOne or more chunk IDs to fetch.

Returns: An array of chunk objects, each containing the chunk text, position within the parent document, and source document metadata.

rag.get_docs

Fetches metadata or the full reconstructed content for one or more documents.

Parameters:

ParameterTypeRequiredDescription
doc_idsarray of stringsyesOne or more document IDs to retrieve.
include_chunksboolnoIf true, includes all chunks for each document in the response. Defaults to false.

Returns: An array of document objects with title, source URL, ingestion timestamp, and optionally all chunks.

rag.fetch_from_source

Re-fetches the original source content for a document (e.g., re-downloads a URL or re-reads a file), bypassing the local index. Useful for verifying that indexed content is still current.

Parameters:

ParameterTypeRequiredDescription
doc_idstringyesThe document ID whose original source should be fetched.

Returns: The raw source content as a string and metadata about the source location.

Management & Monitoring

ToolDescription
rag.admin.statsProvides detailed statistics on RAG index usage and performance.

rag.admin.stats

Returns operational statistics for the RAG index.

Parameters: None.

Returns: A JSON object containing: total document count, total chunk count, index size on disk, number of searches performed (broken down by FTS, vector, and hybrid), average query latency, and cache hit rate.