token-efficient grep for AI coding agents

Fast grep. Fewer tokens.
More context room.

rustygrep is a drop-in ripgrep alternative in Rust. The --llm flag compresses grep output 60-95%. Same file paths, line numbers, and matching content. Fewer tokens. Built-in MCP server wires it into Claude Code, Cursor, and OpenCode.

$ cargo install rustygrep

crates.io v0.x MIT license 100% Rust

Same information. Fewer tokens.

grep output0 tokens
ripgrep output0 tokens
rustygrep --llm0 tokens
context-window savings 0 tokens / call
token compression
0
the problem

LLM agents burn context-window tokens on every grep.

Coding agents run thousands of grep calls per session. Normal grep output is built for humans: wide margins, ANSI codes, verbose paths. Agents pay the same token cost to read what they will never re-use.

normal grep ≈ 12,400 tokens
src/main.rs:42:    fn calculate_total(items: &[Item]) -> u64 {
src/main.rs:43:        items.iter().map(|i| i.price).sum()
src/main.rs:44:    fn main() {
src/main.rs:45:        let total = calculate_total(&items);
src/main.rs:46:        println!("total: {}", total);
rustygrep --llm ≈ 4,100 tokens
--- src/main.rs (3 matches)
42:fn calculate_total(items: &[Item]) -> u64 {
43:  items.iter().map(|i| i.price).sum()
45:let total = calculate_total(&items);

same lines, same info. 67% fewer tokens

built for agents

Not just grep. Token-efficient grep.

Everything an AI coding agent needs from code search: compressed output, structured results, and MCP integration.

MCP server

rustygrep mcp runs a Model Context Protocol server for AI agents. Zero external dependencies. Wires into Claude Code, Cursor, and OpenCode.

Token budget

--llm-budget N caps output to N tokens so agents never blow past their context window.

Match ranking

--top N lists files with the most matches first. Relevance at a glance.

Parallel search

All CPU cores via rayon. SIMD-accelerated byte matching with memchr.

Gitignore-aware

Respects .gitignore by default with zero config. Same rules as ripgrep.

JSON output

--json emits JSON Lines for scripting and piping. --json-file for per-file structure.

model context protocol

Wire rustygrep into your agent.

One command starts an MCP server. Agents call it like any tool and get token-compressed results back.

Available tools

rustygrep_search: pattern search, llm/json/pretty formats rustygrep_files: files containing a pattern rustygrep_count: matches per file

Claude Code Cursor OpenCode JSON-RPC over stdio
claude code settings.json
{
  "mcpServers": {
    "rustygrep": {
      "command": "rustygrep",
      "args": ["mcp"]
    }
  }
}
benchmarks

Fast search. Fewer tokens.

Apple M4, 32GB, 9,000 Rust files. ripgrep-class speed, LLM-class token count.

ToolSearch timeToken count
grep850ms12,400
ripgrep82ms11,800
rustygrep78ms4,100
rustygrep --llm --llm-budget 50078ms~500

SIMD-parallel search keeps speed identical while --llm cuts tokens 60-95%.

install

Zero config. Up in seconds.

cargo install rustygrepfrom crates.io
rustygrep --llm 'pattern' src/LLM-optimized output
rustygrep --llm-budget 500cap output tokens
rustygrep --top 10 src/files by match count
rustygrep -t rs 'fn ' .file type filter
rustygrep mcpstart MCP server