MX

momokun7/xgrep

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

20 stars 1 forks 质量 79 趋势 30Apache-2.0

超高速索引代码搜索引擎——反复搜索比 ripgrep 快,比 zoekt 轻。内置 AI 代理的 MCP 服务器。还能快速查找文件(fd/find 替代方案)。

概览

超高速索引代码搜索引擎,配备 MCP 服务器,用于 AI 编码工具。 预先构建倒索引的三元组,然后在毫秒级内搜索。设计用于在大型代码库上反复搜索——无论是人类还是人工智能代理。 - — 三元组倒索引使重复搜索速度比 ripgrep 快 2-46 倍 - —— ——查找模式定位文件的速度是 fd 的 2-15 倍 - —— 内置的 AI 编码工具模型上下文协议服务器(如 Claude Code、光标等)—— ——格式 LLM 生成带有语言标签、上下文行和标记感知截断的 Markdown - —— 只搜索更改过的文件(---changed)、最近的提交(--自 1h 以来),尊重 .gitignore —— 通过 cargo/npm/pip 安装,然后 xg “pattern”。索引在首次搜索时自动构建—— —— 自上次索引构建以来编辑的文件会在每次搜索中重新扫描;在 Linux 上,xg 服务监控树,因此此检查费用为 ~0。

概述(AI 翻译)

超高速索引代码搜索引擎,配备 MCP 服务器,用于 AI 编码工具。

预先构建倒索引的三元组,然后在毫秒级内搜索。设计用于在大型代码库上反复搜索——无论是人类还是人工智能代理。

特色

  • 索引搜索 — 三元组倒索引使重复搜索速度比ripgrep快2倍到46倍
  • 文件发现 — --find 模式定位文件的速度是 FD 的 2-15 倍
  • MCP 服务器 — 内置的模型上下文协议服务器,用于 AI 编码工具(Claude Code、Cursor 等)
  • LLM 优化输出 — --format llm 生成带有语言标签、上下文行和标记识别截断的 Markdown
  • Git-aware — 仅搜索已更改文件([--changed)、最近提交(--since 1h)、尊重.gitignore
  • 零配置 — 通过 cargo/npm/pip 安装,然后 xg "pattern"。索引在首次搜索时自动构建
  • 始终新鲜 — 自上次索引构建以来编辑的文件在每次搜索中都会重新扫描;在Linux上,xg serve会监控树,因此此检查耗费~0.1毫秒

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

xgrep

Ultra-fast indexed code search engine with MCP server for AI coding tools.

Pre-builds a trigram inverted index, then searches in milliseconds. Designed for repeated searches on large codebases — by humans and AI agents alike.

Features

  • Indexed search — trigram inverted index makes repeated searches 2-46x faster than ripgrep
  • File discovery — --find mode locates files 2-15x faster than fd
  • MCP server — built-in Model Context Protocol server for AI coding tools (Claude Code, Cursor, etc.)
  • LLM-optimized output — --format llm produces Markdown with language tags, context lines, and token-aware truncation
  • Git-aware — search only changed files (--changed), recent commits (--since 1h), respects .gitignore
  • Zero config — install via cargo/npm/pip, then xg "pattern". Index builds automatically on first search
  • Always fresh — files edited since the last index build are rescanned on every search; on Linux, xg serve watches the tree so this check costs ~0.1ms
  • Syntax-aware — tree-sitter outlines (--outline), enclosing-block results (--expand block), definitions, references and a repo map for Rust, Python, JS/TS, Go, Java, C/C++ and Ruby
  • Boolean and history search — file-level --and / --not, search inside git diff (--in-diff) or commit messages (--log)

Why xgrep?

ripgrep zoekt xgrep
Setup None Server required None (cargo/npm/pip)
First search Instant After server start Auto-builds index
Repeated search (Linux kernel) 1,687ms 170ms (server) 37ms
File discovery (next.js, 26K files) N/A N/A 9ms (fd: 191ms)
Index size N/A 155% of source ~13% of source (+6% build-only sidecar)
AI agent integration None None MCP server built-in

xgrep is not a ripgrep replacement. Use ripgrep for one-off searches. Use xgrep when you search the same codebase repeatedly — the index pays for itself after ~2 searches.

Installation

Choose your package manager:

# Rust (recommended — native binary, no runtime)
cargo install xgrep-search    # Requires Rust 1.85+

# npm (Node.js 18+)
npm install -g xgrep

# pip (Python 3.8+)
pip install xgrep-search

Prebuilt binaries are also available on the Releases page.

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "xgrep": { "command": "xg", "args": ["serve"] } } }