# git-mcp-server [Health: Active]

**Category:** 🔄 Version Control  
**Repository:** https://github.com/cyanheads/git-mcp-server  
**GitHub Stars:** 245  
**npm Downloads (last month):** 19010  
**Views:** 12  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/git-mcp-server-2

## Description
Comprehensive Git MCP server enabling native git tools including clone, commit, worktree, & more.

## Tools
Capabilities this server exposes over MCP:

- **git_add** — Stage files for commit. Add file contents to the staging area (index) to prepare for the next commit.
- **git_blame** — Show line-by-line authorship information for a file, displaying who last modified each line and when. For large files, use startLine/endLine to limit output.
- **git_branch** — Manage branches: list all branches, show current branch, create a new branch, delete a branch, or rename a branch.
- **git_changelog_analyze** — Gather git history context (commits, tags) and structured review instructions to support LLM-driven changelog analysis. Changelog file should be read separately; this tool provides the supporting git data and analysis framework. Pass one or more review types to control what kind of analysis to perform.
- **git_checkout** — Switch branches or restore working tree files. Can checkout an existing branch, create a new branch, or restore specific files.
- **git_cherry_pick** — Cherry-pick commits from other branches. Apply specific commits to the current branch without merging entire branches.
- **git_clean** — Remove untracked files from the working directory. Requires force flag for safety. Use dry-run to preview files that would be removed.
- **git_clear_working_dir** — Clear the session working directory setting. This resets the context without restarting the server. Subsequent git operations will require an explicit path parameter unless git_set_working_dir is called again.
- **git_clone** — Clone a repository from a remote URL or local path. Accepts HTTP(S), SSH, git://, file://, and bare filesystem paths, with optional shallow cloning.
- **git_commit** — Create a new commit with staged changes in the repository. Records a snapshot of the staging area with a commit message.

**Commit Message Format:**
Pass commit messages as JSON string parameters. Multi-line messages are supported using standard JSON string escaping.

**Examples:**
- Single line: { "message": "feat: add user authentication" }
- Multi-line: { "message": "feat: add user authentication\n\nImplemented OAuth2 flow with JWT tokens.\nAdded tests for login and logout." }

Note: Do not use bash heredoc syntax. Literal escape sequences (\n, \t) in the message string are automatically normalized to their actual characters.
- **git_diff** — View differences between commits, branches, or working tree. Shows changes in unified diff format.
- **git_fetch** — Fetch updates from a remote repository. Downloads objects and refs without merging them.
- **git_init** — Initialize a new Git repository at the specified path. Creates a .git directory and sets up the initial branch.
- **git_log** — View commit history with optional filtering by author, date range, file path, or commit message pattern.
- **git_merge** — Merge branches together. Integrates changes from another branch into the current branch with optional merge strategies.
- **git_pull** — Pull changes from a remote repository. Fetches and integrates changes into the current branch.
- **git_push** — Push changes to a remote repository. Uploads local commits to the remote branch.
- **git_rebase** — Rebase commits onto another branch. Reapplies commits on top of another base tip for a cleaner history.
- **git_reflog** — View the reference logs (reflog) to track when branch tips and other references were updated. Useful for recovering lost commits.
- **git_remote** — Manage remote repositories: list remotes, add new remotes, remove remotes, rename remotes, or get/set remote URLs.
- **git_reset** — Reset current HEAD to specified state. Can be used to unstage files (soft), discard commits (mixed), or discard all changes (hard).
- **git_set_working_dir** — Set the session working directory for all git operations so subsequent calls can omit the path parameter. Always returns a repository snapshot (status, recent commits, recent tags, remotes) to orient the caller.
- **git_show** — Show details of a git object (commit, tree, blob, or tag). Displays commit information and the diff of changes introduced.
- **git_stash** — Manage stashes: list stashes, save current changes (push), restore changes (pop/apply), or remove stashes (drop/clear).
- **git_status** — Show the working tree status including staged, unstaged, and untracked files.
- **git_tag** — Manage tags: list all tags, create a new tag, delete a tag, or verify a signed tag. Tags are used to mark specific points in history (releases, milestones). Verify runs `git tag -v` and returns a structured result distinguishing unsigned tags, missing trust configuration, bad signatures, and valid signatures.
- **git_worktree** — Manage multiple working trees: list worktrees, add new worktrees for parallel work, remove worktrees, or move worktrees to new locations.
- **git_wrapup_instructions** — Returns a Git wrap-up protocol: an acceptance-criteria checklist the agent must satisfy before the session is considered shipped. Uses the operator's custom instructions if configured, otherwise emits a generic goals-strict/mechanism-generic default. Enriches the response with a repository snapshot (status, recent commits, recent tags) so the agent has immediate orientation for the commit and release steps.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "git-mcp-server": {
    "command": "npx",
    "args": ["-y","@cyanheads/git-mcp-server@latest"],
    "env": {
      "MCP_TRANSPORT_TYPE": "",
      "MCP_LOG_LEVEL": "",
      "MCP_HTTP_PORT": "",
      "GIT_BASE_DIR": "",
      "LOGS_DIR": "",
      "GIT_USERNAME": "",
      "GIT_EMAIL": "",
      "GIT_SIGN_COMMITS": ""
    }
  }
}
```

**Requires environment variables:** `MCP_TRANSPORT_TYPE`, `MCP_LOG_LEVEL`, `MCP_HTTP_PORT`, `GIT_BASE_DIR`, `LOGS_DIR`, `GIT_USERNAME`, `GIT_EMAIL`, `GIT_SIGN_COMMITS` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What the git-mcp-server MCP server does

The git-mcp-server MCP server gives AI agents access to 28 Git operations through the Model Context Protocol. Its tools cover the repository lifecycle, from initialization and cloning through staging, committing, synchronization, and cleanup. It also exposes one resource, `git://working-directory`, and one prompt for a structured Git session wrap-up.

Supported operations include:

- Repository initialization, cloning, status checks, and cleanup of untracked files.
- Staging, commits, diffs, logs, object inspection, blame, and reflogs.
- Branch creation and management, checkout, merge, rebase, and cherry-pick.
- Remote configuration, fetch, pull, and push.
- Tags, stashes, resets, and worktrees.
- Setting and clearing the working directory used by a session.

The current provider uses the Git CLI. The repository describes isomorphic-git as a planned provider for edge deployment, not as a current implementation.

## How it works

The git-mcp-server MCP server can communicate over STDIO or Streamable HTTP. Runtime detection selects the appropriate process-spawning behavior for Node.js or Bun. Node.js requires version 20 or newer, while Bun requires version 1.2 or newer.

A session can set a working directory with `git_set_working_dir`; that location is also available through the `git://working-directory` resource. This supports workflows that move between repositories or worktrees without treating one fixed directory as the only context.

Git identity can be supplied through environment variables, with fallback to the global Git configuration. Commit signing supports GPG and SSH for commits, merges, rebases, cherry-picks, and tags. If signing fails, the operation can fall back to an unsigned result and report signing fields in its response.

Destructive actions such as `git clean` and `git reset --hard` require explicit confirmation flags. File paths are validated and sanitized to help prevent directory traversal.

## Setup and configuration

Run the package with `npx @cyanheads/git-mcp-server@latest` under Node.js or `bunx @cyanheads/git-mcp-server@latest` under Bun. Add the command to an MCP client configuration as a STDIO server. For HTTP transport, set `MCP_TRANSPORT_TYPE` to `http` and provide `MCP_HTTP_PORT`, such as `3015`.

Configuration can include `GIT_BASE_DIR` for the base location, `LOGS_DIR` for logs, `GIT_USERNAME` and `GIT_EMAIL` for identity, and `GIT_SIGN_COMMITS` to control commit signing. `MCP_LOG_LEVEL` sets the logging level. The example configuration uses `stdio` transport and enables signing.

## Tools and capabilities

The tools are organized into repository management, staging and commits, history and inspection, analysis, branching and merging, remote operations, and advanced workflows. The `git_changelog_analyze` tool gathers Git context and instructions for LLM-driven changelog analysis. The Git Wrap-up prompt accepts `changelogPath` and `createTag` parameters to guide review, documentation, commits, and optional tagging.

The framework provides structured error responses, Pino logging, optional OpenTelemetry instrumentation, and pluggable storage options including in-memory, filesystem, Supabase, and Cloudflare KV/R2. Authentication modes include `none`, `jwt`, and `oauth`.

## Limitations and notes

The server operates through the Git CLI provider, so Git must be available to the runtime environment. The material does not document a current isomorphic-git implementation. Authentication, storage, and HTTP deployment details beyond the listed modes and transport settings are not specified. Signing is supported, but failures may produce unsigned commits, merges, rebases, cherry-picks, or tags with a warning rather than stopping the operation.

_Full upstream README: https://allmcps.com/mcp/git-mcp-server-2/readme_

