Efficient code indexing and symbol retrieval using tree-sitter AST parsing.
astllm-mcp
MCP server for efficient code indexing and symbol retrieval. Index GitHub repos or local folders once with tree-sitter AST parsing, then let AI agents retrieve only the specific symbols they need — instead of loading entire files.
Simple 1 file binary distribution for trivial deployments.
Cut code-reading token costs by up to 99%.
How it works
- Index — fetch source files, parse ASTs with tree-sitter, store symbols with byte offsets
- Explore — browse file trees and outlines without touching file content
- Retrieve — fetch only the exact function/class/method you need via O(1) byte-offset seek
- Savings — every response reports tokens saved vs loading raw files
The index is stored locally in ~/.code-index/ (configurable). Incremental re-indexing only re-parses changed files.
The server automatically indexes the working directory on startup (incremental, non-blocking). Optionally set ASTLLM_WATCH=1 to also watch for file changes and re-index automatically. The watcher skips noisy directories (node_modules, .git, dist, .next, etc.) by default — see Watch excludes below.
Supported languages
Python, JavaScript, TypeScript, TSX, Go, Rust, Java, PHP, Dart, C#, C, C++, Dart/Flutter, Swift
Installation
Option 1: Download a pre-built binary (recommended)
Download the binary for your platform from the GitHub Releases page:
| Platform | File |
|---|---|
| macOS ARM (M1/M2/M3) | astllm-mcp-macosx-arm |
| Linux x86-64 | astllm-mcp-linux-x86 |
| Linux ARM64 | astllm-mcp-linux-arm |
# Example for Linux x86-64
curl -L https://github.com/tluyben/astllm-mcp/releases/latest/download/astllm-mcp-linux-x86 -o astllm-mcp
chmod +x astllm-mcp
./astllm-mcp # runs as an MCP stdio server
No Node.js, no npm, no build tools required.
Option 2: Build from source
Requires Node.js 18+ and a C++20-capable compiler (for tree-sitter native bindings).
git clone https://github.com/tluyben/astllm-mcp
cd astllm-mcp
CXXFLAGS="-std=c++20" npm install --legacy-peer-deps
npm run build
Note on Node.js v22+: The
CXXFLAGS="-std=c++20"flag is required because Node.js v22+ v8 headers mandate C++20. The--legacy-peer-depsflag is needed because tree-sitter grammar packages target slightly different tree-sitter core versions.
MCP client configuration
Claude Code
Option A — claude mcp add CLI (easiest):
# Pre-built binary, project-scoped (.mcp.json)
claude mcp add astllm /path/to/astllm-mcp-linux-x86 --scope project
# Pre-built binary, user-scoped (~/.claude.json)
claude mcp add astllm /path/to/astllm-mcp-linux-x86 --scope user
# From source (Node.js), project-scoped
claude mcp add astllm node --args /path/to/astllm-mcp/dist/index.js --scope project
Option B — manual JSON config:
Add to ~/.claude.json (global) or .mcp.json in your project root (project-scoped):
Pre-built binary:
{
"mcpServers": {
"astllm": {
"command": "/path/to/astllm-mcp-linux-x86",
"type": "stdio"
}
}
}
From source (Node.js):
{
"mcpServers": {
"astllm": {
"command": "node",
"args": ["/path/to/astllm-mcp/dist/index.js"],
"type": "stdio"
}
}
}
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
Pre-built binary:
{
"mcpServers": {
"astllm": {
"command": "/path/to/astllm-mcp-macosx-arm"
}
}
}
From source (Node.js):
{
"mcpServers": {
"astllm": {
"command": "node",
"args": ["/path/to/astllm-mcp/dist/index.js"]
}
}
}
Tools
Indexing
`index_repo`
Index a GitHub repository. Fetches source files via the GitHub API, parses ASTs, stores symbols locally.
repo_url GitHub URL or "owner/repo" slug
generate_summaries Generate one-line AI summaries (requires API key, default: false)
incremental Only re-index changed files (default: true)
storage_path Custom storage directory
`index_folder`
Index a local folder recursively.
folder_path Path to index
generate_summaries AI summaries (default: false)
extra_ignore_patterns Additional gitignore-style patterns
follow_symlinks Follow symlinks (default: false)
incremental Only re-index changed files (default: true)
storage_path Custom storage directory
Navigation
`list_repos`
List all indexed repositories with file count, symbol count, and last-indexed time.
`get_repo_outline`
High-level overview: directory breakdown, language distribution, symbol kind counts.
repo Repository identifier ("owner/repo" or short name if unique)
`get_file_tree`
File and directory structure with per-file language and symbol count. M
Tools (5)
index_repoIndex a GitHub repository by fetching source files, parsing ASTs, and storing symbols locally.index_folderIndex a local folder recursively.list_reposList all indexed repositories with file count, symbol count, and last-indexed time.get_repo_outlineGet a high-level overview of a repository including directory breakdown and symbol kind counts.get_file_treeGet file and directory structure with per-file language and symbol count.Environment Variables
ASTLLM_WATCHSet to 1 to watch for file changes and re-index automatically.Configuration
{"mcpServers": {"astllm": {"command": "/path/to/astllm-mcp-macosx-arm"}}}