ContextTree MCP
Enables AI coding assistants to perform local semantic code search using AST parsing and embeddings, finding code by meaning with exact file and line locations, plus AST-based usage lookup.
README
ContextTree MCP π³
Deep semantic & hybrid 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 three powerful pillars:
- tree-sitter parses source files into an AST and extracts logical blocks β functions, methods, and class/struct signatures with docstrings.
- Hybrid Search (BM25 + Dense Vectors with Reciprocal Rank Fusion) β combines exact keyword/identifier matches (
camelCase,snake_case) with dense vector embeddings (sentence-transformers/all-MiniLM-L6-v2in ChromaDB). - Watch Mode & Incremental Indexing β SHA-256 hash change detection and asynchronous filesystem watcher for instant updates on save.
π 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.
Supported Languages
| Language | Extensions | AST Units Indexed |
|---|---|---|
| Python | .py |
functions, decorated functions, methods, class signatures & PEP-257 docs |
| TypeScript / TSX | .ts, .tsx, .mts, .cts |
functions, methods, class signatures & JSDoc |
| JavaScript / JSX | .js, .jsx, .mjs, .cjs |
functions, methods, class signatures & JSDoc |
| Go | .go |
functions, receiver methods, struct/interface types & comments |
| Rust | .rs |
functions, impl methods, struct & trait signatures, /// docs |
| C# | .cs |
methods, constructors, class & interface signatures, /// <summary> XML-docs |
| Java | .java |
methods, constructors, class, interface & record signatures, Javadoc |
Installation & Quick Start
Requires Python 3.12+. uv is recommended:
git clone https://github.com/chelslava/mcp-context-tree.git
cd mcp-context-tree
uv sync
Running the Server
# Standard stdio server (for MCP clients)
uv run context-tree
# Watch mode (monitors directory and incrementally indexes on save)
uv run context-tree --watch /path/to/project
Registering with MCP Clients
Example configuration (claude_desktop_config.json or Antigravity / Cursor configs):
{
"mcpServers": {
"context-tree": {
"command": "uv",
"args": ["run", "--directory", "D:/Repo/mcp-context-tree", "context-tree"]
}
}
}
Tools Exposed to Assistant
| Tool | Parameters | Description |
|---|---|---|
index_workspace |
(directory_path: str = ".") |
Scans workspace, diffs against index state, incrementally indexes changed files. |
semantic_search |
(query: str, limit: int = 5, mode: str = "hybrid") |
Hybrid (BM25 + vectors), semantic-only, or keyword search. Returns exact line snippets. |
find_ast_usages |
(symbol_name: str, limit: int = 50) |
AST lookup of real call sites / instantiations (filters out string literals & comments). |
License
MIT β see LICENSE.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.