ANSWERS · ANSWERS FOR CODING AGENTS

Local code search MCP for Claude Code that uses fewer tokens than grep

AUTHOR · XERJ documentation team · REVIEWED BY · XERJ engineering team · PUBLISHED · 2026-10-19 · UPDATED · 2026-10-20

TL;DR — Yes: xerj is a local code search MCP for Claude Code that uses fewer tokens than grep. It indexes the repository once, then xerj search and xerj def return ranked passages with path:line. On psf/requests, measured 2026-10-19, one answer was 1,303 bytes against 25,150 bytes of rg output.

PASTE THIS TO YOUR AI AGENT — IT DOES THE REST Read https://xerj.org/llms.txt. Install xerj, start a node with xerj --insecure --data-dir ~/xerj-data, run xerj autoindex on this repository, run xerj init so the xerj MCP server is registered, then answer my next code question with one xerj search or xerj def call and cite path:line instead of opening whole files.
RUN THIS XERJ COMMAND curl -fsSL https://xerj.org/get | sh Install the release binary into ~/.local/bin (the installer checks its SHA-256).
RUN THIS XERJ COMMAND xerj --insecure --data-dir ./xerj-data Start a single-user node on localhost:9200 in its own terminal.
RUN THIS XERJ COMMAND xerj autoindex ./requests --prefix req Index the repository once; code files get defs and symbols with line numbers.
RUN THIS XERJ COMMAND xerj search --prefix req -k 3 --full 400 "rebuild auth on redirect strip authorization" Three ranked passages with path:line, each body capped at 400 characters.
RUN THIS XERJ COMMAND xerj def --prefix req should_strip_auth Exact definition lookup: the declaration line and the file's symbol list.
RUN THIS XERJ COMMAND xerj init Register xerj mcp in .mcp.json for Claude Code (and Cursor or Codex when present).

Run it

The installer puts one binary in ~/.local/bin. Start a node in its own terminal, index the repository once, and then ask. These are the exact commands and output from a scratch HOME with v1.0.0-rc.97 and psf/requests at commit 611c6162.

curl -fsSL https://xerj.org/get | sh
xerj --insecure --data-dir ./xerj-data &
git clone --depth 1 https://github.com/psf/requests
xerj autoindex ./requests --prefix req
done in 2.9s — 1 dataset, 1571 records live, 0 duplicate aliases, 0 junk records, 1 junk/skipped file (543.9 docs/sec)
xerj-done ok=true exit=3 reason=completed-with-junk wall=3.0s files=95 records=1571 datasets=1 junk_files=1 code_files=36 code_files_indexed=36 code_files_junked=0

Exit 3 means the run completed and skipped one file it could not use; all 36 code files were indexed.

Ask with the words the code uses. The answer names the function, the file and the line.

xerj search --prefix req -k 3 --full 400 "rebuild auth on redirect strip authorization"
xerj search: these hits are lexical; this command does not consult the embedding.

─── src/requests/sessions.py:309  (score 22.97)
    def rebuild_auth(
            self, prepared_request: PreparedRequest, response: Response
        ) -> None:
            """When being redirected we may want to strip authentication from the
            request to avoid leaking credentials. This method intelligently removes
            and reapplies authentication where possible to avoid credential loss.
            """
            original_request = response.request

    … (--full 800 to see more)

─── docs/conf.py:62  [const]  (score 22.11)
    author = u"Kenneth Reitz"

─── tests/test_requests.py:662  (score 21.64)
    [17 lines of the test body cut here for the page]
3 passage(s) from 'req-*'. Cite ax_path:line for anything you rely on.

When you know the symbol, xerj def is shorter still.

xerj def --prefix req should_strip_auth
─── src/requests/sessions.py:154  [function]
    def should_strip_auth(self, old_url: str, new_url: str) -> bool:

Give it to Claude Code over MCP

Run xerj init in the project. It writes .mcp.json for Claude Code and keeps the MCP entries already there. Cursor and Codex get the same entry when their config folders exist. Keep the node running, because xerj mcp does not start one.

{"mcpServers": {"xerj": {"command": "xerj", "args": ["mcp", "--url", "http://localhost:9200"]}}}

Measured on 2026-10-19

One question, three ways to answer it, on the same checkout (95 files indexed, 36 of them code). Bytes are what lands in the agent's context.

MethodOutputBytesWall time, 5 runs
rg -n -i redirect282 lines from 17 files25,1505 to 7 ms
Open the 17 matching fileswhole files447,383n/a
xerj search -k 3 --full 4003 passages, sessions.py:309 first1,3038 to 23 ms
xerj def should_strip_authdeclaration plus symbol list949not timed

The ratio is 19 times fewer bytes for the search, measured once on one repository. ripgrep is faster per call. A byte is not a token, so treat this as a size comparison, not a token count. The published agent benchmark is the token number: 9,982 output tokens for xerj against 26,477 for the baseline agent, 2.7 times fewer, over 8 tasks.

How it compares

ToolRuns locallyRanked resultsfile:lineMCP serverSetup
xerjyesyes, BM25yesyes, 17 toolsinstall, start node, index once
ripgrepyesno, every matchyesnonone
Zoektyesyesyesnoindex server
GitHub code searchnoyesyesnorepo on GitHub, API limits
Vector database plus embedderdependsyes, semanticonly if you store itdependsembedder, chunker, store

When not to use xerj

FAQ

Is there a local code search MCP for Claude Code that uses fewer tokens than grep?

Yes. xerj runs on your machine, indexes the repository once and serves the index through xerj mcp. On psf/requests a ranked answer was 1,303 bytes where rg -n -i redirect printed 25,150 bytes.

MCP server grep alternative with fewer tokens: which tools does xerj expose?

The rc.97 server lists 17 tools in tools/list, including xerj_search, xerj_code_search, xerj_map and the three hub tools. Run xerj init in the project to register it.

Is xerj faster than ripgrep?

Not per call. Two sessions of five runs on psf/requests took 8 to 23 ms for xerj search and 5 to 7 ms for rg. The saving is in what the agent reads afterwards, not in wall time.

Does it understand code or only words?

Code files are parsed with tree-sitter, so xerj def finds a declaration by name. Ranking is lexical BM25 by default; xerj search says so on its first line.

What happens when my wording does not match the code?

Lexical ranking can miss. Our first phrasing, about stripping the Authorization header when a redirect changes host, ranked tests and rebuild_method above rebuild_auth. Rephrasing with the words in the code fixed it.

How much does this save in a full agent session?

The published coding-agent benchmark measured 2.7 times fewer output tokens than the baseline agent over 8 tasks and 16 runs per arm. Your repository and agent will give a different number.

Evidence

Related