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
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.