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
Instead of cat main.py (500 lines, 12K tokens), your agent calls get_file_skeleton("main.py") and gets 15 lines of structured output.
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
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."
The problem with coding agents today
They understand code the same way a human greps through a codebase — raw text with no structure.
How codetree works
Sits between the agent and the repo. Parses every file with tree-sitter. Exposes 23 structured tools over MCP.
23 tools for autonomous agents
Every tool an agent needs to navigate, understand, and safely change a codebase.
Understand Structure
5 toolsget_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 toolsfind_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 toolsget_complexity
Cyclomatic complexity breakdown
find_dead_code
Symbols defined but never referenced
detect_clones
Duplicate or near-duplicate functions
Inspect & Search
2 toolssearch_symbols
Flexible symbol search with filters
find_tests
Find test functions for a symbol
Onboarding & Graph
4 toolsindex_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 toolsget_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 toolsfind_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.
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"]
}
}
}
Why not just use [X]?
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