mcp-git-historian

mcp-git-historian

MCP server for git archaeology — churn hotspots, blame summaries, bus factor, commit forensics and file history over any local repository.

Category
访问服务器

README

mcp-git-historian

tests

MCP server for git archaeology — churn hotspots, blame summaries, bus factor, commit forensics and file history over any local repository.

Why

Every codebase carries answers to the questions that matter most during maintenance: Which files keep breaking? Who actually knows this legacy module? When did this weird constant appear? What happens if that one developer leaves? The answers are buried in git history, but digging them out means chaining log, blame, shortlog and pickaxe invocations with arcane flags — so nobody does it.

mcp-git-historian gives your AI assistant those forensic tools directly. It shells out to the git CLI you already have (no extra dependencies, no network calls, nothing leaves your machine) and returns structured, LLM-friendly summaries: hotspot rankings, ownership percentages, knowledge silos, and the exact commit where a piece of code first showed up.

Tools

Tool Arguments Returns
repo_summary repo_path Current branch, total commits, first/last commit (hash + date), top 10 contributors, commits per month for the last 12 months
hotspots repo_path, since="1 year ago", top=15 Files ranked by commits touching them + lines added/deleted; deleted files excluded; top 3 flagged as high-churn refactor candidates
file_history repo_path, file, limit=20 Commits that touched the file (hash, date, author, subject, +/- lines), following renames via --follow
blame_summary repo_path, file % of surviving lines per author, dominant author, dates of the oldest and newest lines
bus_factor repo_path, top=10 Per top-level directory: dominant author and share of commits, knowledge silos (>80% one author); global bus factor (min authors covering >50% of commits)
search_commits repo_path, query, author="", since="", limit=20 Case-insensitive commit-message search (git log --grep) with optional author/date filters
find_change repo_path, pattern, file="", limit=10 Commits that added/removed the pattern via pickaxe (git log -S) — "when did this code appear?" (-S tracks occurrence-count changes; -G would also match moved lines)

How it works

flowchart LR
    A[Claude / MCP client] -->|tool call| B[server.py<br/>FastMCP wiring]
    B --> C[core.py<br/>pure stdlib logic]
    C -->|subprocess, 30s timeout| D[git -C repo_path<br/>log / blame / ls-files]
    D --> E[(local git repository)]
    D -->|"porcelain output<br/>(pretty %x1f/%x1e, numstat,<br/>blame --line-porcelain)"| C
    C -->|structured dict| B
    B -->|JSON result| A

All parsing relies on machine-friendly git output: custom --pretty formats with ASCII unit/record separators (%x1f/%x1e), --numstat for line churn, and blame --line-porcelain for ownership. Everything runs locally against repositories on your disk.

Quickstart

pip install -e .

Requires Python 3.10+ and the git CLI on your PATH.

Claude Desktop — add to claude_desktop_config.json:

{
  "mcpServers": {
    "git-historian": {
      "command": "python",
      "args": ["/absolute/path/to/mcp-git-historian/server.py"]
    }
  }
}

Claude Code:

claude mcp add git-historian -- python /absolute/path/to/mcp-git-historian/server.py

Example session

User: Nobody on the team dares to touch legacy/parser.py. Who actually knows that module, and how risky is it?

Claude: (calls blame_summary(repo_path="/work/acme-api", file="legacy/parser.py"))

Ownership is extremely concentrated: Alice Dev wrote 94.6% of the surviving lines (Bob Ops has the remaining 5.4%). The oldest line dates to 2019-03-11 and the newest to 2024-08-02 — it is old code, but still being touched.

(calls bus_factor(repo_path="/work/acme-api"))

The legacy/ directory is a knowledge silo: Alice authored 96.2% of all commits touching it. The repository's global bus factor is 2 — just two people account for more than half of all commits. If Alice is unavailable, legacy/ has no realistic second owner.

User: And where did that MAGIC_TOKEN constant in the parser even come from?

Claude: (calls find_change(repo_path="/work/acme-api", pattern="MAGIC_TOKEN", file="legacy/parser.py"))

The pickaxe found exactly one commit that introduced it: a1b2c3d (2019-04-02, Alice Dev) — "feat: add legacy parser handshake token". It has never been removed or re-added since, so that constant has survived untouched for years. I'd recommend pairing someone with Alice on the next legacy/ change and starting with tests around parse().

Development

pip install -e ".[dev]"
python -m pytest

The test suite builds a real throwaway git repository (two authors, a rename, a deleted file, pinned commit dates) and never imports mcp, so it runs with plain pytest.

License

MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选