Skip to main content
Glama
chelslava

ContextTree MCP

by chelslava

ContextTree MCP 🌳

Deep semantic code search for AI assistants β€” powered by AST parsing and local embeddings. 100% offline.

Python License: MIT MCP README (RU)

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.


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 AuthService.verify_token() even if "validate" never appears in code

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

βœ… file, class, method, start_line, end_line metadata

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 mcp SDK (stdio transport)

AST parsing

tree-sitter + bindings for Python, TypeScript, JavaScript

Vector database

chromadb (local persistent mode)

Embeddings

sentence-transformers Β· all-MiniLM-L6-v2

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

index_workspace

(directory_path: str)

Walks the project, detects changed files by hash, incrementally updates the ChromaDB collection.

semantic_search

(query: str, limit: int = 5)

Natural-language search over indexed code. Returns enriched snippets with file, class, start_line, end_line.

find_ast_usages

(symbol_name: str)

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.

Install Server
A
license - permissive license
A
quality
B
maintenance

Maintenance

–Maintainers
<1hResponse time
–Release cycle
–Releases (12mo)
Commit activity

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

  • A
    license
    A
    quality
    F
    maintenance
    Provides 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.
    6
    56
    199
    MIT
  • A
    license
    Not graded
    quality
    F
    maintenance
    Enables semantic code search for AI assistants by indexing codebases with embeddings and Tree-sitter, returning relevant snippets via natural language queries.
    15
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Provides 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.
    10
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to perform intelligent semantic code search across codebases using local AI embeddings for meaning-based retrieval.
    56
    MIT

View all related MCP servers

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.

View all MCP Connectors

Latest Blog Posts

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