MCP Server for Code Intelligence

Stop feeding entire files
to your AI agent.

codetree gives coding agents structured code understanding via tree-sitter — so they ask precise questions instead of reading thousands of lines. 23 tools, 10 languages, ~1 second startup.

pip install mcp-server-codetree
View on GitHub →

Instead of cat main.py (500 lines, 12K tokens), your agent calls get_file_skeleton("main.py") and gets 15 lines of structured output.

calculator.py
$ cat calculator.py
import math from typing import Optional class Calculator: """A scientific calculator with memory.""" def __init__(self): self.memory = 0 self.history = [] def add(self, a: float, b: float) -> float: """Add two numbers.""" result = a + b self.history.append(('add', a, b, result)) return result def divide(self, a: float, b: float): if b == 0: return None result = a / b self.history.append(('divide', a, b, result)) return result
~2,000 tokens
with codetree
$ get_file_skeleton("calculator.py")
class Calculator → line 4 "A scientific calculator with memory." def __init__(self) → line 7 def add(self, a: float, b: float) → line 11 "Add two numbers." def divide(self, a: float, b: float) → line 17 "Divide a by b, returns None on zero." def sqrt(self, x: float) → line 24 "Square root using math.sqrt."
~80 tokens

The problem with coding agents today

They understand code the same way a human greps through a codebase — raw text with no structure.

Read entire files to find one function Wastes context window tokens
Grep for function names across files Misses structural relationships
Guess what a function calls No call graph visibility
Can't tell what breaks if they change something No impact analysis
Read the same boilerplate across similar functions No deduplication awareness
Don't know which symbols matter most No importance ranking

How codetree works

Sits between the agent and the repo. Parses every file with tree-sitter. Exposes 23 structured tools over MCP.

Agent asks a question
MCP tool call e.g. get_file_skeleton
codetree → tree-sitter parses the file
Structured answer back to the agent
~1 second startup Smart caching with mtime invalidation
Zero dependencies No vector DB, no embedding model, no daemon
One-line install pip install codetree — that's it

23 tools for autonomous agents

Every tool an agent needs to navigate, understand, and safely change a codebase.

Understand Structure

5 tools
get_file_skeleton Classes, functions, methods with line numbers and doc comments
get_symbol Full source of a function or class
get_skeletons Batch skeletons for multiple files
get_symbols Batch source for multiple symbols
get_imports Import statements with line numbers

Navigate Relationships

3 tools
find_references All usages of a symbol across the repo
get_call_graph What a function calls and what calls it
get_blast_radius Transitive impact — what breaks if you change this

Analyze Quality

3 tools
get_complexity Cyclomatic complexity breakdown
find_dead_code Symbols defined but never referenced
detect_clones Duplicate or near-duplicate functions

Onboarding & Graph

4 tools
index_status Graph index freshness and stats
get_repository_map Compact repo overview: languages, entry points, hotspots
resolve_symbol Disambiguate short name into ranked qualified matches
search_graph Graph search with degree filters and pagination

Change & Dataflow

2 tools
get_change_impact Impact analysis via symbol or git diff, with risk levels
analyze_dataflow Variable dataflow, taint analysis, or cross-function tracing

Visualization & History

4 tools
find_hot_paths High-complexity x high-call-count optimization targets
get_dependency_graph File-level dependency graph as Mermaid or list
git_history Git blame, file churn, or change coupling analysis
suggest_docs Find undocumented functions with context for doc generation

10 languages

All backed by official tree-sitter grammars. Adding a language is mechanical — copy a template, implement 5 methods, register.

Python JavaScript TypeScript TSX Go Rust Java C C++ Ruby

Works everywhere

MCP over stdio. Any editor or tool that supports the Model Context Protocol.

claude mcp add codetree -- \
  uvx --from mcp-server-codetree codetree --root .
// .cursor/mcp.json
{
  "mcpServers": {
    "codetree": {
      "command": "uvx",
      "args": ["--from", "mcp-server-codetree",
               "codetree", "--root",
               "${workspaceFolder}"]
    }
  }
}
// .vscode/mcp.json
{
  "servers": {
    "codetree": {
      "command": "uvx",
      "args": ["--from", "mcp-server-codetree",
               "codetree", "--root",
               "${workspaceFolder}"]
    }
  }
}
// ~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "codetree": {
      "command": "uvx",
      "args": ["--from", "mcp-server-codetree",
               "codetree", "--root",
               "${workspaceFolder}"]
    }
  }
}
// claude_desktop_config.json
{
  "mcpServers": {
    "codetree": {
      "command": "uvx",
      "args": ["--from", "mcp-server-codetree",
               "codetree", "--root",
               "/path/to/your/project"]
    }
  }
}
0 MCP tools
0 Languages
~1s Startup
0 Tests passing

Why not just use [X]?

Alternative Limitation codetree advantage
Reading files directly Burns tokens, no structure, no relationships 25x token reduction, structured output
grep / ripgrep Text only, no AST awareness, no call graphs Understands code structure, not just text
LSP servers Heavyweight, stateful, language-specific One command, 10 languages, stateless MCP
SCIP / LSIF Slow builds, complex setup, huge indexes ~1s startup, JSON cache, zero config
AST-only tools Raw trees are verbose, hard for agents Pre-structured output designed for agents

Get started

# Add to Claude Code (recommended)
$ claude mcp add codetree -- uvx --from mcp-server-codetree codetree --root .

# Or install via pip
$ pip install mcp-server-codetree
View on GitHub →