# git-mcp-server

Exposes 28 Git tools to AI agents, covering branching, commits, worktrees, and changelog analysis. Useful when delegating repository workflows directly to models.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed · ★ 242
- Author: cyanheads
- License: Apache-2.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/cyanheads/git-mcp-server
- Updated: 2026-09-26
- HTML: https://affpapa.org/en/nevibecode/mcp/git-mcp-server

## What it does

The server equips coding agents with 28 Git tools. It handles staging, commits, branch creation, merges, and cherry-picking. For repository history, it provides `git_blame`, reflogs, and an inspection utility named `git_changelog_analyze`. That tool extracts commit diffs for release summaries.

Beyond file tracking, it includes a session resource at `git://working-directory` and a workflow prompt called `Git Wrap-up`. This protocol helps models review, record, and tag updates before closing a task. Connection happens over stdio or Streamable HTTP.

You need Node.js 20.0.0 or Bun 1.2.0 at minimum. Runtime is detected automatically. Without configuring `GIT_USERNAME` and `GIT_EMAIL` in the environment block, commit generation will fail.

## Requirements
- Needs: Node.js (commands run via npx)
- Environment variables: `MCP_LOG_LEVEL`, `GIT_BASE_DIR`, `MCP_HTTP_HOST`, `MCP_HTTP_PORT`, `MCP_HTTP_ENDPOINT_PATH`, `MCP_AUTH_MODE` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add --env MCP_LOG_LEVEL=<MCP_LOG_LEVEL> --env GIT_BASE_DIR=<GIT_BASE_DIR> --env MCP_HTTP_HOST=<MCP_HTTP_HOST> --env MCP_HTTP_PORT=<MCP_HTTP_PORT> --env MCP_HTTP_ENDPOINT_PATH=<MCP_HTTP_ENDPOINT_PATH> --transport stdio git-mcp-server -- npx -y @cyanheads/git-mcp-server
```
Replace <…> with your own values. 1 more environment variable is in the server README

### Codex

**Platform CLI**
```bash
codex mcp add git-mcp-server --env MCP_LOG_LEVEL=<MCP_LOG_LEVEL> --env GIT_BASE_DIR=<GIT_BASE_DIR> --env MCP_HTTP_HOST=<MCP_HTTP_HOST> --env MCP_HTTP_PORT=<MCP_HTTP_PORT> --env MCP_HTTP_ENDPOINT_PATH=<MCP_HTTP_ENDPOINT_PATH> -- npx -y @cyanheads/git-mcp-server
```
Replace <…> with your own values. 1 more environment variable is in the server README

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "git-mcp-server": {
            "command": "npx",
            "args": [
                "-y",
                "@cyanheads/git-mcp-server"
            ],
            "env": {
                "MCP_LOG_LEVEL": "<MCP_LOG_LEVEL>",
                "GIT_BASE_DIR": "<GIT_BASE_DIR>",
                "MCP_HTTP_HOST": "<MCP_HTTP_HOST>",
                "MCP_HTTP_PORT": "<MCP_HTTP_PORT>",
                "MCP_HTTP_ENDPOINT_PATH": "<MCP_HTTP_ENDPOINT_PATH>"
            }
        }
    }
}
```
Replace <…> with your own values. 1 more environment variable is in the server README

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "git-mcp-server": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "@cyanheads/git-mcp-server"
            ],
            "env": {
                "MCP_LOG_LEVEL": "<MCP_LOG_LEVEL>",
                "GIT_BASE_DIR": "<GIT_BASE_DIR>",
                "MCP_HTTP_HOST": "<MCP_HTTP_HOST>",
                "MCP_HTTP_PORT": "<MCP_HTTP_PORT>",
                "MCP_HTTP_ENDPOINT_PATH": "<MCP_HTTP_ENDPOINT_PATH>"
            }
        }
    }
}
```
Replace <…> with your own values. 1 more environment variable is in the server README

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e MCP_LOG_LEVEL=<MCP_LOG_LEVEL> -e GIT_BASE_DIR=<GIT_BASE_DIR> -e MCP_HTTP_HOST=<MCP_HTTP_HOST> -e MCP_HTTP_PORT=<MCP_HTTP_PORT> -e MCP_HTTP_ENDPOINT_PATH=<MCP_HTTP_ENDPOINT_PATH> git-mcp-server npx -y @cyanheads/git-mcp-server
```
Replace <…> with your own values. 1 more environment variable is in the server README

## When to use it
- Stage files, generate commits, and push changes from prompts
- Trace code authorship with `git_blame` without leaving the chat
- Prepare commit context for automated changelog generation
- Switch branches and isolate parallel experiments using worktrees

## Example prompts
- Commit all staged modifications with the message "fix: handle edge cases"
- Show recent commit history using `git_log` and explain the last patch
- Run `git_changelog_analyze` to summarize changes since the previous tag

## Similar
- [GitHub](https://affpapa.org/en/nevibecode/mcp/github.md) — MCP server · ★ 33918
- [GitDiagram](https://affpapa.org/en/nevibecode/mcp/gitdiagram.md) — MCP server · ★ 18446
- [Repowise](https://affpapa.org/en/nevibecode/mcp/repowise.md) — MCP server · ★ 7891
- [Octocode MCP - AI Context Platform](https://affpapa.org/en/nevibecode/mcp/octocode-mcp-ai-context-platform.md) — MCP server · ★ 955
- [projectmem](https://affpapa.org/en/nevibecode/mcp/projectmem.md) — MCP server · ★ 866
- [Memorix](https://affpapa.org/en/nevibecode/mcp/memorix.md) — MCP server · ★ 863

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
