ANSWERS · ANSWERS FOR CODING AGENTS

Local RAG: answer questions over your own files, on your machine

AUTHOR · XERJ documentation team · REVIEWED BY · XERJ engineering team · PUBLISHED · 2026-11-13 · UPDATED · 2026-11-17
SHORT ANSWER · UPDATED 2026-11-17

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.

PASTE THIS TO YOUR AI AGENT. IT DOES THE REST 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.
RUN THIS XERJ COMMAND curl -fsSL https://xerj.org/get | sh Install the release binary into ~/.local/bin.
RUN THIS XERJ COMMAND xerj --insecure --data-dir ./.xerj-data Start a local development node. Put the data dir outside the folder you will index.
RUN THIS XERJ COMMAND 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.
RUN THIS XERJ COMMAND xerj search "what is the default timeout" Retrieve cited passages. Hand only those hits to the model.

Pick your local RAG setup

Try it: pick your local RAG setup

Answer three questions and see the closest fit

Who asks the questions?
What is in the folder?
How should the answer arrive?

xerj search

Command line

Index once with xerj autoindex, then search from the terminal and read the cited hits.

xerj mcp

MCP server

Give the agent search tools over the same local index, so it retrieves before it writes.

REST API

REST API

POST a search or hybrid query from your code and hand only the hits to your model.

Runs in your browser and sends nothing. Each answer adds a point to the option it matches. All three use the same local index.

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.

Try it: a local RAG loop

Index locally, retrieve, then generate with citations

  1. 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. 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. 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. 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.

This is the local loop on one binary. It is not a new measured RAG cost study. Query-1 compared with RAG lives on its own page.

Typical stack vs one binary

PartTypical local stackWith XERJ
Index and searchA vector store, such as ChromaDBxerj autoindex and xerj search
EmbeddingsA local embedder you pull and serveBuilt into the binary (lexical by default, neural with --embed-mode neural)
Full-text searchOften a second index, or noneBM25 in the same index
Glue codeA framework such as LlamaIndexCLI, MCP server or REST API
Answer writerA local model, such as one run by OllamaYour 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

  1. Install the binary: curl -fsSL https://xerj.org/get | sh
  2. Start a node: xerj --insecure --data-dir ./.xerj-data. Keep the data dir outside the folder you index.
  3. Index the folder: xerj autoindex ./docs --url http://127.0.0.1:9200 --prefix docs --progress plain
  4. Retrieve: xerj search "what is the default timeout", or send a hybrid request to POST /docs-*/_search.
  5. Generate only from those hits, and keep the ax_path or 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

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

Related