/ Annuaire / Playground / git-mcp-server
● Communauté cyanheads ⚡ Instantané

git-mcp-server

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

Pourquoi l'utiliser

Fonctionnalités clés

Démo en direct

Aperçu en pratique

git-2.replay ▶ prêt
0/0

Installer

Choisissez votre 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
    }
  }
}

Ouvrez Claude Desktop → Settings → Developer → Edit Config. Redémarrez après avoir enregistré.

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

Cursor utilise le même schéma mcpServers que Claude Desktop. La config projet l'emporte sur la globale.

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

Cliquez sur l'icône MCP Servers dans la barre latérale Cline, puis "Edit Configuration".

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

Même format que Claude Desktop. Redémarrez Windsurf pour appliquer.

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

Continue utilise un tableau d'objets serveur plutôt qu'une map.

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

Ajoutez dans context_servers. Zed recharge à chaud à la sauvegarde.

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

Une seule ligne. Vérifiez avec claude mcp list. Supprimez avec claude mcp remove.

Cas d'usage

Usages concrets : git-mcp-server

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

👤 Platform engineers, devrel ⏱ ~45 min advanced

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

Prérequis
  • Local clones or write access — SSH keys configured
Déroulement
  1. Enumerate repos
    List every repo under ~/code/acme. For each, switch working directory, run git_status, and tell me the current branch.✓ Copié
    → 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).✓ Copié
    → PR URLs for each repo

Résultat : Cross-repo change dispatched in one conversation.

Pièges
  • 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
Combiner avec : github · filesystem

Generate release notes from git log between two tags

👤 Release managers ⏱ ~20 min intermediate

Quand l'utiliser : Cutting a release and want the changelog written from actual commits, not memory.

Déroulement
  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.✓ Copié
    → Grouped commit list
  2. Draft notes
    Write release notes in keep-a-changelog format, highlighting breaking changes and contributors.✓ Copié
    → Markdown changelog draft
  3. Tag the release
    Create tag v1.5.0 with these release notes as the tag message. Sign it.✓ Copié
    → Signed tag created

Résultat : Release published with accurate, readable notes.

Pièges
  • Commit messages are garbage → release notes are garbage — Enforce conventional commits in CI before this step
Combiner avec : github

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

👤 Devs with messy WIP branches ⏱ ~15 min intermediate

Quand l'utiliser : 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.

Déroulement
  1. Inspect
    Show git_log for branch 'feat/payments' since it diverged from main.✓ Copié
    → Commit list
  2. Plan the squash
    Propose a 3-commit rewrite plan grouping related work. Don't execute yet.✓ Copié
    → 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.✓ Copié
    → 3-commit linear history

Résultat : A reviewable PR history.

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

Combinaisons

Associez-le à d'autres MCPs pour un effet X10

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.✓ Copié
git-2 + filesystem

Edit files then commit atomically

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

Outils

Ce que ce MCP expose

OutilEntréesQuand appelerCoût
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

Coût et limites

Coût d'exécution

Quota d'API
None — all local
Tokens par appel
git_log/diff outputs can be huge; cap with max_count / paths
Monétaire
Free, Apache 2.0
Astuce
Use max_count on git_log and specific paths on git_diff. Full-history log on a big repo = 50k+ tokens.

Sécurité

Permissions, secrets, portée

Portées minimales : Local filesystem access to the repos you want managed
Stockage des identifiants : SSH keys in ~/.ssh; set GIT_BASE_DIR to sandbox the MCP
Sortie de données : git push sends to your configured remotes
Ne jamais accorder : Force push to main/master without confirmation

Dépannage

Erreurs courantes et correctifs

Permission denied (publickey) on push

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

Vérifier : 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.

Vérifier : 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.

Vérifier : Call git_status and inspect the returned path

Alternatives

git-mcp-server vs autres

AlternativeQuand l'utiliserCompromis
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

Plus

Ressources

📖 Lire le README officiel sur GitHub

🐙 Voir les issues ouvertes

🔍 Parcourir les 400+ serveurs MCP et Skills