code-dna-tracker
Tracks the complete lineage and DNA of every line of code, enabling impact analysis, bug risk prediction, and code archaeology through deterministic analysis of git history and AST.
README
Code DNA Tracker
An MCP (Model Context Protocol) server that tracks the complete lineage and DNA of every line of code — who wrote it, when, why, what PRs modified it, what bugs it introduced/fixed, and how it has evolved over time.
Features
- Lineage Tracking: Complete history of every line of code
- Impact Analysis: Blast radius and dependency analysis
- Code Archaeology: Find zombie code, abandoned code, hot spots, and orphan code
- Bug Risk Prediction: Predict which lines are likely to cause bugs
- Incremental Updates: Only re-process files that changed since last analysis
- Multi-Platform: Works with Claude Code, Cursor, OpenCode, Cline, and any MCP-compatible host
- Deterministic: No LLMs, no API keys, no external costs — works fully offline
Installation
pip install code-dna-tracker
Or from source:
git clone https://github.com/sebachriss/code-dna-tracker.git
cd code-dna-tracker
pip install -e .
Requirements:
- Python 3.10+
- Git repository to analyze
Usage
As MCP Server
Code DNA Tracker works with any MCP-compatible host. Configure it once and use it everywhere.
Claude Code (~/.config/claude-code/mcp_config.json):
{
"mcpServers": {
"code-dna-tracker": {
"command": "python",
"args": ["-m", "code_dna_tracker.mcp.server"],
"env": {
"CODE_DNA_REPO_PATH": "/path/to/your/repository"
}
}
}
}
Cursor (Settings → MCP):
{
"mcpServers": {
"code-dna-tracker": {
"command": "python",
"args": ["-m", "code_dna_tracker.mcp.server"],
"env": {
"CODE_DNA_REPO_PATH": "/path/to/your/repository"
}
}
}
}
See MCP_CONFIG_EXAMPLES.md for configuration examples for OpenCode, Cline, and other platforms.
CLI Usage
# Initialize tracking for a repository
code-dna init ./my-repo
# Update tracking incrementally (only changed files)
code-dna update ./my-repo
# Get line DNA
code-dna get-line-dna ./my-repo path/to/file.py 42
# Get file DNA summary
code-dna get-file-dna ./my-repo path/to/file.py
# Calculate blast radius of a line change
code-dna blast-radius ./my-repo path/to/file.py 42
# Predict bug risk of a line
code-dna bug-risk ./my-repo path/to/file.py 42
# Find zombie code (files not modified in over 1 year)
code-dna zombie-code ./my-repo --days 365
# Analyze overall code health
code-dna code-health ./my-repo
# Launch web dashboard
code-dna web ./my-repo
MCP Tools
Lineage Tools
get_line_dna: Get complete DNA of a specific line including author, commit, function context, and modification historyget_file_dna: Get DNA summary for a file including commit history and structureinit_repository: Initialize tracking for a repository (parses all files and builds database)update_repository: Update tracking incrementally — only re-parses files that changed since last analysis
Impact Analysis Tools
get_blast_radius: Calculate what other code is affected if a specific line changespredict_bug_risk: Predict bug risk for a line based on modification history and complexity
Code Archaeology Tools
find_zombie_code: Find files that haven't been modified in a long time (default: 365 days)find_abandoned_code: Find functions whose original authors have been inactive (default: 180 days)find_hot_spots: Find files that change frequently and may be unstablefind_orphan_code: Find functions/classes that are never called or importedanalyze_code_health: Get overall code health score with recommendations
Architecture
code_dna_tracker/
├── core/ # Core analysis engine
│ ├── git_analyzer.py # Git operations and blame analysis
│ ├── ast_parser.py # Tree-sitter based code parsing
│ ├── lineage_builder.py # Combines git and AST data
│ ├── impact_calculator.py # Dependency and blast radius analysis
│ ├── code_archaeologist.py # Code health and archaeology
│ └── file_utils.py # Code file discovery with exclusions
├── storage/ # Data persistence
│ └── database.py # SQLite storage layer
├── mcp/ # MCP server
│ └── server.py # MCP tools and protocol implementation
├── web/ # Web UI dashboard
│ ├── app.py # FastAPI backend
│ └── static/ # Frontend (HTML/CSS/JS)
└── cli.py # Command-line interface
Components
- Git Analyzer: Extracts commit history, blame information, and file modifications from Git
- AST Parser: Parses code using Tree-sitter to extract functions, classes, imports, and variables
- Lineage Builder: Combines Git and AST data to build the complete DNA of each line
- Impact Calculator: Builds dependency graphs and calculates blast radius and bug risk
- Code Archaeologist: Analyzes code for zombie code, abandoned code, hot spots, orphan code, and overall health
- Storage Layer: Persists analysis data in SQLite for fast queries
How It Works
- Initialization:
code-dna initparses all code files in a repository, extracts git blame for each line, and stores the data in SQLite - Incremental Update:
code-dna updatedetects files changed since the last analyzed commit and only re-processes those, keeping updates fast - Query: The MCP server reads from the database and runs real-time analysis when tools are called
- Analysis: Combines git history, AST structure, and graph algorithms to provide insights
Supported Languages
- Python (
.py) - JavaScript (
.js,.jsx) - TypeScript (
.ts,.tsx) - Go (
.go) - Rust (
.rs) - Java (
.java)
More languages can be added by including additional Tree-sitter grammars.
Cost
Code DNA Tracker is a deterministic tool that does not use LLMs. The only cost is local computation time.
- No API keys required
- No LLM costs
- Works offline
Development
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -e ".[dev]"
# Run tests
pytest
Roadmap
- [x] Core lineage tracking
- [x] Impact analysis
- [x] Code archaeology
- [x] Incremental updates
- [x] Multi-language support (Python, JS, TS, Go, Rust, Java)
- [x] Web UI dashboard
- [ ] IDE extensions
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。