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.

pip install 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 16 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

16 tools for autonomous agents

Understand Structure

get_file_skeletonClasses + signatures with line numbers
get_symbolFull source of one function or class
get_skeletonsBatch skeletons for multiple files
get_symbolsBatch source for multiple symbols
get_importsImport statements with line numbers

Navigate Relationships

find_referencesEvery usage across the repo
get_call_graphWhat calls what
get_blast_radiusTransitive impact analysis
rank_symbolsPageRank importance

Analyze Quality

get_complexityCyclomatic complexity
find_dead_codeUnused symbols
detect_clonesDuplicate functions

Inspect & Test

search_symbolsFlexible filtered search
get_astRaw AST as S-expression
find_testsTests for any symbol
get_variablesParams + locals

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 -- \
  codetree --root /path/to/project
// .cursor/mcp.json
{
  "mcpServers": {
    "codetree": {
      "command": "codetree",
      "args": ["--root", "/path/to/project"]
    }
  }
}
// .vscode/mcp.json
{
  "servers": {
    "codetree": {
      "command": "codetree",
      "args": ["--root", "/path/to/project"]
    }
  }
}
// ~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "codetree": {
      "command": "codetree",
      "args": ["--root", "/path/to/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 25x token reduction
grep / ripgrep Text only, no AST awareness Understands code structure
LSP servers Heavyweight, stateful One pip install, 10 languages
SCIP / LSIF Slow index, complex setup ~1s startup, zero config

Get started

# Install
$ pip install codetree

# Run on your project
$ codetree --root .

# Add to Claude Code
$ claude mcp add codetree -- codetree --root .
View on GitHub →