Codebase Archaeology MCP
Enables tracing any line in a local git repository back to the commit that actually introduced it and the PR/review discussion behind it, overcoming git blame's misleading last-touch attribution.
README
Codebase Archaeology MCP
An MCP server that answers "why is this line here?" for a local git repo by tracing a line back to the commit that actually introduced it, then to the PR and review discussion behind that commit.
The problem
git blame attributes a line to whoever last touched it. In real repos
that is usually a formatter run, an import reorder, or a rename. The naive
pipeline — blame → commit → PR — returns "Bob, prettier migration, 2024"
and tells you nothing about intent.
This server defeats that:
- blame runs with
-w -C -C(whitespace ignored, moved/copied code followed) and honours.git-blame-ignore-revs. - line history follows a range backwards through edits and renames
(
git log -L), detects cosmetic commits (git show -wproduces no output → the change was whitespace-only), and compensates for-Lrange drift, solikely_originis the commit that genuinely introduced the content — not the formatter, and not the neighboring lines' history. - PR lookup uses GitHub's
commits/{sha}/pullsendpoint, which works for squash and rebase merges where commit-message parsing silently fails. - When the trace bottoms out at the commit that created the file, the
answer says so —
git log -Lcannot see across a file split, and pretending otherwise would be lying.
Tools
| Tool | Question it answers |
|---|---|
why_this_line(repo, path, line, context=0) |
Start here. The whole story: last touch, true origin, evolution, origin PR + review discussion, and an interpretation when blame's answer is misleading. |
blame_range(repo, path, start, end) |
Who last touched these lines (formatters already discounted)? |
line_history(repo, path, start, end, limit=15) |
Every commit that changed this range, with likely_origin and a cosmetic_skipped count. |
find_removal(repo, pattern, path="", limit=10) |
"There used to be a retry here — where did it go?" Pickaxe (git log -S), each hit labelled added / removed / modified. |
commit_context(repo, sha) |
Full message, author, files, stat for one commit. |
pr_for_commit(repo, sha, include_comments=True) |
The PR that introduced a commit, with inline review comments and discussion. |
repo may be any path inside the work tree; file paths are resolved against
the repo root and anything escaping it is rejected.
Setup
Python 3.11+ and git on PATH.
pip install -r requirements.txt
Run over stdio:
python server.py
or explore interactively:
fastmcp dev server.py
Client configuration (stdio)
{
"mcpServers": {
"codebase-archaeology": {
"command": "python",
"args": ["C:/path/to/code-arch/server.py"],
"env": {
"ARCHAEOLOGY_REPOS": "C:/Users/you/src/repo-a;C:/Users/you/src/repo-b",
"GITHUB_TOKEN": "ghp_...",
"ARCHAEOLOGY_CACHE": "C:/Users/you/.cache/archaeology.sqlite"
}
}
}
}
Environment variables
| Variable | Meaning |
|---|---|
ARCHAEOLOGY_REPOS |
Allowlist of repositories the server may read, separated by the platform path separator (: on Unix, ; on Windows). A repo qualifies if its toplevel is one of these paths or inside one. Unset = any local repo is allowed — set it when exposing the server to anything you don't fully trust. |
GITHUB_TOKEN |
GitHub token for PR lookups. Optional, but unauthenticated calls are capped at 60 req/hr; one why_this_line costs up to 3. Rate-limit errors name this variable. |
ARCHAEOLOGY_CACHE |
Path of the SQLite HTTP cache (default ~/.cache/codebase-archaeology/http_cache.sqlite). Responses are kept ~7 days; commit→PR mappings are effectively immutable, so cached answers cost zero API calls. |
Honest limits
git log -Lcannot trace across a file split (content extracted into a new file). The origin will be the splitting commit, flagged withorigin_is_file_creation: trueand an interpretation pointing atfind_removalto dig further.- Cosmetic detection is whitespace-based (
git show -w). A formatter that changes quote characters is not "cosmetic" by this test, but the lineage trace still walks through it to the real origin. git log -Lon a huge file with deep history is genuinely slow; that is whylimitdefaults to 15 and git calls time out at 30s.
Tests
python -m pytest
The suite builds a throwaway repo reproducing the failure mode (real origin → whitespace-only reformat → reword) and asserts, among other things, that naive blame credits the formatter while every tool here names the true origin. GitHub tests run against a fake transport — no network needed.
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.
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.
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.
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.