The Problem
grep matches literal strings, not meaning. Searching a codebase for "where do we set up auth?" requires knowing the exact terms — passport, session, middleware — and even then you get a token match, not an answer. For multimodal content (PDFs, images), grep does not work at all. mgrep replaces that with semantic, natural-language search over your local files, indexed in the background.
What This Does
mgrep is a CLI that indexes a git repository and answers natural-language queries against it. The core loop is mgrep watch to index, then mgrep "your question" to search. It handles code, text, PDFs, and images, with a --web flag for web search. It is built for both humans and coding agents, with a background sync mode that starts and stops with an agent session.
The implementation is TypeScript, organized under src/. The CLI entry point is src/index.ts, which dispatches to subcommands in src/commands/ (search.ts, watch.ts, login.ts, etc.). Core logic lives in src/lib/, including auth.ts for device login, config.ts for settings, and store.ts for the local index.
How It Is Wired
Execution starts at src/index.ts, which parses arguments and dispatches to a command. src/commands/search.ts handles the query path: it reads the local store, sends the query to the Mixedbread API, and prints results. src/commands/watch.ts is the indexing path: it walks the filesystem, respects .gitignore, and syncs changes to the remote store. src/commands/login.ts handles the device-auth flow, writing credentials to a local config.
The central hub is src/lib/store.ts — both search and watch route through it for local state. src/lib/auth.ts is the second most impactful: every network call depends on its token management. The watch command also has a Python hook (plugins/mgrep/hooks/mgrep_watch.py) that manages the background process lifecycle for coding agents.
The wiring is straightforward: CLI command → lib function → network call or filesystem operation. No complex module graph or cycles. The only external dependency is the Mixedbread API, which the CLI calls for both indexing and search. The background sync for agents is the one piece that touches the process lifecycle, via the Python hook scripts.
How To Use It
Setup — install globally:
npm install -g @mixedbread/mgrep
Configuration — sign in once with mgrep login, or set the MXBAI_API_KEY environment variable for headless use.
Running it — index and search:
cd path/to/repo
mgrep watch
mgrep "where do we set up auth?" src/lib
The commands are documented in the README and implemented in src/commands/.
Real-World Use
A developer joins a new codebase. Instead of reading through src/lib/auth.ts to find where sessions are created, they run mgrep watch once, then ask mgrep "how do we validate JWT tokens?". The CLI returns the relevant file and line, cutting the exploration time from minutes to seconds. A CI pipeline can use the same flow with an API key, searching a codebase for security patterns before a release.
Code Health & Issues
No measured static analysis has run for this repo yet. The structure shows: 26 TypeScript files, 4 test files (test/test.bats), CI in .github/workflows/ci.yml, and a license. The dependency on the @mixedbread/mgrep npm package and the remote API means a network call is required for every search — there is no fully local mode in the code. The Python hooks in plugins/ are a separate runtime from the main TypeScript code, which adds a second language to maintain.
The Bottom Line
mgrep solves a real problem — semantic search over local files — with a clean CLI and a simple architecture. The trade-off is the mandatory remote API dependency; if the service goes down, so does search. It is a solid tool for developers and agents working in large codebases, but teams needing fully offline search would need to look elsewhere.