Skip to main content
Glama

gitrisk-mcp

Ask your AI agent where the risk is in a codebase, and who knows the code.

gitrisk-mcp is a read-only MCP server that mines a git repository's history. Generic git servers give an agent status, diff and commit. This one answers the questions you ask before touching old code: which files are the riskiest, who actually understands them, which files secretly change together, and which directories would be orphaned if one person left.

How it differs from the existing git-analytics MCP servers (for example repo-pulse-mcp, mcp-git-historian, GitIntel-MCP-Server and andriilazor/git-insights-mcp):

  • Expertise is measured on surviving code, not just commit counts. file_experts runs git blame -w -M and blends the surviving-line share with recent activity, then flags authors who have gone quiet. Commit counting alone rewards whoever reformatted a file.

  • History noise is handled, not ignored. Mass commits (reformat, vendor drops) are filtered, lock files are excluded, .mailmap is honoured everywhere (including blame), merge commits are not double counted, and renames are followed so a moved file keeps its past.

  • Every number is reproducible. Each formula is documented, and the test suite builds real repositories with scripted commits and asserts the exact scores, confidences and shares. Read-only is tested too: the whole repository is hashed byte for byte before and after every tool.

  • Safe and honest on awkward repos: a --dir sandbox, shallow clones are detected and warned about, bare repositories work, non-UTF-8 path names do not crash anything, and huge histories are streamed with explicit limits (a generated 20,000 commit repository runs every tool in about a second).

  • Zero dependencies beyond mcp. It shells out to your real git, with argument lists only.

Tools

Tool

Answers

repo_summary

Age, commits, merges, authors, languages by churn, branches, tags. Warns on shallow clones.

hotspots

Which files are risky: recency-weighted churn times author breadth, over a time window.

file_experts

Who knows this file or directory (blame + recent commits), the bus factor, and who is inactive.

change_coupling

Which files change together with this one, with support and confidence.

bus_factor

Per directory: how many people hold more than half the knowledge.

churn_timeline

Commits and changed lines per week or month, with an ASCII sparkline.

release_notes

Markdown notes between two refs, grouped by conventional-commit type or by area.

commit_search

Find commits by message, author, path, dates, or text added/removed.

file_history

A file's commits, following it across renames.

Related MCP server: git-context-mcp

What it looks like

Real output from the test repository (a scripted three-author history):

> hotspots
| # | file | score | commits | lines | authors | last change |
|---|---|---|---|---|---|---|
| 1 | core/engine.py | 40.8 | 6 | 22 | 3 | 2026-02-24 |
| 2 | api/routes.py | 16.0 | 2 | 10 | 2 | 2026-02-16 |
| 3 | core/util.py | 11.6 | 4 | 8 | 2 | 2026-02-23 |

> file_experts core
Experts for core: 30 surviving lines in 2 file(s) (3 authors). Bus factor 1. BUS FACTOR 1: a single person holds most of this code.
| author | email | surviving lines | blame share | commits (180d) | recent share | score | last touch |
| Alice | alice@x.io | 19 | 63% | 3 | 63% | 0.633 | 2026-02-23 |
| Bob   | bob@x.io   | 10 | 33% | 2 | 33% | 0.333 | 2026-02-02 |

> change_coupling core/engine.py
| file | support | confidence | reverse | file commits |
| core/util.py | 4 | 0.67 | 1.00 | 4 |

Install

Needs Python 3.10+ and git on your PATH.

Claude Code

claude mcp add gitrisk -- uvx gitrisk-mcp --dir /path/to/your/projects

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "gitrisk": {
      "command": "uvx",
      "args": ["gitrisk-mcp", "--dir", "C:\\Users\\you\\projects"]
    }
  }
}

--dir is repeatable. Without it, the server may only read the repository containing its working directory. Every tool takes repo= (a path under an allowed directory; the first --dir is the default).

Try asking

  • "Give me a summary of this repo, then show the 15 riskiest files from the last 6 months."

  • "Who should review changes to src/billing/? Is anyone the only person who knows it?"

  • "Which directories have a bus factor of 1 and at least 10 commits?"

  • "What files usually change together with src/auth/session.py? Anything surprising?"

  • "Draft release notes from the last tag to HEAD, grouped by area."

  • "Chart commit activity per week for the api/ folder over the last year."

  • "Find commits that added or removed the string legacy_flag, and show who made them."

  • "Show the history of lib/parser.py including before it was renamed."

How the numbers work

  • Hotspot score of file F = sum over its commits of (lines changed x 0.5^(age/half_life)) x (1 + log2(distinct authors)). Default half-life 90 days. Binary changes count as 1 line. Only files that still exist are ranked; commits touching more than 100 files are skipped.

  • Expert score = 0.6 x blame share + 0.4 x recent share (recent = lines changed in the last 180 days). Bus factor = the fewest authors whose combined share is more than 50%.

  • Change coupling: confidence = commits touching both / commits touching this file, reverse = commits touching both / commits touching the other file. Commits touching more than 50 files are ignored.

  • Timelines use UTC; weeks start on Monday.

Limits and honest caveats

  • numstat makes git read file contents, so very large diffs are slow in git itself. Measured on a real 2,200-commit Electron project with big bundled files, one full-history pass took about 6 seconds; on a generated 20,000-commit repository it takes under a second. Scans are capped (max_commits) and say so when they stop early; since= narrows them.

  • Shallow clones understate everything. The server tells you, in every answer.

  • Non-UTF-8 file names are shown with \xNN escapes and are skipped by blame-based tools (they cannot be passed through argv portably).

  • Identity is the (mailmapped) author email. Without a .mailmap, one person with two addresses counts as two.

  • Bus factor from history is a signal, not a verdict: it cannot see pairing, reviews or docs.

Security

  • Read-only. Only log, blame, rev-parse, rev-list, ls-tree, diff, for-each-ref, describe and hash-object (without -w) are ever run. GIT_OPTIONAL_LOCKS=0 stops even stat refreshes from touching the index. Tests hash the repo before and after.

  • No shell. Commands are argument lists. Refs are resolved to commit ids first and refs starting with - are rejected, so a ref can not become an option. Search text is passed literally, never as a regex. Paths are literal (GIT_LITERAL_PATHSPECS=1).

  • Sandbox. Repositories must live under a --dir root; a repository that merely contains an allowed directory is refused. Inherited GIT_* environment variables are dropped.

  • Git still honours the repo's own configuration. Only point --dir at repositories you trust.

Companion tutorial

gitrisk-mcp-the-hard-way builds a minimal version of this server from scratch in seven modules.

Development

uv sync --extra test
uv run pytest tests            # builds real repos; needs git
uv run pytest tests -m slow    # 20,000-commit repo (and local real repos if present)

MIT licence.

Available Tools

9 tools
bus_factorA

Bus factor per directory (first depth path components), from history: the fewest authors whose recency-weighted changed lines exceed 50%. Directories with factor 1 and at least min_commits commits are marked AT RISK. Use file_experts for blame-based detail.

Inputs: ref, path, repo, as_of, +6 more. Returns: result

change_couplingB

Which files change together with this file? For each other file: support (commits touching both), confidence (support / commits touching this file) and reverse confidence. Mass commits (more than max_files_per_commit files) are ignored and renames are followed. High confidence between files with no import relation is a hidden dependency.

Inputs: path (required), ref, repo, limit, +5 more. Returns: result

churn_timelineB

Commits and changed lines per week or month (UTC), with ASCII sparklines ('_' = none, '@' = peak). Filter by path or author substring. Merges are excluded.

Inputs: ref, path, repo, since, +3 more. Returns: result

file_expertsA

Who knows this file or directory? Weights each author by surviving lines (git blame ignoring whitespace and moved lines) and by lines changed in the last recent_days (score = 0.6 blame share + 0.4 recent share). Reports the bus factor (fewest authors holding more than 50% of the code) and flags authors with no activity for inactive_days. For a directory, the max_files biggest text files are blamed.

Inputs: path (required), ref, repo, as_of, +4 more. Returns: result

file_historyB

Commits that touched a file, newest first, following it across renames (reports the earlier names). Shows lines added/deleted per commit.

Inputs: path (required), ref, repo, limit. Returns: result

hotspotsA

Rank files by risk: recency-weighted churn (lines added+deleted, halving every half_life_days) multiplied by (1 + log2 of distinct authors). Only files that still exist are listed. Commits touching more than max_files_per_commit files (reformats, imports) and lock files are ignored; exclude takes extra globs like '*.min.js'. since/until accept git dates ('6 months ago', '2026-01-01'); path limits to a directory; as_of pins 'now'.

Inputs: ref, path, repo, as_of, +7 more. Returns: result

release_notesB

Markdown release notes for from_ref..to_ref (default: latest tag before to_ref up to HEAD). group_by='type' groups by conventional-commit type (feat, fix, ...) with breaking changes first; group_by='area' groups by the top-level directory each commit mostly touched. Merge commits and PR numbers ((#123), 'Merge pull request #123') are listed.

Inputs: repo, to_ref, from_ref, group_by, +1 more. Returns: result

repo_summaryB

Overview of a repository: age, commit and merge counts, top authors (mailmap applied), languages by churn, branches, tags. Warns if the clone is shallow. Start here.

Inputs: ref, repo, max_commits. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 9 tools

    Disambiguation4/5

    Each tool targets a distinct analytical view (risk ranking, history, ownership, coupling, timeline, release notes, search), and descriptions actively cross-reference each other (bus_factor vs file_experts). The main soft overlaps are hotspots vs churn_timeline (both churn-based) and bus_factor vs file_experts (both ownership/bus-factor), but the stated granularity differences keep them separable.

    Naming Consistency4/5

    All names are snake_case and stable, with a dominant noun_noun/analysis-view convention (repo_summary, file_history, change_coupling, bus_factor, churn_timeline, release_notes). Minor deviations: 'hotspots' is a bare noun and 'commit_search' reverses the noun_verb order, but none of these impede readability.

    Tool Count5/5

    Nine tools for a git risk-analysis server is a well-scoped set; each covers a distinct analysis angle with no filler. Nothing appears redundant enough to drop.

    Completeness4/5

    The surface covers overview, risk ranking, file history, ownership, coupling, bus factor, churn timeline, release notes, and commit search — a strong lifecycle for repo risk analysis. Gaps are minor: no per-author aggregated risk view, no ref/commit diff or comparison tool, and no raw blame summary, but agents can work around these via file_experts and commit_search.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Analyzes git repository metrics to understand team health, development patterns, code quality, and collaboration through natural language queries. Provides insights on commit statistics, bus factor, velocity trends, technical debt, and burnout detection.
      12
      50 npm
      1
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI assistants to turn local git history into answers about recent activity, file hotspots, change coupling, stale or already-merged branches, contributors, ref comparisons, and drafted release notes. It runs locally over stdio with a git subcommand allowlist, so it is read-only, works offline and without shell access, and is safe to auto-approve.
      13
      80 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI clients to interrogate a local Git repository's history, surfacing change hotspots, per-author activity, files that change together, single-file commit history, and draft changelogs between refs. It is strictly read-only, requires no API keys, and returns structured data for the client to interpret.
      6
      MIT