claude-context-local
Provides Claude Code with local semantic search and indexing of your codebase using AST-aware chunking and hybrid search, enabling deep code understanding without sending data to the cloud.
README
claude-context-local
Your entire codebase as context. A local MCP server that gives Claude Code deep semantic understanding of your codebase — without sending a single byte to the cloud.
claude-context-local uses AST-aware chunking and hybrid semantic+keyword search to find all relevant code from your entire codebase. No multi-round file discovery needed. It brings results straight into Claude's context.
Cost-effective for large codebases: Instead of loading entire directories into Claude for every request (which can be very expensive), claude-context-local efficiently stores your codebase in a local vector database and only retrieves the code that's actually relevant — keeping your token usage manageable.
A lightweight alternative to zilliztech/claude-context that uses local embeddings instead of OpenAI + Zilliz Cloud.
Features
- 100% local — no API keys, no cloud, no data leaves your machine
- AST-aware chunking — splits code at function/class boundaries using tree-sitter (9+ languages), not arbitrary line counts
- Hybrid search — BM25 keyword + semantic embedding for best-of-both-worlds results
- Language-aware metadata — search results include language, symbol name, and symbol type
- Symbol dependency graph — "who calls this function?" / "what does this function call?"
- Auto-reindex — file watcher detects changes and re-indexes in the background
- Multi-project search — search across all your indexed projects at once
- Context-aware results — see surrounding code lines for better understanding
- Diff-aware search — search only code that changed since a git ref
- Lightweight — ONNX embeddings (~200 MB RAM, no PyTorch required)
.gitignore-aware — respects your project's gitignore patterns- Per-project isolation — each project gets its own index
- Incremental indexing — only re-indexes changed files (MD5 hash)
- 40+ file types supported out of the box
Quick start
claude mcp add claude-context-local -- uvx claude-context-local
That's it. Restart Claude Code and the tools are available.
Alternative: pip
pip install claude-context-local
claude mcp add claude-context-local -- claude-context-local
Alternative: from source
git clone https://github.com/tazhate/claude-context-local.git
cd claude-context-local
pip install -e .
claude mcp add claude-context-local -- claude-context-local
MCP Tools
| Tool | Description |
|---|---|
index_project(project_path) |
Index a codebase with AST-aware chunking. Incremental by default, force=True to rebuild. watch=True to auto-reindex on file changes. |
search_code(query, project_path) |
Hybrid semantic+keyword search. Supports file_filter, symbol_type, and context_lines. |
search_all(query) |
Search across ALL indexed projects at once. |
search_diff(project_path, query, ref) |
Search only code changed since a git ref (commit/branch/tag). |
find_symbol(symbol_name, project_path) |
Find who calls a function (callers) or what it calls (callees). |
index_status(project_path) |
Show index stats: files, chunks, languages, symbols, watcher status. |
drop_index(project_path) |
Remove project index and stop watcher. |
Usage examples
Once connected, Claude Code will automatically use these tools. You can also ask directly:
- "Index this project" — triggers
index_project - "Search for authentication logic" — semantic search across your codebase
- "Find all Python functions related to caching" —
search_codewithfile_filter="*.py"andsymbol_type="function" - "Who calls the validate_email function?" — triggers
find_symbol - "What changed since yesterday?" — triggers
search_diff - "Search for error handling across all my projects" — triggers
search_all
How it works
┌───────────────┐
│ tree-sitter │
│ AST parser │
└───────┬───────┘
│
┌─────────────┐ ┌──────────────┴───────┐ ┌──────────┐
│ Claude Code │────>│ claude-context-local │────>│ ChromaDB │
│ (MCP client)│<────│ (MCP server) │<────│ (vectors)│
└─────────────┘ └──────────────┬───────┘ └──────────┘
│ │ │
┌────┴┐ ┌┴───┐ ┌┴────────┐
│ ONNX│ │BM25│ │ Symbol │
│embed│ │keys│ │ Graph │
└─────┘ └────┘ └─────────┘
- Index: Walk project files → parse AST with tree-sitter → split at function/class boundaries → embed with ONNX model + build BM25 index + build symbol call graph → store in ChromaDB
- Search: Hybrid — cosine similarity (semantic) + BM25 (keyword) merged with configurable alpha → ranked results with file paths, line numbers, language, symbol info
- Incremental: MD5 hash per file — only changed files are re-processed
- Watch:
watchfilesmonitors your project directory and triggers incremental re-index on save
AST-aware chunking
Traditional tools split files at arbitrary line boundaries, cutting functions in half. claude-context-local uses tree-sitter to parse code into AST and split at natural boundaries:
| Language | Supported symbols |
|---|---|
| Python | functions, classes, decorated definitions |
| Go | functions, methods, types |
| JavaScript/TypeScript | functions, classes, exports, interfaces |
| Rust | functions, structs, impls, enums, traits |
| Java | methods, classes, interfaces |
| C/C++ | functions, structs, classes, namespaces |
| Ruby | methods, classes, modules |
| PHP | functions, classes, methods |
| Bash | functions |
Files without tree-sitter support fall back to overlapping line-based chunking.
Per-project isolation
Each project gets its own ChromaDB database under ~/.cache/claude-context-local/<hash>/, where <hash> is derived from the absolute project path. Projects never mix.
Configuration
Environment variables (pass via claude mcp add -e KEY=VALUE):
| Variable | Default | Description |
|---|---|---|
CCL_MODEL |
all-MiniLM-L6-v2 |
Embedding model (default uses built-in ONNX, no PyTorch) |
CCL_HYBRID_ALPHA |
0.7 |
Search blend: 0=BM25 only, 1=semantic only |
CCL_CHUNK_LINES |
50 |
Max lines per chunk |
CCL_CHUNK_OVERLAP |
10 |
Overlap lines between chunks |
CCL_CONTEXT_LINES |
5 |
Default surrounding context lines in results |
CCL_DATA_DIR |
~/.cache/claude-context-local |
Index storage directory |
Custom model example
# Use a code-specific model (requires: pip install claude-context-local[gpu])
claude mcp add claude-context-local \
-e CCL_MODEL=jinaai/jina-embeddings-v2-base-code \
-- uvx claude-context-local
# More keyword-heavy search
claude mcp add claude-context-local \
-e CCL_HYBRID_ALPHA=0.4 \
-- uvx claude-context-local
Resource usage
| Resource | Default (ONNX) | With [gpu] (PyTorch) |
|---|---|---|
| RAM | ~200 MB | ~780 MB |
| Model on disk | 80 MB | 88 MB |
| Install size | ~310 MB | ~2 GB |
| Index size | ~27 MB per 500 files | same |
| CPU | Near zero at idle | same |
| First index | ~2 min for 500 files | same |
Supported file types
Code: .py .go .js .ts .tsx .jsx .rs .java .kt .c .cpp .h .hpp .cs .rb .php .swift .scala .sh .bash .lua .zig .nim .ex .exs .erl .nix
Config: .yaml .yml .toml .json .hcl .tf .sql .graphql .proto
Docs: .md .txt .rst
Web: .html .css .scss .less
Other: Dockerfile, Makefile
Comparison with zilliztech/claude-context
| claude-context-local | zilliztech/claude-context | |
|---|---|---|
| Embeddings | Local (ONNX, no PyTorch) | OpenAI API |
| Vector DB | Local (ChromaDB) | Zilliz Cloud |
| Hybrid search | BM25 + semantic | BM25 + semantic |
| AST chunking | tree-sitter (9+ languages) | No |
| Symbol graph | Yes (who calls / what calls) | No |
| Auto-reindex | Yes (file watcher) | No |
| Multi-project | Yes | No |
| Diff search | Yes (git-aware) | No |
| Context lines | Yes | No |
| API keys needed | None | OpenAI + Zilliz |
| Data privacy | 100% local | Cloud |
| Setup | One command | Multiple API keys |
| Cost | Free | Pay per use |
| Search quality | Good | Better (larger models) |
| .gitignore | Yes | No |
| RAM usage | ~200 MB | ~50 MB (Node.js) |
Security
- All data stays local — no network calls, no telemetry, no cloud
- Index files stored under
~/.cache/with user-only permissions - No secrets or credentials are ever indexed (lock files,
.envexcluded) - CI runs pip-audit and bandit on every push
Development
git clone https://github.com/tazhate/claude-context-local.git
cd claude-context-local
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest -v
License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。