/ Каталог / Песочница / Git
● Официальный modelcontextprotocol ⚡ Сразу

Git

автор modelcontextprotocol · modelcontextprotocol/servers

Point your agent at a local repo and let it read status, log, diff, and blame — no shell access needed.

Official modelcontextprotocol git server. Read and write local git: status, log, diff (staged/unstaged/commit-range), show, blame-lite via show, plus commit/add/branch/checkout for write-capable workflows. Scoped to a single --repository path — safer than giving the agent raw shell.

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

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

Живое демо

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

git.replay ▶ готово
0/0

Установка

Выберите клиент

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "git": {
      "command": "uvx",
      "args": [
        "mcp-server-git",
        "--repository",
        "/repo"
      ]
    }
  }
}

Откройте Claude Desktop → Settings → Developer → Edit Config. Перезапустите после сохранения.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "git": {
      "command": "uvx",
      "args": [
        "mcp-server-git",
        "--repository",
        "/repo"
      ]
    }
  }
}

Cursor использует ту же схему mcpServers, что и Claude Desktop. Конфиг проекта приоритетнее глобального.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "git": {
      "command": "uvx",
      "args": [
        "mcp-server-git",
        "--repository",
        "/repo"
      ]
    }
  }
}

Щёлкните значок MCP Servers на боковой панели Cline, затем "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "git": {
      "command": "uvx",
      "args": [
        "mcp-server-git",
        "--repository",
        "/repo"
      ]
    }
  }
}

Тот же формат, что и Claude Desktop. Перезапустите Windsurf для применения.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "git",
      "command": "uvx",
      "args": [
        "mcp-server-git",
        "--repository",
        "/repo"
      ]
    }
  ]
}

Continue использует массив объектов серверов, а не map.

~/.config/zed/settings.json
{
  "context_servers": {
    "git": {
      "command": {
        "path": "uvx",
        "args": [
          "mcp-server-git",
          "--repository",
          "/repo"
        ]
      }
    }
  }
}

Добавьте в context_servers. Zed перезагружается автоматически.

claude mcp add git -- uvx mcp-server-git --repository /repo

Однострочная команда. Проверить: claude mcp list. Удалить: claude mcp remove.

Сценарии использования

Реальные сценарии: Git

Have an agent review your staged changes before you commit

👤 Solo devs, anyone who ships without code review ⏱ ~3 min beginner

Когда использовать: About to commit. Want a second pair of eyes to catch obvious smell before the commit lands.

Предварительные требования
  • Local repo with staged changesgit add -p as usual, then ask the agent
Поток
  1. Read the staged diff
    Show me my staged changes. Flag anything that looks like: debug logs, commented code, hardcoded secrets, or changes unrelated to the stated commit goal '<GOAL>'.✓ Скопировано
    → Specific file:line flags
  2. Suggest a commit message
    Write a commit message following conventional commits. First line under 60 chars, body explains why not what.✓ Скопировано
    → Copy-pasteable message
  3. Confirm scope
    Based on the diff, is this commit appropriately small? Suggest splits if it touches multiple concerns.✓ Скопировано
    → Go/no-go with rationale

Итог: A cleaner commit with fewer 'oops' follow-ups.

Подводные камни
  • Agent misses secrets because they don't look obviously secret-shaped — Don't rely on this as a secret scanner — run gitleaks or trufflehog in your pre-commit hook as the real defense
  • Asking for a commit message biases the agent to approve the diff — Always do the review step BEFORE asking for a message — order matters
Сочетать с: github

Find when and why a specific line broke

👤 Engineers debugging regressions ⏱ ~15 min intermediate

Когда использовать: A test started failing and you need to know which commit introduced the bug.

Поток
  1. Narrow the suspect file's history
    Show git log for src/checkout/Cart.tsx limited to the last 20 commits. Include author and short message.✓ Скопировано
    → Compact history with SHAs
  2. Diff the suspicious commits
    For the 3 commits that touched the calculateTotal function, show the diff. Focus on math/logic changes, ignore style.✓ Скопировано
    → Per-commit diff snippets
  3. Form a regression hypothesis
    Which commit most likely introduced an off-by-one or rounding bug? Point to the exact line and explain your reasoning.✓ Скопировано
    → Specific SHA + line with rationale

Итог: A precise commit-level hypothesis you can confirm with git revert + re-run tests.

Подводные камни
  • Rename-heavy history loses the trail at renames — Use git log --follow mentality — ask the agent to include the commit that renamed the file and look at that commit's pre-rename path
Сочетать с: github

List and categorize stale local branches

👤 Anyone whose `git branch` output is pages long ⏱ ~10 min beginner

Когда использовать: Quarterly cleanup — too many branches, unclear which are safe to delete.

Поток
  1. List all local branches
    List every local branch with its last commit date and message.✓ Скопировано
    → Table of branches
  2. Classify each
    Classify: 'merged' (ancestor of main), 'stale' (no commit in 60+ days), 'active' (commit in last 30 days). Flag any that look like abandoned experiments.✓ Скопировано
    → Categorized list
  3. Propose deletions
    Give me the git branch -d command for everything safe to delete. Flag anything that needs -D (force) and explain why.✓ Скопировано
    → Copy-pasteable cleanup commands

Итог: A pruned branch list with confidence you're not dropping work.

Подводные камни
  • Agent suggests -D for branches that actually have unique commits not on main — Always eyeball the force-delete list manually — one git reflog recovery is cheap but annoying

Комбинации

Сочетайте с другими MCP — эффект x10

git + github

Local git review before pushing, then open a PR with the same context

Review my staged changes. If they look good, commit with a descriptive message, push the branch, and open a PR on GitHub.✓ Скопировано

Code changes + git history in one reasoning loop

Read src/auth/login.ts and the last 5 commits that touched it. Explain why the retry logic was added.✓ Скопировано

Инструменты

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

ИнструментВходные данныеКогда вызыватьСтоимость
git_status repo_path First call of any session — understand what's dirty free
git_diff_unstaged repo_path, context_lines? Review unstaged changes before git add free
git_diff_staged repo_path, context_lines? Review what's about to be committed free
git_diff repo_path, target, context_lines? Compare current branch to target (e.g. main, HEAD~5) free
git_log repo_path, max_count?, start_timestamp?, end_timestamp? History browsing — pair with max_count to limit token use free
git_show repo_path, revision Inspect a specific commit free
git_commit repo_path, message Create a commit from staged changes — DISABLE for read-only setups free
git_add repo_path, files: string[] Stage specific files — prefer over git_add . for agent safety free
git_reset repo_path Unstage everything — dangerous, usually skip free
git_create_branch repo_path, branch_name, base_branch? Start a new branch for a task free
git_checkout repo_path, branch_name Switch branches free
git_branch repo_path, branch_type, contains?, not_contains? List branches, filter by containing a commit free

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

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

Квота API
None — all local
Токенов на вызов
200–5000 per diff depending on size
Деньги
Free
Совет
Large diffs blow up token costs fast. Use context_lines: 1 or filter by path in your prompt before asking the agent to read the whole thing.

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

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

Хранение учётных данных: None — no credentials
Исходящий трафик: None — server is 100% local, no network calls

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

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

fatal: not a git repository

The --repository path doesn't point at a git repo. Verify with ls <path>/.git — the directory must exist.

Проверить: ls <repo_path>/.git/HEAD
Empty diff output despite uncommitted changes

Check staged vs unstaged — git_diff_unstaged and git_diff_staged are separate tools. Use git_status first to see what's where.

git_commit fails with 'Please tell me who you are'

Set git config in the repo: git config user.email ... and git config user.name .... The MCP uses your existing git config.

Проверить: git config --get user.email
Huge diff burns tokens

Pass context_lines: 0 or 1, or ask the agent to summarize file-by-file first before reading full diffs.

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

Git в сравнении

АльтернативаКогда использоватьКомпромисс
GitHub MCPYou want remote history (PRs, review comments, Actions) not just localNeeds a PAT and makes network calls; more powerful but more surface area
filesystem MCP + shellYou need operations beyond git (grep, find, build commands)Much broader blast radius — stick with git MCP if git is all you need

Ещё

Ресурсы

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

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

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