Local RAG: answer questions over your own files, on your machine
Local RAG is retrieval-augmented generation that keeps your files and the search index on your own machine. You index a folder, retrieve the passages that answer a question, and a model writes the answer from those passages with citations. XERJ does the retrieval step in one Apache-2.0 binary, with no separate vector database and no embedding API key.
Key number: On main, xerj mcp registers 24 MCP tools, or 21 when the binary has no Corpus Hub key. (as of 2026-10-28 · source: landing/docs/agents/schemas/mcp-tools.json)
TL;DR Local RAG keeps your files and the search index on your own machine. You index a folder, retrieve the passages that answer a question, and a model writes the answer from those passages with citations. With XERJ the retrieval step is one Apache-2.0 binary: xerj autoindex, then xerj search, the MCP server or a REST query. There is no separate vector database and no embedding API key.
Act as a coding agent. Read https://xerj.org/llms.txt, start a node with `xerj --insecure --data-dir ./.xerj-data`, index the folder you were handed with `xerj autoindex ./docs --url http://127.0.0.1:9200 --prefix docs --progress plain`, retrieve with `xerj search`, and write the answer only from cited hits. If a fact is not in a hit, say so.
curl -fsSL https://xerj.org/get | sh
Install the release binary into ~/.local/bin.
xerj --insecure --data-dir ./.xerj-data
Start a local development node. Put the data dir outside the folder you will index.
xerj autoindex ./docs --url http://127.0.0.1:9200 --prefix docs --progress plain
Build a local index. No schema and no separate vector database.
xerj search "what is the default timeout"
Retrieve cited passages. Hand only those hits to the model.
Pick your local RAG setup
Answer three questions and see the closest fit
Command line
Index once with xerj autoindex, then search from the terminal and read the cited hits.
MCP server
Give the agent search tools over the same local index, so it retrieves before it writes.
REST API
POST a search or hybrid query from your code and hand only the hits to your model.
How local RAG works
Retrieval-augmented generation has two halves. Retrieval finds the passages that answer the question. Generation writes the answer from those passages. In local RAG both the files and the index stay on your machine, so private notes, code and logs never leave it.
The quality of the answer depends mostly on retrieval. If the right passage comes back, the model can quote it and cite the file. If it does not, the model guesses. That is why good local RAG starts with good search. It needs keyword ranking for exact terms and meaning-based ranking for paraphrases, with hybrid search to blend the two. On XERJ the embedder is lexical by default and neural with --embed-mode neural.
Index locally, retrieve, then generate with citations
1. Install and start a node
curl -fsSL https://xerj.org/get | sh, then xerj --insecure --data-dir ./.xerj-data. Put the data dir outside the folder you will index.
2. Index the corpus
xerj autoindex ./docs --url http://127.0.0.1:9200 --prefix docs --progress plain. No schema and no separate vector database.
3. Retrieve with citations
xerj search, a hybrid query, or POST /docs-*/_search. Each hit carries ax_path or file:line. The default embedding mode is lexical, not neural.
4. Generate from the hits
Hand the passages to your model and require it to cite those paths. If a fact is not in a hit, say so. Nothing in this loop leaves the machine unless you send it.
Typical stack vs one binary
| Part | Typical local stack | With XERJ |
|---|---|---|
| Index and search | A vector store, such as ChromaDB | xerj autoindex and xerj search |
| Embeddings | A local embedder you pull and serve | Built into the binary (lexical by default, neural with --embed-mode neural) |
| Full-text search | Often a second index, or none | BM25 in the same index |
| Glue code | A framework such as LlamaIndex | CLI, MCP server or REST API |
| Answer writer | A local model, such as one run by Ollama | Your choice of model |
The typical stack column follows the LlamaIndex cookbook for a fully local RAG pipeline with Chroma and Ollama. Both routes keep data local. The difference is how many services you run. The same design is explained in RAG without a vector database.
Set it up in five commands
- Install the binary:
curl -fsSL https://xerj.org/get | sh - Start a node:
xerj --insecure --data-dir ./.xerj-data. Keep the data dir outside the folder you index. - Index the folder:
xerj autoindex ./docs --url http://127.0.0.1:9200 --prefix docs --progress plain - Retrieve:
xerj search "what is the default timeout", or send a hybrid request toPOST /docs-*/_search. - Generate only from those hits, and keep the
ax_pathor file:line next to each claim.
Each command has a copy button below. To let your agent run it, use Copy the prompt and paste it into Claude Code, Cursor or Codex.
Local RAG for AI agents over MCP
xerj mcp is the MCP server in the same binary. On main it registers 24 tools, or 21 when the binary has no Corpus Hub key. The agent searches the local index, reads the cited passages and writes its answer from them, which keeps the context window small. Why that matters is on context engineering, and the protocol itself is the Model Context Protocol.
Published studies of retrieval against printing raw matches are on the retrieval studies page. For answers that must stay tied to their sources, see grounded answers.
Beyond RAG
Local RAG still asks a language model to write the final answer. The Query-1 model takes another route: it compiles a question into a program the engine runs over your facts. That comparison, with its own figures, is on the Query-1 page.
Sources checked
- LlamaIndex, "Fully Local RAG Pipeline with Chroma + Ollama", developers.llamaindex.ai, read 2026-11-17.
- XERJ MCP tool count:
landing/docs/agents/schemas/mcp-tools.json.
Read next
RAG without a vector database, Cohere RAG with XERJ, reranking, grounded answers and a local AI search engine.
FAQ
How do I set up local RAG in 2026?
Install XERJ, start a local node, run xerj autoindex on the folder, then retrieve with xerj search, the MCP server or the REST API. Give the model only the retrieved passages and ask it to cite them.
What does a typical local RAG stack look like?
Often three parts: a local model runner, a vector store and a framework that glues them together. The LlamaIndex cookbook for fully local RAG, for example, uses Ollama with ChromaDB. With XERJ, indexing and retrieval are one binary, and you bring the model.
Can a coding agent use local RAG?
Yes. Add xerj mcp as an MCP server in Claude Code, Cursor or Codex. The agent searches the local index first and writes from the cited hits.
What is local RAG?
It is retrieval-augmented generation that keeps the corpus on your machine. You retrieve cited passages from a local index, then a model writes an answer from those hits.
Do I need a separate vector database?
Not with XERJ. The embedder ships in the binary. See RAG without a vector database for the same point, with more API detail.
Is there a local RAG MCP server?
xerj mcp is the MCP server in the same binary. On main it registers 24 tools, or 21 with no Corpus Hub key. The agent retrieves from the local index, then writes from the cited hits.
What is the default embedding mode?
Lexical, not neural. Semantic and hybrid queries still run, but they use word and sub-word overlap plus BM25 unless you start the node with --embed-mode neural.
How is this different from Query-1?
Local RAG still uses a language model to write the final answer from retrieved hits. The Query-1 model compiles a question into a program the engine runs over your facts. That comparison lives on the Query-1 page.
Evidence
- On main, xerj mcp registers 24 MCP tools, or 21 when the binary has no Corpus Hub key. Source:
landing/docs/agents/schemas/mcp-tools.json
Related
- RAG without a vector database: 3 vectorless RAG setups that work
- Local AI search engine: private, offline search over your own files
- RAG vs grep for AI coding agents
- What is hybrid search?
- What is semantic search?
- What is context engineering?
- What is the Model Context Protocol?
- XERJ Query-1
- Local file search MCP server: let Claude or ChatGPT search a folder on your laptop · same intent: Find the right tool
- What is XERJ? · same intent: Find the right tool
- What's a local MCP search engine for Claude? · same intent: Find the right tool