/ Diretório / Playground / Git
● Oficial modelcontextprotocol ⚡ Instantâneo

Git

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

Por que usar

Principais recursos

Demo ao vivo

Como fica na prática

git.replay ▶ pronto
0/0

Instalar

Escolha seu cliente

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

Abra Claude Desktop → Settings → Developer → Edit Config. Reinicie após salvar.

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

Cursor usa o mesmo esquema mcpServers que o Claude Desktop. Config de projeto vence a global.

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

Clique no ícone MCP Servers na barra lateral do Cline, depois "Edit Configuration".

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

Mesmo formato do Claude Desktop. Reinicie o Windsurf para aplicar.

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

O Continue usa um array de objetos de servidor em vez de um map.

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

Adicione em context_servers. Zed recarrega automaticamente ao salvar.

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

Uma linha só. Verifique com claude mcp list. Remova com claude mcp remove.

Casos de uso

Usos do mundo real: Git

Have an agent review your staged changes before you commit

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

Quando usar: About to commit. Want a second pair of eyes to catch obvious smell before the commit lands.

Pré-requisitos
  • Local repo with staged changesgit add -p as usual, then ask the agent
Fluxo
  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>'.✓ Copiado
    → 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.✓ Copiado
    → Copy-pasteable message
  3. Confirm scope
    Based on the diff, is this commit appropriately small? Suggest splits if it touches multiple concerns.✓ Copiado
    → Go/no-go with rationale

Resultado: A cleaner commit with fewer 'oops' follow-ups.

Armadilhas
  • 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
Combine com: github

Find when and why a specific line broke

👤 Engineers debugging regressions ⏱ ~15 min intermediate

Quando usar: A test started failing and you need to know which commit introduced the bug.

Fluxo
  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.✓ Copiado
    → 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.✓ Copiado
    → 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.✓ Copiado
    → Specific SHA + line with rationale

Resultado: A precise commit-level hypothesis you can confirm with git revert + re-run tests.

Armadilhas
  • 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
Combine com: github

List and categorize stale local branches

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

Quando usar: Quarterly cleanup — too many branches, unclear which are safe to delete.

Fluxo
  1. List all local branches
    List every local branch with its last commit date and message.✓ Copiado
    → 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.✓ Copiado
    → 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.✓ Copiado
    → Copy-pasteable cleanup commands

Resultado: A pruned branch list with confidence you're not dropping work.

Armadilhas
  • 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

Combinações

Combine com outros MCPs para 10× de alavancagem

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.✓ Copiado

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.✓ Copiado

Ferramentas

O que este MCP expõe

FerramentaEntradasQuando chamarCusto
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

Custo e limites

O que custa rodar

Cota de API
None — all local
Tokens por chamada
200–5000 per diff depending on size
Monetário
Free
Dica
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.

Segurança

Permissões, segredos, alcance

Armazenamento de credenciais: None — no credentials
Saída de dados: None — server is 100% local, no network calls

Solução de problemas

Erros comuns e correções

fatal: not a git repository

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

Verificar: 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.

Verificar: 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.

Alternativas

Git vs. outros

AlternativaQuando usarTroca
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

Mais

Recursos

📖 Leia o README oficial no GitHub

🐙 Ver issues abertas

🔍 Ver todos os 400+ servidores MCP e Skills