/ ディレクトリ / プレイグラウンド / git-mcp-server
● コミュニティ cyanheads ⚡ 即起動

git-mcp-server

作者 cyanheads · cyanheads/git-mcp-server

本格派のgit MCP — ワークツリー、スタッシュ、reflog、GPG署名、セッションスコープの作業ディレクトリなど28のツールを備え、Claudeが複数リポジトリを安全に操作できます。

リファレンス実装のgit MCPが基本機能をカバーするのに対し、cyanheads/git-mcp-serverはさらに深い機能を提供します。ワークツリー管理、オプションのコミット署名、パスのサンドボックス化、セッション分離された作業ディレクトリ、レスポンス形式の制御(エージェント向けJSON / 人間向けMarkdown)により、マルチリポジトリエージェントやエンタープライズワークフローに適しています。

なぜ使うのか

主な機能

ライブデモ

実際の動作

git-2.replay ▶ 準備完了
0/0

インストール

クライアントを選択

~/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
    }
  }
}

Claude Desktop → Settings → Developer → Edit Config を開く。保存後、アプリを再起動。

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

Cursor は Claude Desktop と同じ mcpServers スキーマを使用。プロジェクト設定はグローバルより優先。

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

Cline サイドバーの MCP Servers アイコンをクリックし、"Edit Configuration" を選択。

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

Claude Desktop と同じ形式。Windsurf を再起動して反映。

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

Continue はマップではなくサーバーオブジェクトの配列を使用。

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

context_servers に追加。保存時に Zed がホットリロード。

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

ワンライナー。claude mcp list で確認、claude mcp remove で削除。

ユースケース

実用的な使い方: git-mcp-server

モノレポ隣接組織の10リポジトリに同一リファクタリングを適用する

👤 プラットフォームエンジニア、DevRel ⏱ ~45 min advanced

使うタイミング: 多数のリポジトリで依存関係のバンプやインポートのリネームが必要で、手動でクローンやコンテキストスイッチをしたくない場合。

前提条件
  • ローカルクローンまたは書き込みアクセス — SSHキーを設定済みであること
フロー
  1. リポジトリの列挙
    List every repo under ~/code/acme. For each, switch working directory, run git_status, and tell me the current branch.✓ コピーしました
    → リポジトリごとのステータス
  2. ブランチ作成と変更適用
    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).✓ コピーしました
    → 各リポジトリのPR URL

結果: クロスリポジトリの変更を1つの会話で一括ディスパッチ。

注意点
  • コミットの嵐 — 不具合のあるリファクタリングが10個のPRに拡散する — まず1つのリポジトリでテストし、問題なければ残りに展開する
  • Sign-off / DCOが必要だが署名されていない — GIT_SIGN_COMMITSを有効にし、GIT_USERNAME/GIT_EMAILを設定する
組み合わせ: github · filesystem

2つのタグ間のgitログからリリースノートを生成する

👤 リリースマネージャー ⏱ ~20 min intermediate

使うタイミング: リリースカット時に、記憶ではなく実際のコミットからチェンジログを作成したい場合。

フロー
  1. タグの取得と差分確認
    Switch to repo ~/code/acme/api. Fetch, then git_log from tag v1.4.0 to HEAD. Group by conventional-commit type.✓ コピーしました
    → 種別ごとにグループ化されたコミットリスト
  2. ノートの下書き
    Write release notes in keep-a-changelog format, highlighting breaking changes and contributors.✓ コピーしました
    → Markdownチェンジログのドラフト
  3. リリースのタグ付け
    Create tag v1.5.0 with these release notes as the tag message. Sign it.✓ コピーしました
    → 署名付きタグの作成完了

結果: 正確で読みやすいノート付きでリリースを公開。

注意点
  • コミットメッセージが雑 → リリースノートも雑になる — このステップの前にCIでconventional commitsを強制する
組み合わせ: github

マージ前にフィーチャーブランチを整理する(squash + reword)

👤 WIPコミットが散らかったブランチを持つ開発者 ⏱ ~15 min intermediate

使うタイミング: フィーチャーブランチに「wip」「fix」「more fix」「actually fix it」といったコミットが14個ある場合。PR作成前に論理的な3コミットにスカッシュしたいとき。

フロー
  1. 確認
    Show git_log for branch 'feat/payments' since it diverged from main.✓ コピーしました
    → コミットリスト
  2. スカッシュ計画
    Propose a 3-commit rewrite plan grouping related work. Don't execute yet.✓ コピーしました
    → コミット境界とメッセージを含む計画
  3. reset + 新規コミットで実行
    Execute the plan using git_reset --soft to the merge-base, then git_add + git_commit in 3 logical chunks per the plan.✓ コピーしました
    → 3コミットのリニア履歴

結果: レビューしやすいPR履歴。

注意点
  • 破壊的操作 — force-pushで共同作業者の変更を上書きする — 個人のフィーチャーブランチでのみ実行し、共有ブランチでは絶対に行わない

組み合わせ

他のMCPと組み合わせて10倍の力を

git-2 + github

git_commit + git_push + PR作成を1つのフローで実行

Commit staged changes with message 'X', push, then open a PR on GitHub targeting main.✓ コピーしました
git-2 + filesystem

ファイル編集後にアトミックにコミット

Edit src/index.ts replacing foo with bar, git_add the file, git_commit.✓ コピーしました

ツール

このMCPが提供する機能

ツール入力呼び出すタイミングコスト
git_status cwd?: str セッションの最初のステップ。リポジトリの状態を確認する free
git_log cwd?, range?, max_count? 履歴の確認。リリース差分には range を使用 free
git_diff cwd?, target?, staged?: bool コミット前に変更内容をレビューする free
git_add cwd?, paths[] 特定のファイルをステージする — 機密ファイルの漏洩を防ぐため.は避ける free
git_commit cwd?, message, sign?: bool コミットを作成する。破壊的な側面があるため、事前に確認すること free
git_branch cwd?, action: list|create|delete|rename, name? ブランチを管理する free
git_worktree cwd?, action: add|list|remove, path?, branch? ブランチ切り替えなしで複数ブランチを並行操作する free
git_push cwd?, remote?, branch?, force?: bool コミットを公開する。forceは破壊的 — デフォルトはfalseにすること network
set_working_directory path: str セッションのアクティブリポジトリを切り替える free

コストと制限

運用コスト

APIクォータ
なし — すべてローカル実行
呼び出しあたりのトークン
git_log/diffの出力は巨大になりうる。max_count / pathsで制限すること
金額
無料、Apache 2.0ライセンス
ヒント
git_logにはmax_countを、git_diffには特定のパスを使用してください。大規模リポジトリのフル履歴ログは50,000トークン以上になります。

セキュリティ

権限、シークレット、影響範囲

最小スコープ: Local filesystem access to the repos you want managed
認証情報の保管: SSHキーは~/.sshに格納。MCPをサンドボックス化するにはGIT_BASE_DIRを設定
データ送信先: git pushは設定済みのリモートにデータを送信します
絶対に付与しない: Force push to main/master without confirmation

トラブルシューティング

よくあるエラーと対処法

Permission denied (publickey) — プッシュ時

MCPプロセスからSSHキーにアクセスできません。キーをロードした状態でssh-agentを起動してください。

確認: ssh -T [email protected]
Operation outside base directory rejected — ベースディレクトリ外の操作が拒否された

GIT_BASE_DIRが設定されており、リクエストされたパスがその範囲外です。リポジトリをベースディレクトリ内に移動するか、範囲を広げてください。

Commit signing fails — コミット署名の失敗

GPG/SSH署名キーが設定されていません。git config --get user.signingkeygpg --list-secret-keysを確認してください。

確認: git commit -S -m test in the repo directly
Wrong repo operated on — 誤ったリポジトリへの操作

セッションのcwdが未設定です。セッション開始時に必ずset_working_directoryを実行するか、呼び出しごとにcwdを渡してください。

確認: Call git_status and inspect the returned path

代替案

git-mcp-server 他との比較

代替案代わりに使う場面トレードオフ
Official git MCP基本的なgit操作のみ必要で、リファレンス実装を使いたい場合ツール数が少ない。セッションcwdや署名機能なし
GitHub MCPワークフローがPR中心でGitHub上で完結する場合ローカルgitではなくGitHub APIで操作。補完的に使用

その他

リソース

📖 GitHub の公式 README を読む

🐙 オープンな issue を見る

🔍 400以上のMCPサーバーとSkillsを見る