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
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.
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);
--- 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
Everything an AI coding agent needs from code search: compressed output, structured results, and MCP integration.
rustygrep mcp runs a Model Context Protocol server for AI agents. Zero external dependencies. Wires into Claude Code, Cursor, and OpenCode.
--llm-budget N caps output to N tokens so agents never blow past their context window.
--top N lists files with the most matches first. Relevance at a glance.
All CPU cores via rayon. SIMD-accelerated byte matching with memchr.
Respects .gitignore by default with zero config. Same rules as ripgrep.
--json emits JSON Lines for scripting and piping. --json-file for per-file structure.
One command starts an MCP server. Agents call it like any tool and get token-compressed results back.
rustygrep_search: pattern search, llm/json/pretty formats
rustygrep_files: files containing a pattern
rustygrep_count: matches per file
{
"mcpServers": {
"rustygrep": {
"command": "rustygrep",
"args": ["mcp"]
}
}
}
Apple M4, 32GB, 9,000 Rust files. ripgrep-class speed, LLM-class token count.
| Tool | Search time | Token count |
|---|---|---|
| grep | 850ms | 12,400 |
| ripgrep | 82ms | 11,800 |
| rustygrep | 78ms | 4,100 |
| rustygrep --llm --llm-budget 500 | 78ms | ~500 |
SIMD-parallel search keeps speed identical while --llm cuts tokens 60-95%.
cargo install rustygrepfrom crates.iorustygrep --llm 'pattern' src/LLM-optimized outputrustygrep --llm-budget 500cap output tokensrustygrep --top 10 src/files by match countrustygrep -t rs 'fn ' .file type filterrustygrep mcpstart MCP server