Purpose
git-context-mcp is an MCP (Model Context Protocol) server whose goal is to answer a question developers commonly ask: "Why does this code exist?"
Traditional git blame can only tell you who wrote a certain line, whereas git-context-mcp further traces the commit behind that line, the Pull Request that landed that commit, the PR description, and all associated GitHub Issues, helping you understand the historical background and the reasons behind decisions about the code.
Main Capabilities
- Given a file and a line range, run git blame -p to find the corresponding commit hash.
- For each commit, call git show to obtain the full commit message and diff statistics.
- Via the GitHub API (gh api /repos/:owner/:repo/commits/:hash/pulls), find the associated Pull Request.
- Parse #NNN and /issues/NNN references in the PR body, and fetch the content of each Issue.
- Return all results as structured Markdown for Claude to reason about and present.
How to Use
There are three ways to install:
- Use npx (no installation required).
- Install globally.
- Manual configuration: add the configuration to ~/.claude/claude_mcp_config.json, then restart Claude Code.
The usage environment is Claude Code or any MCP-compatible client.
GitHub PR/Issue queries require the gh CLI (which must be installed) and running gh auth login. When gh is not installed, the tool can still run, it will just skip the PR/Issue context.
After installation is complete, you can use it directly in any git repository by conversing with Claude in natural language.
Applicable Scenarios
- When you need to understand the historical reasons and design decisions behind a piece of code.
- When investigating the background of code changes and quickly locating related PRs and Issues.
- When obtaining code context directly in Claude, avoiding the need to manually dig through git log, search GitHub, and cross-reference issue trackers.
Limitations
- Does not store tokens.
- Except for GitHub itself's API, it does not send data anywhere else (consistent with the behavior of the gh CLI).
- When the gh CLI is not installed, PR and Issue context cannot be obtained.
- The entire server code is located in src/index.ts.
Other
PRs are welcome.