Skip to main content
Glama

git-context-mcp

모든 개발자가 가진 질문인 **"이 코드는 왜 존재하는가?"**에 답하는 MCP 서버입니다.

git blame은 코드 한 줄을 누가 작성했는지 알려줍니다. 이 도구는 왜 작성했는지 알려줍니다.

파일과 줄 범위를 지정하면 git-context-mcp가 커밋을 역추적하여 해당 코드가 포함된 풀 리퀘스트(PR)를 찾고, PR 설명을 읽은 뒤, 연결된 모든 GitHub 이슈를 한 번에 Claude 안에서 바로 보여줍니다.


데모

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

더 이상 git 로그를 뒤지거나, GitHub를 검색하거나, 이슈 트래커를 교차 참조할 필요가 없습니다. Claude가 한 번에 처리합니다.


Related MCP server: Git Insight MCP

도구

도구

기능

blame_context

파일 + 줄 범위 → 커밋 + PR 설명 + 연결된 이슈

commit_story

커밋 해시 → 전체 내러티브 (메시지, diff 통계, PR, 이슈)

file_history

파일 → 최근 N개의 커밋 (각각 PR 및 이슈 정보 포함)

search_commits

키워드 → PR/이슈 컨텍스트가 포함된 일치하는 커밋

file_contributors

파일 → 기여자 순위 표 (커밋 수, 소유한 줄 수, 활동 날짜)


설치

옵션 1 — npx (설치 불필요)

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

옵션 2 — 전역 설치

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

옵션 3 — 수동 설정

~/.claude/claude_mcp_config.json에 추가하세요:

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

그런 다음 Claude Code를 재시작하세요.


요구 사항

  • Claude Code (또는 MCP 호환 클라이언트)

  • PATH에 git 포함

  • gh CLI (설치) + GitHub PR/이슈 조회를 위한 gh auth login

    • gh 없이도 작동하지만, PR/이슈 컨텍스트는 생략됩니다.


사용 예시

설치가 완료되면 git 저장소에서 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"

작동 원리

  1. **blame_context**가 해당 줄에 대해 git blame -p를 실행하여 커밋 해시를 찾습니다.

  2. 각 커밋에 대해 git show를 호출하여 전체 메시지와 diff 통계를 가져옵니다.

  3. GitHub API (gh api /repos/:owner/:repo/commits/:hash/pulls)를 호출하여 PR을 찾습니다.

  4. PR 본문에서 #NNN 및 /issues/NNN 참조를 파싱하여 각 이슈를 가져옵니다.

  5. 모든 정보가 Claude가 추론할 수 있도록 구조화된 마크다운으로 반환됩니다.

토큰은 저장되지 않습니다. GitHub 자체 API 외에는 데이터가 전송되지 않습니다 (gh CLI와 동일).


기여

PR을 환영합니다. 서버 전체 코드는 src/index.ts에 있습니다.

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

라이선스

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