/ Каталог / Песочница / git-mcp-server
● Сообщество cyanheads ⚡ Сразу

git-mcp-server

автор 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.

Зачем использовать

Ключевые функции

Живое демо

Как выглядит на практике

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 использует ту же схему mcpServers, что и Claude Desktop. Конфиг проекта приоритетнее глобального.

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

Щёлкните значок MCP Servers на боковой панели Cline, затем "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 использует массив объектов серверов, а не map.

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

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

👤 Platform engineers, devrel ⏱ ~45 min advanced

Когда использовать: You need to bump a dependency or rename an import across many repos and don't want to clone and context-switch manually.

Предварительные требования
  • Local clones or write access — SSH keys configured
Поток
  1. Enumerate repos
    List every repo under ~/code/acme. For each, switch working directory, run git_status, and tell me the current branch.✓ Скопировано
    → 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).✓ Скопировано
    → PR URLs for each repo

Итог: Cross-repo change dispatched in one conversation.

Подводные камни
  • 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
Сочетать с: github · filesystem

Generate release notes from git log between two tags

👤 Release managers ⏱ ~20 min intermediate

Когда использовать: Cutting a release and want the changelog written from actual commits, not memory.

Поток
  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.✓ Скопировано
    → Grouped commit list
  2. Draft notes
    Write release notes in keep-a-changelog format, highlighting breaking changes and contributors.✓ Скопировано
    → Markdown changelog draft
  3. Tag the release
    Create tag v1.5.0 with these release notes as the tag message. Sign it.✓ Скопировано
    → Signed tag created

Итог: Release published with accurate, readable notes.

Подводные камни
  • Commit messages are garbage → release notes are garbage — Enforce conventional commits in CI before this step
Сочетать с: github

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

👤 Devs with messy WIP branches ⏱ ~15 min intermediate

Когда использовать: 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.

Поток
  1. Inspect
    Show git_log for branch 'feat/payments' since it diverged from main.✓ Скопировано
    → Commit list
  2. Plan the squash
    Propose a 3-commit rewrite plan grouping related work. Don't execute yet.✓ Скопировано
    → 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.✓ Скопировано
    → 3-commit linear history

Итог: A reviewable PR history.

Подводные камни
  • Destructive — force-push overwrites collaborators' work — Only do this on solo feature branches; never on shared branches

Комбинации

Сочетайте с другими MCP — эффект 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.✓ Скопировано
git-2 + filesystem

Edit files then commit atomically

Edit src/index.ts replacing foo with bar, git_add the file, git_commit.✓ Скопировано

Инструменты

Что предоставляет этот MCP

ИнструментВходные данныеКогда вызыватьСтоимость
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

Стоимость и лимиты

Во что обходится

Квота API
None — all local
Токенов на вызов
git_log/diff outputs can be huge; cap with max_count / paths
Деньги
Free, Apache 2.0
Совет
Use max_count on git_log and specific paths on git_diff. Full-history log on a big repo = 50k+ tokens.

Безопасность

Права, секреты, радиус поражения

Минимальные скоупы: Local filesystem access to the repos you want managed
Хранение учётных данных: SSH keys in ~/.ssh; set GIT_BASE_DIR to sandbox the MCP
Исходящий трафик: git push sends to your configured remotes
Никогда не давайте: Force push to main/master without confirmation

Устранение неполадок

Частые ошибки и исправления

Permission denied (publickey) on push

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

Проверить: 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.

Проверить: 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.

Проверить: Call git_status and inspect the returned path

Альтернативы

git-mcp-server в сравнении

АльтернативаКогда использоватьКомпромисс
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

Ещё

Ресурсы

📖 Читать официальный README на GitHub

🐙 Открытые задачи

🔍 Все 400+ MCP-серверов и Skills