ContextTree MCP
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ContextTree MCPSearch the codebase for payment retry logic and show me the exact locations."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ContextTree MCP π³
Deep semantic code search for AI assistants β powered by AST parsing and local embeddings. 100% offline.
ContextTree MCP is a local Model Context Protocol server that gives your AI coding assistant structural understanding of a codebase. It combines two worlds:
tree-sitter parses source files into an AST and extracts logical blocks β functions, methods, class signatures with docstrings.
sentence-transformers (
all-MiniLM-L6-v2) embeds each block β enriched with file path, class name, method name and docstring β into a local ChromaDB vector store.
The result: your assistant finds code by meaning, not by keywords, and every search hit comes back with exact file path and line numbers.
π Privacy first. Everything runs on your machine: parsing, embedding model, vector index. No cloud calls, no telemetry, no code ever leaves the disk it lives on.
Why not plain text search?
grep and full-text search match strings. They fail exactly where developers need help most:
Task | Text search | ContextTree MCP |
"Where do we validate JWT tokens?" | β needs exact keyword guessing | β
matches |
Find a method whose name was refactored | β broken by rename | β docstring + surrounding context still carry the meaning |
Distinguish definition vs. usage | β impossible without regex gymnastics | β AST-level separation of declarations and call sites |
Return precise locations | β οΈ line of match only | β
|
Ignore comments / strings / imports noise | β | β only real logical units are indexed |
Related MCP server: CodeGrok MCP
Features
π² AST-aware chunking β indexes functions, methods and class signatures via tree-sitter, not arbitrary text windows.
π§© Context-Enriched Logical Blocks β every indexed document embeds its file path, owning class, method name, docstring and body, so queries like "payment retry logic" hit the right method.
β‘ Incremental indexing β SHA-256 content hashes per file; only changed/new/deleted files are reprocessed.
π Semantic search β natural-language query β ranked code fragments with exact line ranges.
π AST usage lookup β find real call sites of any symbol (function or class), filtered from false positives like string literals or comments.
ποΈ Persistent local index β ChromaDB stored in
.chroma/, survives restarts, never committed to Git.π Stdio MCP transport β plugs into Claude Desktop, OpenCode, Cursor, Cline, or any MCP-compatible client.
Tech stack
Layer | Technology |
Language | Python 3.12+ |
Protocol | Official |
AST parsing |
|
Vector database |
|
Embeddings |
|
Installation
Requires Python 3.12+. uv is recommended as a fast, modern package manager:
git clone https://github.com/<your-org>/mcp-context-tree.git
cd mcp-context-tree
# Option A β uv (recommended): resolves dependencies from pyproject.toml, locks uv.lock
uv sync
# Option B β classic pip + venv
python -m venv venv && source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtπ‘ First run downloads the embedding model (~90 MB). PyTorch is installed as a dependency of
sentence-transformers; CPU build is sufficient β no GPU required.
Registering with an MCP client
Example configuration (Claude Desktop / any client supporting stdio servers):
{
"mcpServers": {
"context-tree": {
"command": "<path-to-venv>/bin/python",
"args": ["-m", "context_tree"],
"env": {}
}
}
}(On Windows use <path-to-venv>\Scripts\python.exe.)
Tools exposed to the assistant
Tool | Signature | Description |
|
| Walks the project, detects changed files by hash, incrementally updates the ChromaDB collection. |
|
| Natural-language search over indexed code. Returns enriched snippets with |
|
| AST-based lookup of real call sites / instantiations of a function or class. |
Typical workflow:
1. index_workspace("D:/projects/my-app")
2. semantic_search("where do we handle payment retries", limit=8)
3. find_ast_usages("PaymentGateway.retry")Supported languages
Language | Status |
Python | β supported at launch |
TypeScript / TSX | β supported at launch |
JavaScript / JSX | β supported at launch |
Go, Java, Rustβ¦ | πΊοΈ roadmap β parser registry is designed for extension |
Documentation
ποΈ ARCHITECTURE.md β project layout, ChromaDB data schema, AST extraction logic, incremental indexing design.
π·πΊ README.ru.md β Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΡΠΈΡ Π½Π° ΡΡΡΡΠΊΠΎΠΌ ΡΠ·ΡΠΊΠ΅.
Roadmap
Watch mode β automatic re-indexing on file change (fs watcher)
More languages via tree-sitter bindings
Hybrid search (BM25 + vectors rerank)
Call-graph aware ranking ("who calls this?")
PyPI release (
context-tree-mcp)
Contributing
Issues and PRs are welcome. Please keep changes consistent with ARCHITECTURE.md.
License
MIT β see LICENSE.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityFmaintenanceProvides intelligent semantic code search using local AI embeddings, enabling natural language queries to find relevant code by meaning rather than exact keywords. Indexes codebases in the background with smart project detection and privacy-first local processing.656199MIT
- AlicenseNot gradedqualityFmaintenanceEnables semantic code search for AI assistants by indexing codebases with embeddings and Tree-sitter, returning relevant snippets via natural language queries.15MIT
- AlicenseNot gradedqualityBmaintenanceProvides AI coding assistants with deep, semantic understanding of local codebases via AST-aware chunking, cross-repo symbol graphs, and architectural memory, enabling context-aware code search and dependency tracing.10MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to perform intelligent semantic code search across codebases using local AI embeddings for meaning-based retrieval.56MIT
Related MCP Connectors
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Give your AI agent a persistent map of your project's structure, dependencies, and bugs.
Persistent memory and knowledge graph for AI assistants β keyword + vector + graph search.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/chelslava/mcp-context-tree'
If you have feedback or need assistance with the MCP directory API, please join our Discord server