/ Directory / Playground / git-mcp-server
● Community cyanheads ⚡ Instant

git-mcp-server

by cyanheads · cyanheads/git-mcp-server

A git MCP with teeth — 28 tools including worktrees, stash, reflog, GPG signing, and session-scoped working directories so Claude can operate across multiple repos safely.

Where the reference git MCP covers the basics, cyanheads/git-mcp-server goes deeper. Worktree management, optional commit signing, path sandboxing, session-isolated working directories, and response format control (JSON vs Markdown) make it a good fit for multi-repo agents and enterprise workflows.

Why use it

Key features

Live Demo

What it looks like in practice

git-2.replay ▶ ready
0/0

Install

Pick your client

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "git-2": {
      "command": "npx",
      "args": [
        "-y",
        "git-mcp-server"
      ],
      "_inferred": true
    }
  }
}

Open Claude Desktop → Settings → Developer → Edit Config. Restart after saving.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "git-2": {
      "command": "npx",
      "args": [
        "-y",
        "git-mcp-server"
      ],
      "_inferred": true
    }
  }
}

Cursor uses the same mcpServers schema as Claude Desktop. Project config wins over global.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "git-2": {
      "command": "npx",
      "args": [
        "-y",
        "git-mcp-server"
      ],
      "_inferred": true
    }
  }
}

Click the MCP Servers icon in the Cline sidebar, then "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "git-2": {
      "command": "npx",
      "args": [
        "-y",
        "git-mcp-server"
      ],
      "_inferred": true
    }
  }
}

Same shape as Claude Desktop. Restart Windsurf to pick up changes.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "git-2",
      "command": "npx",
      "args": [
        "-y",
        "git-mcp-server"
      ]
    }
  ]
}

Continue uses an array of server objects rather than a map.

~/.config/zed/settings.json
{
  "context_servers": {
    "git-2": {
      "command": {
        "path": "npx",
        "args": [
          "-y",
          "git-mcp-server"
        ]
      }
    }
  }
}

Add to context_servers. Zed hot-reloads on save.

claude mcp add git-2 -- npx -y git-mcp-server

One-liner. Verify with claude mcp list. Remove with claude mcp remove.

Use Cases

Real-world ways to use git-mcp-server

Apply the same refactor across 10 repos in a monorepo-adjacent org

👤 Platform engineers, devrel ⏱ ~45 min advanced

When to use: You need to bump a dependency or rename an import across many repos and don't want to clone and context-switch manually.

Prerequisites
  • Local clones or write access — SSH keys configured
Flow
  1. Enumerate repos
    List every repo under ~/code/acme. For each, switch working directory, run git_status, and tell me the current branch.✓ Copied
    → Per-repo status
  2. Branch and apply change
    In each repo, create branch 'chore/bump-foo', bump foo from 1.x to 2.x in package.json, commit with message 'chore: bump foo', push, and open a PR (via github MCP).✓ Copied
    → PR URLs for each repo

Outcome: Cross-repo change dispatched in one conversation.

Pitfalls
  • Commit storm — a bad refactor now lives in 10 PRs — Test on one repo first; only then dispatch to the rest
  • Sign-off / DCO required but unsigned — Enable GIT_SIGN_COMMITS and set GIT_USERNAME/GIT_EMAIL
Combine with: github · filesystem

Generate release notes from git log between two tags

👤 Release managers ⏱ ~20 min intermediate

When to use: Cutting a release and want the changelog written from actual commits, not memory.

Flow
  1. Fetch tags and diff
    Switch to repo ~/code/acme/api. Fetch, then git_log from tag v1.4.0 to HEAD. Group by conventional-commit type.✓ Copied
    → Grouped commit list
  2. Draft notes
    Write release notes in keep-a-changelog format, highlighting breaking changes and contributors.✓ Copied
    → Markdown changelog draft
  3. Tag the release
    Create tag v1.5.0 with these release notes as the tag message. Sign it.✓ Copied
    → Signed tag created

Outcome: Release published with accurate, readable notes.

Pitfalls
  • Commit messages are garbage → release notes are garbage — Enforce conventional commits in CI before this step
Combine with: github

Clean up a feature branch before merge (squash + reword)

👤 Devs with messy WIP branches ⏱ ~15 min intermediate

When to use: You have 14 commits on a feature branch: 'wip', 'fix', 'more fix', 'actually fix it'. You want to squash into 3 logical commits before opening the PR.

Flow
  1. Inspect
    Show git_log for branch 'feat/payments' since it diverged from main.✓ Copied
    → Commit list
  2. Plan the squash
    Propose a 3-commit rewrite plan grouping related work. Don't execute yet.✓ Copied
    → Plan with commit boundaries + messages
  3. Execute via reset + fresh commits
    Execute the plan using git_reset --soft to the merge-base, then git_add + git_commit in 3 logical chunks per the plan.✓ Copied
    → 3-commit linear history

Outcome: A reviewable PR history.

Pitfalls
  • Destructive — force-push overwrites collaborators' work — Only do this on solo feature branches; never on shared branches

Combinations

Pair with other MCPs for X10 leverage

git-2 + github

git_commit + git_push + open PR in one flow

Commit staged changes with message 'X', push, then open a PR on GitHub targeting main.✓ Copied
git-2 + filesystem

Edit files then commit atomically

Edit src/index.ts replacing foo with bar, git_add the file, git_commit.✓ Copied

Tools

What this MCP exposes

ToolInputsWhen to callCost
git_status cwd?: str First step in any session; verify repo state free
git_log cwd?, range?, max_count? Inspect history; use range for release diffs free
git_diff cwd?, target?, staged?: bool Review changes before committing free
git_add cwd?, paths[] Stage specific files — avoid . to prevent sensitive file leaks free
git_commit cwd?, message, sign?: bool Create a commit; destructive-ish, so confirm first free
git_branch cwd?, action: list|create|delete|rename, name? Manage branches free
git_worktree cwd?, action: add|list|remove, path?, branch? Juggle multiple branches without switching free
git_push cwd?, remote?, branch?, force?: bool Publish commits; force is destructive — default to false network
set_working_directory path: str Switch the session's active repo free

Cost & Limits

What this costs to run

API quota
None — all local
Tokens per call
git_log/diff outputs can be huge; cap with max_count / paths
Monetary
Free, Apache 2.0
Tip
Use max_count on git_log and specific paths on git_diff. Full-history log on a big repo = 50k+ tokens.

Security

Permissions, secrets, blast radius

Minimum scopes: Local filesystem access to the repos you want managed
Credential storage: SSH keys in ~/.ssh; set GIT_BASE_DIR to sandbox the MCP
Data egress: git push sends to your configured remotes
Never grant: Force push to main/master without confirmation

Troubleshooting

Common errors and fixes

Permission denied (publickey) on push

SSH key not available to the MCP process. Start ssh-agent with your key loaded.

Verify: ssh -T [email protected]
Operation outside base directory rejected

You set GIT_BASE_DIR; the requested path escapes it. Move the repo into the base dir or widen it.

Commit signing fails

GPG/SSH signing key not configured. Check git config --get user.signingkey and gpg --list-secret-keys.

Verify: git commit -S -m test in the repo directly
Wrong repo operated on

Session cwd not set. Always start a session with set_working_directory or pass cwd per call.

Verify: Call git_status and inspect the returned path

Alternatives

git-mcp-server vs others

AlternativeWhen to use it insteadTradeoff
Official git MCPYou only need basic git ops and want the reference implementationFewer tools; no session cwd or signing
GitHub MCPYour workflow is PR-centric and lives on GitHubOperates on GitHub API, not local git; complementary

More

Resources

📖 Read the official README on GitHub

🐙 Browse open issues

🔍 Browse all 400+ MCP servers and Skills