Skip to main content
Glama

git-context-mcp

Un servidor MCP que responde a la pregunta que todo desarrollador se hace: "¿por qué existe este código?"

git blame te dice quién escribió una línea. Esto te dice por qué.

Dada una línea o rango de líneas de un archivo, git-context-mcp rastrea el commit, encuentra la solicitud de extracción (pull request) que lo introdujo, lee la descripción del PR y muestra todos los issues de GitHub vinculados, todo de una vez, directamente dentro de Claude.


Demo

You: Why does line 87 of src/auth/session.ts exist?

Claude (using blame_context):
  Commit `a3f9c12` by Sarah Chen on 2024-08-14
  Message: "fix: rotate session tokens on privilege escalation"

  PR #441 — "Security: fix session fixation vulnerability"
  Merged: 2024-08-15  |  Labels: security, critical

  PR Description:
  > After the pen test in sprint 22, we found that session tokens
  > weren't being rotated when a user's role changed. This allows
  > a stolen low-priv token to be used after the account is promoted.

  Linked Issue #389 — "Session token not rotated on role change" (closed)
  > Reported by @contractor-red: "I was able to reuse a captured
  > token after my account was upgraded to admin..."

Se acabó el buscar en el registro de git, investigar en GitHub y cruzar referencias en los gestores de incidencias. Claude lo hace en un solo paso.


Related MCP server: Git Insight MCP

Herramientas

Herramienta

Qué hace

blame_context

Archivo + rango de líneas → commit + descripción del PR + issues vinculados

commit_story

Hash del commit → narrativa completa (mensaje, estadísticas de diff, PR, issues)

file_history

Archivo → últimos N commits, cada uno anotado con PR e issues

search_commits

Palabra clave → commits coincidentes con contexto de PR/issue

file_contributors

Archivo → tabla de autores clasificados (commits, líneas propias, fechas de actividad)


Instalación

Opción 1 — npx (sin instalación)

claude mcp add git-context -- npx git-context-mcp

Opción 2 — instalación global

npm install -g git-context-mcp
claude mcp add git-context -- git-context-mcp

Opción 3 — configuración manual

Añadir a ~/.claude/claude_mcp_config.json:

{
  "mcpServers": {
    "git-context": {
      "command": "npx",
      "args": ["git-context-mcp"]
    }
  }
}

Luego reinicia Claude Code.


Requisitos

  • Claude Code (o cualquier cliente compatible con MCP)

  • git en el PATH

  • CLI de gh (instalar) + gh auth login para búsquedas de PR/issues en GitHub

    • Funciona sin gh, simplemente omite el contexto de PR/issue


Ejemplos de uso

Una vez instalado, habla con Claude de forma natural en cualquier repositorio git:

"Why does line 42 of src/db/connection.ts exist?"
"What's the story behind commit d4a8f91?"
"Who owns the most of src/payments/stripe.ts?"
"When was the rate limiting added? Search commits for 'rate limit'"
"Show me the last 5 changes to src/api/auth.ts and why each was made"

Cómo funciona

  1. blame_context ejecuta git blame -p en tus líneas para encontrar el/los hash(es) del commit

  2. Para cada commit, llama a git show para obtener el mensaje completo y las estadísticas del diff

  3. Consulta la API de GitHub (gh api /repos/:owner/:repo/commits/:hash/pulls) para encontrar el PR

  4. Analiza las referencias #NNN y /issues/NNN del cuerpo del PR y obtiene cada issue

  5. Todo se devuelve como markdown estructurado para que Claude pueda razonar sobre ello

No se almacenan tokens. No se envían datos a ningún lugar excepto a la propia API de GitHub (igual que la CLI de gh).


Contribuciones

Las PR son bienvenidas. Todo el servidor reside en src/index.ts.

git clone https://github.com/muhannad-hash/git-context-mcp
cd git-context-mcp
npm install
npm run dev   # watch mode

Licencia

MIT

Available Tools

5 tools
blame_contextA

Given a file and line range, returns who wrote those lines, when, the commit message, the associated pull request (title + description), and any linked issues. Answers the question: why does this code exist?

Inputs: file (required), start_line (required), end_line, repo_path.

commit_storyB

Given a commit hash, returns the full story: commit message, files changed, the pull request that landed it, the PR description, and all linked GitHub issues.

Inputs: hash (required), repo_path.

file_contributorsA

Shows every author who has ever committed to a file, ranked by number of commits. Includes current line ownership, commit percentage, and the date range they were active on the file.

Inputs: file (required), repo_path.

file_historyA

Returns the N most recent commits that touched a file, each annotated with its associated pull request and linked issues.

Inputs: file (required), limit, repo_path.

search_commitsA

Search commits by keyword across commit messages (and optionally code changes). Returns matching commits annotated with their pull requests and linked issues. Useful for finding when a feature was added, a bug was fixed, or a dependency was changed.

Inputs: query (required), repo_path, limit, search_code.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no overlap: blame_context focuses on line-level authorship and rationale, commit_story provides comprehensive commit details, file_contributors shows author statistics, file_history gives recent commit timeline, and search_commits enables keyword-based discovery. The descriptions clearly differentiate their scopes and use cases.

    Naming Consistency5/5

    All tools follow a consistent snake_case naming pattern with clear, descriptive compound names (e.g., blame_context, commit_story, file_contributors). The naming convention is uniform throughout, making the tool set predictable and easy to understand at a glance.

    Tool Count5/5

    With 5 tools, this server is well-scoped for its purpose of providing Git context and history insights. Each tool serves a specific, valuable function in the domain, and the count is neither too sparse nor bloated, allowing comprehensive coverage without overwhelming complexity.

    Completeness5/5

    The tool set offers complete coverage for exploring Git history and context: from line-level blame and commit details to file authorship, recent changes, and commit search. There are no obvious gaps; agents can navigate from high-level searches to detailed investigations seamlessly, covering the full lifecycle of code changes.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Answers why code exists by tracing file:line or natural-language questions through git blame, commits, PRs, and linked issues, providing cited evidence from history.
      MIT