Skip to main content
Glama

git-context-mcp

Ein MCP-Server, der die eine Frage beantwortet, die jeder Entwickler hat: „Warum existiert dieser Code?“

git blame sagt dir, wer eine Zeile geschrieben hat. Dies sagt dir, warum.

Gegeben eine Datei und einen Zeilenbereich, verfolgt git-context-mcp den Commit zurück, findet den Pull Request, der ihn eingefügt hat, liest die PR-Beschreibung und zeigt alle verknüpften GitHub-Issues an – alles auf einmal, direkt in 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..."

Kein Suchen mehr im git log, kein Durchforsten von GitHub und kein Abgleichen von Issue-Trackern. Claude erledigt das in einem Schritt.


Related MCP server: Selvedge

Tools

Tool

Was es tut

blame_context

Datei + Zeilenbereich → Commit + PR-Beschreibung + verknüpfte Issues

commit_story

Commit-Hash → vollständige Historie (Nachricht, Diff-Statistik, PR, Issues)

file_history

Datei → letzte N Commits, jeweils annotiert mit PR und Issues

search_commits

Schlüsselwort → passende Commits mit PR/Issue-Kontext

file_contributors

Datei → Rangliste der Autoren (Commits, Zeilenanteil, aktive Daten)


Installation

Option 1 — npx (keine Installation)

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

Option 2 — globale Installation

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

Option 3 — manuelle Konfiguration

Hinzufügen zu ~/.claude/claude_mcp_config.json:

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

Starten Sie danach Claude Code neu.


Anforderungen

  • Claude Code (oder ein beliebiger MCP-kompatibler Client)

  • git im PATH

  • gh CLI (Installation) + gh auth login für GitHub PR/Issue-Abfragen

    • Funktioniert auch ohne gh – überspringt dann einfach den PR/Issue-Kontext


Anwendungsbeispiele

Sobald installiert, sprechen Sie in einem beliebigen Git-Repository ganz natürlich mit Claude:

"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"

Funktionsweise

  1. blame_context führt git blame -p auf Ihren Zeilen aus, um den/die Commit-Hash(es) zu finden.

  2. Für jeden Commit ruft es git show für die vollständige Nachricht und die Diff-Statistik auf.

  3. Es fragt die GitHub-API ab (gh api /repos/:owner/:repo/commits/:hash/pulls), um den PR zu finden.

  4. Es parst #NNN und /issues/NNN Referenzen aus dem PR-Text und ruft jedes Issue ab.

  5. Alles wird als strukturiertes Markdown zurückgegeben, damit Claude es analysieren kann.

Keine Token gespeichert. Keine Daten werden irgendwohin gesendet, außer an die GitHub-eigene API (genau wie bei der gh CLI).


Mitwirken

PRs sind willkommen. Der gesamte Server befindet sich in src/index.ts.

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

Lizenz

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?

ParametersJSON Schema
NameRequiredDescriptionDefault
fileYesPath to the file (absolute or relative to repo_path)
start_lineYesFirst line to inspect
end_lineNoLast line to inspect (defaults to start_line)
repo_pathNoWorking directory / repo root (defaults to cwd)

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It clearly describes the tool's behavior by specifying what information is returned, but doesn't disclose operational traits like performance characteristics, error conditions, authentication needs, or rate limits. The description doesn't contradict any annotations (none exist), but could provide more behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise - two sentences that efficiently communicate the tool's purpose and value. The first sentence enumerates what's returned, the second frames the tool's unique value proposition. Every word earns its place with zero waste or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 4 parameters, 100% schema coverage, but no annotations and no output schema, the description provides adequate context about what the tool does but lacks information about return format, error handling, or operational constraints. It's complete enough to understand the tool's purpose but leaves implementation details unspecified.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 4 parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema descriptions. It mentions 'file and line range' which aligns with the schema but doesn't provide additional semantic context. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('returns', 'answers') and resources (file, line range). It enumerates exactly what information is returned (who wrote lines, when, commit message, PR details, linked issues) and explicitly distinguishes its purpose from siblings by framing it as answering 'why does this code exist?' rather than just listing commits or contributors.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by stating it answers 'why does this code exist?' which suggests it's for understanding code rationale rather than just historical tracking. However, it doesn't explicitly state when to use this tool versus alternatives like 'file_history' or 'search_commits', nor does it mention prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
hashYesFull or short commit hash
repo_pathNoWorking directory / repo root (defaults to cwd)

TDQS

B3.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. While it states what information is returned, it doesn't mention error handling (e.g., invalid hash), performance characteristics, rate limits, authentication needs, or whether it requires network access to GitHub. This leaves significant gaps for a tool that appears to query external systems.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core functionality. Every element (commit hash input, returned information) earns its place without redundancy. It could be slightly more structured but remains highly concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, the description adequately covers what information is returned but lacks details on behavioral aspects (errors, performance, dependencies) and output structure. Given the complexity of integrating commit, PR, and issue data, more context would be helpful, but the description meets minimum viable standards.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema (e.g., hash format examples, repo_path implications). Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('returns the full story') and resources (commit hash, commit message, files changed, pull request, PR description, GitHub issues). It distinguishes itself from sibling tools like 'search_commits' by focusing on detailed information for a single commit rather than searching across commits.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when detailed commit information is needed, but provides no explicit guidance on when to use this tool versus alternatives like 'search_commits' (for finding commits) or 'file_history' (for file-specific history). No exclusions or prerequisites are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
fileYesPath to the file
repo_pathNoWorking directory / repo root (defaults to cwd)

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses behavioral traits such as ranking authors by commit count and including specific metrics (line ownership, percentage, date range), but does not mention performance characteristics, error conditions, or data freshness. The description adds value beyond a minimal statement but lacks comprehensive operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that efficiently conveys the tool's functionality without redundancy. It front-loads the core purpose and elaborates with specific output details, making every word count. No extraneous information is included.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no annotations, no output schema), the description is reasonably complete. It explains what the tool does and what information it returns, compensating for the lack of output schema. However, it could improve by addressing potential limitations or example use cases to fully guide an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters ('file' path and 'repo_path' default). The description does not add meaning beyond the schema, as it focuses on output semantics rather than input details. Baseline 3 is appropriate since the schema provides adequate parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('shows', 'ranked') and resources ('every author who has ever committed to a file'), including detailed output information (line ownership, commit percentage, date range). It distinguishes from siblings like 'blame_context' or 'file_history' by focusing on contributor statistics rather than change tracking or commit narratives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for analyzing file authorship and contributor activity, but does not explicitly state when to use this tool versus alternatives like 'blame_context' (which might show per-line attribution) or 'search_commits' (which could filter commits). No exclusions or prerequisites are mentioned, leaving usage context somewhat open-ended.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

file_historyA

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

ParametersJSON Schema
NameRequiredDescriptionDefault
fileYesPath to the file
limitNoNumber of commits to return (default 10)
repo_pathNoWorking directory / repo root (defaults to cwd)

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool returns data (non-destructive) but lacks critical details: whether it requires authentication, rate limits, error handling, pagination behavior, or what happens with invalid inputs. The mention of 'annotated with pull request and linked issues' hints at enriched output but doesn't specify format or completeness guarantees.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, dense sentence with zero wasted words. It front-loads the core functionality ('Returns the N most recent commits that touched a file') and efficiently adds value with the annotation detail. Every element earns its place, making it highly scannable and informative.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read-only tool with 3 parameters (100% schema coverage) but no output schema or annotations, the description is minimally complete. It clarifies the tool's purpose and output nature but lacks behavioral context (e.g., error cases, performance). The absence of output schema means the description doesn't explain return values, though it hints at enriched data structure.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so parameters are fully documented in the schema. The description adds no additional parameter semantics beyond what's in the schema (e.g., no clarification on 'file' path format, 'limit' constraints, or 'repo_path' resolution). Baseline score of 3 reflects adequate but minimal value addition over structured schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Returns'), resource ('N most recent commits that touched a file'), and scope ('each annotated with its associated pull request and linked issues'). It distinguishes itself from siblings like 'blame_context' (line-level attribution) and 'search_commits' (general commit search) by focusing on file-specific commit history with rich annotations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving annotated commit history for a specific file, but provides no explicit guidance on when to choose this tool over alternatives like 'commit_story' or 'file_contributors'. There's no mention of prerequisites, limitations, or comparative use cases, leaving the agent to infer context from tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesKeyword or phrase to search for (case-insensitive)
repo_pathNoWorking directory / repo root (defaults to cwd)
limitNoMax number of results to return (default 20)
search_codeNoAlso search the actual code changes (git pickaxe / -S), not just commit messages (default false)

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses key behavioral traits like case-insensitive search, optional code change searching, and that results include annotations with pull requests and linked issues. However, it lacks details on permissions, rate limits, or error handling, which are important for a search tool with no structured annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with two concise sentences that directly state the tool's function and utility. Every sentence earns its place by clarifying search scope and use cases without unnecessary elaboration or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (4 parameters, no output schema, no annotations), the description is somewhat complete but has gaps. It explains the search functionality and use cases but does not cover return values, pagination, or error scenarios, which are important for an agent to invoke the tool correctly without structured output information.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema, mentioning 'keyword' and 'optionally code changes' which align with the schema's 'query' and 'search_code' parameters, but does not provide additional syntax or format details, meeting the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('search commits by keyword') and resources ('commit messages', 'code changes'), distinguishing it from siblings like 'blame_context' or 'file_history' by focusing on keyword-based search across commits rather than line-level attribution or file-specific history.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('useful for finding when a feature was added, a bug was fixed, or a dependency was changed'), but it does not explicitly mention when not to use it or name specific alternatives among the sibling tools, such as 'file_history' for tracking file changes over time.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 5 tool updatesv1.0.0
    • First observedblame_context
    • First observedcommit_story
    • First observedfile_contributors
    • First observedfile_history
    • First observedsearch_commits

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.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    A
    maintenance
    Change tracking for AI-era codebases. AI agents call it to log structured change events (entity + diff + reasoning) before the session ends, then query history with diff, blame, history, changeset, and search. Captures the intent that would otherwise evaporate.
    8
    205 PyPI
    25
    MIT
  • 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.
    50 npm
    MIT