embgrep
Provides local semantic search over files using embeddings, enabling directory indexing and natural language queries without external services.
README
embgrep
Local semantic search — embedding-powered grep for files, zero external services.
Search your codebase and documentation by meaning, not just keywords. embgrep indexes files into local embeddings and lets you run semantic queries — no API keys, no cloud services, no vector database servers.
Features
- Local embeddings — Uses fastembed (ONNX Runtime), no API keys needed
- SQLite storage — Single-file index, no external vector DB
- Incremental indexing — Only re-indexes changed files (SHA-256 hash comparison)
- Smart chunking — Function-level splitting for code, heading-level for docs
- MCP native — 4-tool FastMCP server for LLM agent integration
- 15+ file types —
.py,.js,.ts,.java,.go,.rs,.md,.txt,.yaml,.json,.toml, and more
Install
pip install embgrep # core (fastembed + numpy)
pip install embgrep[cli] # + click/rich CLI
pip install embgrep[mcp] # + FastMCP server
pip install embgrep[all] # everything
Quick Start
Python API
from embgrep import EmbGrep
eg = EmbGrep()
# Index a directory
eg.index("./my-project", patterns=["*.py", "*.md"])
# Semantic search
results = eg.search("database connection pooling", top_k=5)
for r in results:
print(f"{r.file_path}:{r.line_start}-{r.line_end} (score: {r.score:.4f})")
print(f" {r.chunk_text[:80]}...")
# Incremental update (only changed files)
eg.update()
# Index statistics
status = eg.status()
print(f"{status.total_files} files, {status.total_chunks} chunks, {status.index_size_mb} MB")
eg.close()
CLI
# Index a project
embgrep index ./my-project --patterns "*.py,*.md"
# Search
embgrep search "error handling patterns"
# Filter by file type
embgrep search "async database query" --path-filter "%.py"
# Check status
embgrep status
# Update changed files
embgrep update
Convenience functions
import embgrep
embgrep.index("./src")
results = embgrep.search("authentication middleware")
status = embgrep.status()
embgrep.update()
MCP Server
Add to your Claude Desktop / MCP client configuration:
{
"mcpServers": {
"embgrep": {
"command": "embgrep-mcp"
}
}
}
Or with uvx:
{
"mcpServers": {
"embgrep": {
"command": "uvx",
"args": ["--from", "embgrep[mcp]", "embgrep-mcp"]
}
}
}
MCP Tools
| Tool | Description |
|---|---|
index_directory |
Index files in a directory for semantic search |
semantic_search |
Search indexed files using natural language |
index_status |
Get current index statistics |
update_index |
Incremental update — re-index changed files only |
How It Works
flowchart TD
A["📁 Files"] --> B["Smart Chunking\ncode: function-level\ndocs: heading-level"]
B --> C["fastembed\nlocal embeddings"]
C --> D["SQLite\nvector index"]
D --> E["🔍 Query"]
E --> F["Cosine Similarity\nranked results"]
F --> G["✅ Matches\nwith context"]
-
Chunking — Files are split into semantically meaningful chunks:
- Code files (
.py,.js,.ts, etc.): split by function/class boundaries - Documents (
.md,.txt): split by headings or paragraph breaks - Config files: fixed-size chunking
- Code files (
-
Embedding — Each chunk is converted to a 384-dimensional vector using BGE-small-en-v1.5 via ONNX Runtime (no PyTorch needed)
-
Storage — Embeddings are stored as BLOBs in a local SQLite database
-
Search — Query text is embedded and compared against all chunks using cosine similarity
Configuration
| Parameter | Default | Description |
|---|---|---|
db_path |
~/.local/share/embgrep/embgrep.db |
SQLite database location |
model |
BAAI/bge-small-en-v1.5 |
fastembed model name |
max_chunk_size |
1000 chars | Maximum chunk size for fixed-size splitting |
top_k |
5 | Number of search results |
QuartzUnit Ecosystem
| Package | Description |
|---|---|
| markgrab | HTML/YouTube/PDF/DOCX to LLM-ready markdown |
| snapgrab | URL to screenshot + metadata |
| docpick | OCR + LLM document structure extraction |
| browsegrab | Local LLM browser agent |
| feedkit | RSS feed collection + MCP |
| embgrep | Local semantic search for files |
Used in
- newswatch — RSS news monitoring pipeline (feedkit → markgrab → embgrep → diffgrab)
License
MIT
<!-- mcp-name: io.github.QuartzUnit/embgrep -->
<sub>Part of the QuartzUnit ecosystem — composable Python libraries for data collection, extraction, search, and AI agent safety.</sub>
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。