Git Insight MCP
git-insight-mcp
通过 MCP 进行语义化 git 查询。超越 git log —— 回答关于任何代码行、文件或分支的“谁/什么/何时/为什么”。

与 terminal-history-mcp 和 localhost-mcp 配合使用。组合起来:你运行了什么、正在运行什么、你更改了什么。
为什么
开发人员经常问这些问题;git 的回答效果不佳:
“谁最后修改了这个函数?” ——
git blame只给出代码行,而不是按区域划分的作者“哪一个 PR 引入了这一行?” —— 手动操作:blame → 提交 SHA → 搜索 GH
“哪些文件总是同时更改?” —— 没有内置功能
“显示超过 30 天未合并的分支” —— 需要复杂的 bash 单行命令
“我上周做了什么?” —— 手动清理日志
LLM 代理需要这些上下文来进行安全的编辑。目前它们只能使用 git log -n 5,从而遗漏所有内容。
Related MCP server: semamerge
安装
npm install -g git-insight-mcp接入 Claude Code:
claude mcp add --scope user git-insight -- git-insight-mcp或任何兼容 MCP 的客户端。作为 stdio MCP 服务器运行。
对于 PR / issue 查询,请设置 GitHub 令牌:
export GH_TOKEN=ghp_...如果没有令牌,本地 git 工具仍然有效。PR 关联功能将被跳过。
工具
工具 | 用途 |
| 按作者对 blame 进行分组。包括代码行、提交、最后修改时间、主要所有者。可选代码行范围缩小。 |
| 查找引入某一行(或提交)的 PR。首先解析合并消息;如果失败则回退到 GitHub API。 |
| 与输入文件最常一起更改的文件。 |
| 列出分支及其领先/落后情况、最后提交、合并状态、过期标记。 |
| 站会助手:作者在一段时间内的提交 + 文件 + 插入/删除量。 |
| 完整的提交上下文:主题、正文、文件、PR、相关 issue。 |
示例输出 (who_touched)
{
"file": "src/auth.ts",
"total_lines": 124,
"authors": [
{ "name": "alice", "email": "alice@x.com", "lines": 87, "commits": 12, "last_commit_date": "2026-04-12T10:33:01.000Z" },
{ "name": "bob", "email": "bob@x.com", "lines": 37, "commits": 4, "last_commit_date": "2026-01-03T18:14:55.000Z" }
],
"primary_owner": "alice"
}CLI 使用(完整性检查)
git-insight-mcp who-touched src/auth.ts
git-insight-mcp co-change src/auth.ts
git-insight-mcp branches
git-insight-mcp recent alice
git-insight-mcp commit a3e577e
git-insight-mcp intro-pr src/auth.ts:42
git-insight-mcp intro-pr a3e577e
git-insight-mcp # MCP stdio server从源码构建
git clone https://github.com/HasanJahidul/git-insight-mcp.git
cd git-insight-mcp
npm install
npm run build
node dist/cli.js branches限制 (v0.1)
仅限 GitHub(暂不支持 GitLab/Bitbucket)。
co_change的复杂度为 O(窗口 × 每次提交的文件数) —— 默认限制为 1000 次提交。函数级 blame 是按代码行范围进行的,而不是 AST。尚未跟踪重命名。
适用 GH API 速率限制(认证用户每小时 5000 次)。此版本中 PR 结果未缓存。
许可证
MIT
Available Tools
6 toolsbranch_hygieneARead-onlyIdempotent
Read-only. Inventory of branches with ahead/behind counts versus the default branch, last commit date and author, merged status, and a stale flag (no commits in stale_days days). Use it to find unmerged, abandoned branches. The default branch itself is excluded from the list. Pure local git; no network. Returns { count, branches, default_branch_excluded }.
Inputs: cwd, remote, stale_days. Returns: count, branches, default_branch_excluded
co_changeARead-onlyIdempotent
Read-only. Files that historically change together with the input file — answers "if I edit X, what else should I check?". Mines up to window recent commits that touch file, counts how often each other file appears alongside it, and returns those above threshold, with the co-occurrence count and ratio (count / commits-touching-file), capped at limit. Pure local log mining; no network. Cost is O(window × files-per-commit) — keep window ≤ a few thousand on large repos.
Inputs: file (required), cwd, limit, window, +1 more. Returns: file, co_changed, total_commits_touching
commit_contextARead-onlyIdempotent
Read-only. Everything about one commit in a single call: subject, body, changed files with per-file insertions/deletions, totals, the linked PR (parsed from the merge message, or via the GitHub API when GH_TOKEN/GITHUB_TOKEN is set), and issue numbers referenced in the message (Fixes #N, Closes #N). Errors if the SHA does not resolve in cwd. May make one outbound GitHub API call for PR enrichment.
Inputs: sha (required), cwd. Returns: pr, sha, body, date, +6 more
introducing_prARead-onlyIdempotent
Read-only. Find the pull request that introduced a line or a commit. First resolves the line to a commit via git blame, then reads the local merge-commit message; if that has no PR reference and GH_TOKEN/GITHUB_TOKEN is set, falls back to the GitHub REST API. Without a token the local path still works; pr is null when nothing can be resolved (e.g. rebase-merged with no PR ref). Provide either commit, or both file and line. May make one outbound GitHub API call (subject to the 5000/h authed rate limit).
Inputs: cwd, file, line, commit. Returns: pr, author, commit, source, +2 more
recent_workARead-onlyIdempotent
Read-only. Standup / changelog helper: one author's commits in a time window with files touched and insertion/deletion totals. Defaults to the repo's user.name and the last 7 days. Pure local git; no network. Returns { author, since, commit_count, commits[] } where each commit has subject, date, files, insertions, deletions.
Inputs: cwd, limit, since, author. Returns: since, author, commits, commit_count
who_touchedARead-onlyIdempotent
Read-only. Code ownership for a file via git blame, aggregated by author. Returns each author's line count, commit count, and most recent commit date, plus the primary_owner (most lines). Pass line_start/line_end to scope to one region (e.g. a single function). Errors if cwd is not a git repo or file is untracked. Cost scales with file size; instant for typical files.
Inputs: file (required), cwd, function, line_end, +1 more. Returns: file, authors, total_lines, primary_owner
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool targets a distinct git analysis task: branches, file co-change, commit details, PR introduction, recent work, and file ownership. No functional overlap is apparent.
All names use lowercase snake_case and are descriptive compound nouns (e.g., branch_hygiene, who_touched). While not strictly verb_noun, the pattern is consistent and readable.
Six tools is a well-scoped set for a git insight server, covering key analyses without being overwhelming or too sparse.
The set covers branch analysis, co-change, commit details, PR discovery, recent work, and blame. Missing common operations like branch diff or commit log filtering, but still functional for the intended domain.
Maintenance
Related MCP Connectors
Shared context for your codebase: a hosted code knowledge graph over MCP. Free plan, OAuth sign-up.
Deterministic context layer for your codebase: change impact, blast radius, answers with receipts.
AI-native git hosting — repos, PRs, issues, CI gates, and AI code review over MCP (60 tools).
Hosted code graph over MCP: exact callers, dependencies, and cross-repo blast radius for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAutomatically extracts architectural decisions, patterns, and insights from Git commits to build a local, structured project memory. It exposes this living context to AI tools via MCP, allowing them to understand the historical reasoning and evolution behind your codebase.6MIT
- AlicenseAqualityDmaintenanceMCP server that detects semantic (non-textual) merge conflicts between Git branches using AST-level analysis. Catches incompatible changes that Git merges cleanly — signature changes, removed exports, parameter changes, interface breaks, and cross-file dependency conflicts.441 npmMIT
- AlicenseAqualityCmaintenanceDevelopers: Search your zsh, bash, or fish shell history from Claude Code, Cline, Cursor, Zed, or any MCP client using tools like search_history (full-text with timestamp/CWD/exit code), recent_in_dir, failed_commands, and command_chains for multi-step sequences. Reindex after new activity. Local-only SQLite FTS5 with secrets redacted before storage.741 npm5MIT
- AlicenseAqualityDmaintenanceInspect, manage, and kill local dev servers via MCP. Stop guessing what's on :3000. Five tools: list servers with framework detection, inspect ports, find zombies, diagnose conflicts, safe-kill with dry-run default. Local, no cloud, no telemetry.56 npm4MIT