mgrep README

The project's README from github.com/mixedbread-ai/mgrep. As one markdown file: README.md.

mgrep

mgrep

A calm, CLI-native way to semantically grep everything, like code, images, pdfs and more.

npm version License: Apache 2.0
Playground: Try it now Slack Community

Your browser does not support the video tag.

Why mgrep?

# index once
mgrep watch

# then ask your repo things in natural language
mgrep "where do we set up auth?"

Quick Start

  1. Install

    npm install -g @mixedbread/mgrep    # or pnpm / bun
    
  2. Sign in once

    mgrep login
    

    A browser window (or verification URL) guides you through Mixedbread authentication.

    Alternative: API Key Authentication For CI/CD or headless environments, set the MXBAI_API_KEY environment variable:

    export MXBAI_API_KEY=your_api_key_here
    

    This bypasses the browser login flow entirely.

  3. Index a project

    cd path/to/repo
    mgrep watch
    

    watch performs an initial sync, respects .gitignore, then keeps the Mixedbread store updated as files change.

  4. Search anything

    mgrep "where do we set up auth?" src/lib
    mgrep -m 25 "store schema"
    

    Searches default to the current working directory unless you pass a path.

Today, mgrep works great on: code, text, PDFs, images.
Coming soon: audio & video.

Using it with Coding Agents

[!CAUTION] Background Sync Enabled: When installed with a coding agent, mgrep runs a background process that syncs your files to enable semantic search. This process starts automatically when you begin a session and stops when your session ends. You can see your current usage in the Mixedbread platform.

[!NOTE] Default Limits: mgrep enforces default limits to ensure optimal performance:

  • Maximum file size: 1MB per file
  • Maximum file count: 1,000 files per directory

These limits can be customized via CLI flags (--max-file-size, --max-file-count), environment variables, or config files. See the Configuration section for details.

If you prefer to manually start the file watcher instead of relying on the agent's automatic background sync, you can run:

mgrep watch /path/to/your/project

This gives you explicit control over when indexing occurs and which directories are watched.

mgrep supports assisted installation commands for many agents:

These commands sign you in (if needed) and add Mixedbread mgrep support to the agent. After that you only have to start the agent in your project folder, thats it.

More Agents Coming Soon

More agents (Cursor, Windsurf, etc.) are on the way—this section will grow as soon as each integration lands.

Making your agent smarter

We plugged mgrep into Claude Code and ran a benchmark of 50 QA tasks to evaluate the economics of mgrep against grep.

mgrep benchmark

In our 50-task benchmark, mgrep+Claude Code used ~2x fewer tokens than grep-based workflows at similar or better judged quality.

mgrep finds the relevant snippets in a few semantic queries first, and the model spends its capacity on reasoning instead of scanning through irrelevant code from endless grep attempts. You can Try it yourself.

Note: Win Rate (%) was calculated by using an LLM as a judge.

Why we built mgrep

grep is an amazing tool. It's lightweight, compatible with just about every machine on the planet, and will reliably surface any potential match within any target folder.

But grep is from 1973, and it carries the limitations of its era: you need exact patterns and it slows down considerably in the cases where you need it most, on large codebases.

Worst of all, if you're looking for deeply-buried critical business logic, you cannot describe it: you have to be able to accurately guess what kind of naming patterns would have been used by the previous generations of engineers at your workplace for grep to find it. This will often result in watching a coding agent desperately try hundreds of patterns, filling its token window, and your upcoming invoice, with thousands of tokens.

But it doesn't have to be this way. Everything else in our toolkit is increasingly tailored to understand us, and so should our search tools. mgrep is our way to bring grep to 2025, integrating all of the advances in semantic understanding and code-search, without sacrificing anything that has made grep such a useful tool.

Under the hood, mgrep is powered by Mixedbread Search, our full-featured search solution. It combines state-of-the-art semantic retrieval models with context-aware parsing and optimized inference methods to provide you with a natural language companion to grep. We believe both tools belong in your toolkit: use grep for exact matches, mgrep for semantic understanding and intent.

When to use what

We designed mgrep to complement grep, not replace it. The best code search combines mgrep with grep.

Use grep (or ripgrep) for... Use mgrep for...
Exact Matches Intent Search
Symbol tracing, Refactoring, Regex Code exploration, Feature discovery, Onboarding

mgrep can also search the web alongside your local files. This is useful when you need to find documentation, tutorials, or answers to programming questions without leaving your terminal.

# Search the web and get a summarized answer
mgrep --web --answer "How do I integrate a JavaScript runtime into Deno?"

# Get the urls of the search
mgrep --web "best practices for error handling in TypeScript"

Web search queries the mixedbread/web store in addition to your local store, merging results based on relevance. Use --answer (or -a) to get a concise summary instead of raw results.

mgrep as Subagent

For complex questions that require information from multiple sources, mgrep can act as a subagent that automatically refines queries and performs multiple searches to find the best answer.

# Enable agentic search for complex multi-part questions
mgrep --agentic "What are the yearly numbers for 2020, 2021, 2022, 2023, 2024?"

# Combine with --answer for a synthesized response from multiple sources
mgrep --agentic -a "How does authentication work and where is it configured?"

When --agentic is enabled, mgrep will:

This is particularly useful for questions that span multiple files or concepts, where a single search might miss important context.

Commands at a Glance

Command Purpose
mgrep / mgrep search <pattern> [path] Natural-language search with many grep-style flags (-i, -r, -m...).
mgrep watch Index current repo and keep the Mixedbread store in sync via file watchers.
mgrep login & mgrep logout Manage device-based authentication with Mixedbread.
mgrep install-claude-code Authenticate, add the Mixedbread mgrep plugin to Claude Code.
mgrep install-opencode Authenticate and add the Mixedbread mgrep to OpenCode.
mgrep install-codex Authenticate and add the Mixedbread mgrep to Codex.
mgrep install-droid Authenticate and add the Mixedbread mgrep hooks/skills to Factory Droid.

mgrep search is the default command. It can be used to search the current directory for a pattern.

Option Description
-m <max_count> The maximum number of results to return
-c, --content Show content of the results
-a, --answer Generate an answer to the question based on the results
-w, --web Include web search results alongside local files
--agentic Enable agentic search to automatically refine queries and perform multiple searches
-s, --sync Sync the local files to the store before searching
-d, --dry-run Dry run the search process (no actual file syncing)
--no-rerank Disable reranking of search results
--max-file-size <bytes> Maximum file size in bytes to upload (overrides config)
--max-file-count <count> Maximum number of files to upload (overrides config)

All search options can also be configured via environment variables (see Environment Variables section below).

Examples:

mgrep "What code parsers are available?"  # search in the current directory
mgrep "How are chunks defined?" src/models  # search in the src/models directory
mgrep -m 10 "What is the maximum number of concurrent workers in the code parser?"  # limit the number of results to 10
mgrep -a "What code parsers are available?"  # generate an answer to the question based on the results
mgrep --web --answer "How do I integrate a JavaScript runtime into Deno?"  # search the web and get a summarized answer

mgrep watch

mgrep watch is used to index the current repository and keep the Mixedbread store in sync via file watchers.

It respects the current .gitignore, as well as a .mgrepignore file in the root of the repository. The .mgrepignore file follows the same syntax as the .gitignore file.

Option Description
-d, --dry-run Dry run the watch process (no actual file syncing)
--max-file-size <bytes> Maximum file size in bytes to upload (overrides config)
--max-file-count <count> Maximum number of files to upload (overrides config)

Examples:

mgrep watch  # index the current repository and keep the Mixedbread store in sync via file watchers
mgrep watch --max-file-size 1048576  # limit uploads to files under 1MB
mgrep watch --max-file-count 5000  # limit sync to 5000 changed files or fewer

Mixedbread under the hood

Configuration

mgrep can be configured via config files, environment variables, or CLI flags.

Config File

Create a .mgreprc.yaml (or .mgreprc.yml) in your project root for local configuration, or ~/.config/mgrep/config.yaml (or config.yml) for global configuration.

# Maximum file size in bytes to upload (default: 1MB)
maxFileSize: 5242880

# Maximum number of files to sync (upload/delete) per operation (default: 1000)
maxFileCount: 5000

Configuration precedence (highest to lowest):

  1. CLI flags (--max-file-size, --max-file-count)
  2. Environment variables (MGREP_MAX_FILE_SIZE, MGREP_MAX_FILE_COUNT)
  3. Local config file (.mgreprc.yaml in project directory)
  4. Global config file (~/.config/mgrep/config.yaml)
  5. Default values

Configuration Tips

Environment Variables

All search options can be configured via environment variables, which is especially useful for CI/CD pipelines or when you want to set defaults for all searches.

Authentication & Store

Search Options

Sync Options

Examples:

# Set default max results to 25
export MGREP_MAX_COUNT=25
mgrep "search query"

# Always show content in results
export MGREP_CONTENT=1
mgrep "search query"

# Disable reranking globally
export MGREP_RERANK=0
mgrep "search query"

# Use multiple options together
export MGREP_MAX_COUNT=20
export MGREP_CONTENT=1
export MGREP_ANSWER=1
mgrep "search query"

Note: Command-line options always override environment variables.

Development

pnpm install
pnpm build        # or pnpm dev for a quick compile + run
pnpm format       # biome formatting + linting

Testing

pnpm test

The tests are written using bats.

Troubleshooting

Support

For usage questions, feedback, or other support, please reach out on the Mixedbread Slack.

License

Apache-2.0. See the LICENSE file for details.

mgrep (mixedbread-ai/mgrep)

Searching Database…

4.4K ·GitHub
这是什么?mgrep 是一个 CLI 工具,让你用自然语言对代码、PDF、图片和文本做语义搜索,而不是依赖精确的 grep 式模式。
它是用来取代 grep 的,还是和 grep 搭配用的?它的设计定位是补充而非取代 grep:精确匹配和符号追踪用 grep,基于意图的语义搜索和代码探索用 mgrep。
怎么开始用 mgrep?安装 CLI,通过基于浏览器的设备登录流程登录,运行 'mgrep watch' 为项目建索引(它会遵循 .gitignore),然后直接运行 'mgrep' 或 'mgrep search' 并输入自然语言查询即可。
用它需要 Mixedbread 账号或 API key 吗?需要,mgrep 由 Mixedbread Search 提供支持,需要进行身份验证,可以走浏览器设备登录流程,也可以为 CI/CD 和无头环境设置 MXBAI_API_KEY 环境变量。
它对能索引的内容有限制吗?有,默认情况下每个文件上限 1MB、每个目录最多 1,000 个文件,而且暂不支持音频/视频搜索(目前只有代码、文本、PDF 和图片可用)。这些限制可以通过 CLI 标志、环境变量或配置文件调整。
它和哪些编程智能体集成?它内置了针对 Claude Code、OpenCode、Codex 和 Factory Droid 的安装命令,Cursor 和 Windsurf 集成也在计划中。
mgrep 也能搜索网络,而不只是本地文件吗?可以,使用 --web(或 -w)标志时,它会在搜索本地文件的同时查询 mixedbread/web 存储,并按相关性合并结果,--answer 则给出简明摘要而不是原始命中。
--agentic 模式是干什么用的?它把 mgrep 变成一个 subagent,自动把复杂查询拆成子查询,执行多次搜索,并整合跨文件的发现,适合涉及代码库多个部分的问题。
mgrep 真的能为编程智能体省 token 吗?在一个与 Claude Code 协作的 50 项任务基准测试中,mgrep 消耗的 token 大约是基于 grep 工作流的一半,而评判质量相当或更好,因为它能直接找到相关片段,不用智能体反复尝试各种 grep 模式。
我可以按项目或实验隔离索引吗?可以,--store 标志(或 MXBAI_STORE 环境变量)让你为每个仓库、团队或实验创建独立的 Mixedbread store,store 会按需自动创建。
Size
0.6 MB
Stars
4.4K
Age
11mo
Commits · 90 Days