git_advisor
Indexes Git repository history and uses git archive to analyze commits, forecast impact, select tests, and verify refactors in isolated checkouts.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
git_advisor
A fast, zero-GPU, causally calibrated repository impact advisor, smart test selector, and verified refactoring tool (CLI + MCP server) backed by real multi-language benchmarks. (v0.1.0)
git_advisor indexes Git history into a single local SQLite database without touching your working tree, builds a file/symbol dependency graph, and gives both developers and AI coding agents six concrete capabilities:
Impact & Risk Forecasting (
advise) — Given a natural-language task, predicts which files will change, estimates a calibrated conformal blast-radius interval, and surfaces hub-guarded historical risk precedents in ~330 tokens.Structure Optimization (
optimize-structure) — Detects cross-file and within-file AST-body code clones (clustered to prevent clique noise, flagging stack-sensitive APIs likewarnings.warn), decorator-aware dead functions, directional TF-IDF misplaced modules, and hard import cycles vs. lazy runtime back-edges.Targeted Test Selection (
select-tests) — Combines reverse static imports, historical test↔source co-change, path stems, and symbol tokens to pick minimal regression test files (~89% suite reduction).Isolated Sandbox Verification (
verify-refactor) — Exports the base commit viagit archiveinto a clean temporary directory, applies proposed edits, runs targeted tests + live dependency graph extraction, and certifiesCERTIFIED_SAFEor rejects (REJECTED_TESTS_FAILED,REJECTED_NEW_CYCLE,REJECTED_SYNTAX_ERROR,REJECTED_EDIT_ERROR).Bounded Agent Loop (
agent-loop) — Runs aPropose → Verify → Refineloop (deterministic or backed by local Ollama / pluggable LLM) that feeds test failure output back on rejection and emits edits only whenCERTIFIED_SAFE.Zero-Dependency MCP Server (
mcp-serve) — Exposes all tools over stdio JSON-RPC 2.0 (with dynamic per-calldatabaseswitching) to Antigravity, Claude Code, Cursor, or Codex.
60-Second Quickstart
Requires Python 3.10+ and Git (numpy is required for advise / optimize-structure).
pip install -e ".[embeddings]"
# 1. Index the last 100 commits of any local or remote Git repository
git-advisor --db repo.sqlite index /path/to/your-repo --limit 100
# 2. Forecast affected files & regression risk before editing (~330-token LLM context)
git-advisor --db repo.sqlite advise "fix token refresh expiry on login" --llm-context
# 3. Audit structural clones, dead code, misplaced files, and import cycles
git-advisor --db repo.sqlite optimize-structure --llm-context
# 4. Select minimal regression tests for a planned edit
git-advisor --db repo.sqlite select-tests --file src/auth/session.py
# 5. Verify a candidate refactoring in a clean isolated checkout (never mutates your repo)
git-advisor --db repo.sqlite verify-refactor --candidate dead-1 --recordRelated MCP server: Checkride
Connect as an MCP Server
Add this once to your MCP client config (for example ~/.gemini/config/mcp_config.json in Antigravity). No hardcoded --db is needed—agents can discover indexes with git_advisor_list_indexes and pass "database" on any call:
{
"mcpServers": {
"git_advisor": {
"command": "python",
"args": ["-m", "git_advisor", "mcp-serve"]
}
}
}Use --read-only to expose only the 4 read-only analysis tools (git_advisor_list_indexes, git_advisor_advise, git_advisor_optimize_structure, git_advisor_select_tests) and disable sandboxed test execution (git_advisor_verify_refactor, git_advisor_agent_loop).
Real-World Examples & Benchmarks
All benchmarks below were evaluated strictly causally (at parent_sha, zero future leakage) across 200 live stdio MCP calls spanning 11 real repositories (pytest, flask, httpx, click, packaging, fastapi-template, pythonQEPest, fonline, linux-kunit, linux-leds, and git_advisor).
Concrete findings on pytest (40,331 LOC, 81 src/ files, 97 test files)
Found a real upstream dead function:
optimize-structureflaggedsrc/_pytest/fixtures.py::is_visibility_more_specific(23 lines, orphaned in commita84e5039c) with 0 false positives across 277 zero-static-caller functions (correctly sparing@fixture(name="LineMatcher")via decorator-alias parsing). Zero-configverify-refactor --candidate dead-1auto-selected 2 of 97 test files (97.9%suite reduction), ran 309 passing tests, and issuedCERTIFIED_SAFE(-25 LOC,0new cycles).Verified real clone consolidations: Caught
Dir.collect↔Package.collect(-13 LOC, 198 passed) and_load_pytest_ini↔_load_ini_file(-6 LOC, 25 passed), with 0% false positives across all 8 emitted clone clusters.Caught a static-invisible behavioral trap:
pytest's #1 cross-file AST clone (collect_thread_exception↔collect_unraisable, 35 identical lines) passed static analysis, yetverify-refactorrejected naive extraction (REJECTED_TESTS_FAILED) becausepytesttests assert the exactwarnings.warn(...)source line and-Werrortraceback depth.optimize-structurenow flags stack-sensitive APIs automatically.
200-Example Live MCP Benchmark Summary
MCP Tool | Cases ( | Pass Rate | p50 Latency | Measured Quality |
| 10 | 100.0% |
| Multi-directory discovery & error guards |
| 65 (8 repos) | 100.0% |
| 80.0% Hit@5, 66.4% Mean Recall@5, 84.9% token reduction ( |
| 60 (6 repos) | 100.0% |
| 91.7% Hit@5, 76.6% Mean Recall@5, 89.1% suite reduction |
| 25 (11 repos) | 100.0% |
| Mean 525 tokens/plan, |
| 20 (4 repos) | 95.0%* |
| All 5 verdicts certified ( |
| 10 (6 repos) | 100.0% |
| 0 uncertified patches leaked across all runs |
Protocol / | 10 | 100.0% |
| JSONL + |
*The single miss in the 200-case run (ver-05) was a mutation test (estimate_tokens -> 0) that exposed a missing assertion in tests/test_advise.py, now fixed.
Cross-Repository Zero-Shot Transfer Benchmark (7 Unseen Non-Python Repos, n = 1,387)
To verify generalization beyond Python, a single HybridImpactRanker was trained strictly on 6 Python repos (pytest, flask, httpx, click, packaging, fastapi — 674 commits / 22,781 candidate rows) and evaluated zero-shot and strictly causally (only commits $< t$ and files existing before $t$) across 1,387 commits on 7 completely unseen non-Python repositories (Java, Android Java/C++, JavaScript, TypeScript, C/C++, and Bash):
Method | Training Data | Macro Hit@1 | Macro Hit@5 | Macro Hit@10 | Mean Recall@5 | MRR |
| Target history only | 10.5% | 27.1% | 36.7% | 13.0% | 0.180 |
| Target commit subjects only | 27.4% | 42.2% | 49.5% | 25.5% | 0.340 |
| Full causal file tree | 27.8% | 45.1% | 51.9% | 27.7% | 0.350 |
| 6 Python repos ONLY (frozen) | 31.4% | 51.1% | 57.0% | 31.2% | 0.400 |
| Target repo online causal refit | 32.9% | 51.4% | 57.4% | 31.7% | 0.410 |
Unseen Target Repo | Language(s) | Tracked Files | Eval ( |
|
|
|
|
|
| Android Java / C++ | 10,386 | 187 | 52.9% | 69.0% (+16.1) | 68.4% | 94.6% |
|
| JavaScript | 6,102 | 200 | 64.5% | 66.5% (+2.0) | 66.0% | 93.5% |
|
| Bash / Shell | 488 | 200 | 56.0% | 66.0% (+10.0) | 67.5% | 94.5% |
|
| C / C++ | 29,578 | 200 | 50.0% | 54.0% (+4.0) | 53.0% | 96.5% |
|
| TypeScript | 4,697 | 200 | 40.0% | 46.0% (+6.0) | 46.0% | 97.0% |
|
| TypeScript | 21,935 | 200 | 26.5% | 31.5% (+5.0) | 32.0% | 97.0% |
|
| Java / C++ | 72,315 | 200 | 25.5% | 24.5% (-1.0) | 27.0% | 94.5% |
|
Zero-shot transfer beat
BM25on 6 of 7 unseen repos (+6.0 ppmacro Hit@5) and captured 99.3% of full online in-repo retraining (51.1%vs.51.4%) with zero target-repo tuning.Conformal calibration (
LogCQRHurdle+ ACI) maintained 93.5%–97.0% empirical coverage across all 7 languages (90% target), and inverted-index BM25 kept query latency at 1.5–3.2 ms even on 72k-fileopenjdk/jdk.No pre-training required: In normal use,
git-advisor adviseautomatically fits the ranker and conformal calibrator on-the-fly from your repository's own Git history (zero weights or GPU needed).Reproduce these benchmarks: See benchmarks/README.md for self-contained scripts (
python benchmarks/mcp_benchmark.pyandpython benchmarks/cross_repo_transfer.py --eval-per-repo 200).
Honest Status & Limitations
What works best today: Python repositories with $\ge 20$ commits and an automated
pytestorunittestsuite (for full AST refactoring & live verification), plus any Git repository in any language for causal impact ranking, co-change, and calibrated blast-radius intervals.Why hybrid symbolic + statistical instead of a deep neural JEPA (yet): Earlier offline experiments in this repo tested a learned temporal JEPA encoder (EMA + VICReg) and found deterministic AST/graph extractors, inverted-index BM25 + co-change, regularized logistic/GBDT rankers, log-space conformal calibration (
LogCQRHurdle+ ACI), and isolated sandbox execution consistently outperformed it on low-data repo histories with zero GPU overhead.Ultra-large monorepos with terse issue-ID titles: On 22k–72k file monorepos (
microsoft/vscodeat31.5%Hit@5,openjdk/jdkat24.5%Hit@5) where commit titles often say only"Fix #241912"or"8341234: Fix C2 crash", title-only grounding hits a ceiling without issue bodies or learned symbol-level embeddings.Multi-language AST depth: Python has full AST-body cloning, decorator-aware dead-code detection, and dependency extraction. TypeScript (
npm ci) and C/C++ (pip install -e ".[native]") support semantic graph extraction, whileoptimize-structurefalls back tograph_onlymode on non-Python repos.Cold-start latency: Running
git-advisor --db repo.sqlite mine-outcomes --cacheonce pre-caches SZZ history and speeds up repeatedadvisecalls on large repos.
Interactive Graph Viewer, Prospective Benchmarks & Advanced CLI
git_advisor also ships a local localhost web viewer (git-advisor --db repo.sqlite view) with an interactive architecture graph, 3D commit embedding trajectory, reuse planner, side-by-side plan comparison, and prospective forecast capture/scoring:
# Open the interactive graph viewer (or --forecast-only for read-only agent API)
git-advisor --db repo.sqlite view
# Pre-cache causal SZZ outcomes (reverts, Fixes: trailers, symbol-overlap follow-ups)
git-advisor --db repo.sqlite mine-outcomes --cache
# Run a chronological risk benchmark on mature commits
git-advisor --db repo.sqlite benchmark-outcomes
# Run a bounded Propose -> Verify -> Refine loop with a local Ollama model
git-advisor --db repo.sqlite agent-loop --candidate dedup-1 --ollama-model qwen2.5-coder:7b --record
# Run the full unit test suite (98 tests, zero external services required)
python -m unittest discover -s tests -vFor deeper documentation on the architecture graph, embeddings, prospective protocol, and local LLM plan review, see docs/08-review-report/release.md and docs/software-world-model.md.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Build, test and cache insights for Xcode, Gradle and Bazel projects, for coding agents.
Live GitHub repo AST X-Ray, 42 coding-agent DoD gates, Git worktree guards & brownfield baselines.
Deterministic context layer for your codebase: change impact, blast radius, answers with receipts.
Related MCP Servers
- FlicenseAqualityNot gradedmaintenanceProvides AI coding agents with dependency analysis, impact detection, and build verification tools.14-
- AlicenseAqualityDmaintenanceEnables AI coding agents to run fast, sandboxed pre-flight validation—tests, type-checking, linting, security audits, Git safety scans, and fix suggestions—before committing or pushing code, with instant caching and optional Docker isolation.109 npmMIT
- AlicenseBqualityCmaintenanceEnables AI agents to build a structured model of a Python codebase and query it over stdio JSON-RPC: dependency-mapped component stats, ranked blast-radius predictions for a target file, natural-language change planning with suggested tests, and design decisions mined from git history.4MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI assistants to audit git diffs, scan for leaked secrets and unsafe APIs, detect breaking changes, triage issues, generate changelogs, and assess repository hygiene through native stdio JSON-RPC tools.7Apache 2.0