What Is mcp-server-git?
mcp-server-git is the official Model Context Protocol Git reference server. It lets an MCP client inspect repository status, read diffs, view logs, compare revisions, create branches, stage files, and create commits through Git-specific tools.
The important correction is packaging. Git is not published as the checked npm package @modelcontextprotocol/server-git. The official path is the Python package mcp-server-git, usually launched with uvx. That makes this page a setup correction guide, not a generic Git tutorial.
How to Calculate the Correct Git MCP Setup
Calculate the setup from four decisions: runner, client, repository scope, and write posture. Use uvx for the recommended package runner, use your MCP client's JSON shape, point --repository at one exact repository, and keep write-capable tools behind human review until the workflow is proven.
Runner
Use uvx first, pip fallback second, Docker when your team wants bind-mount boundaries.
Client
Claude Desktop and VS Code use different outer config keys but the same Git server command.
Repository
One repo path is the permission boundary. Avoid parent workspaces and home folders.
Write posture
Treat add, commit, reset, branch, and checkout as reviewed actions, not smoke tests.
Claude Desktop with uvx
{
"mcpServers": {
"git": {
"command": "uvx",
"args": ["mcp-server-git", "--repository", "/path/to/git/repo"]
}
}
}Use this for the normal official Git MCP route. Replace the repository path with one repo you are willing to expose.
VS Code MCP config
{
"servers": {
"git": {
"command": "uvx",
"args": ["mcp-server-git", "--repository", "${workspaceFolder}"]
}
}
}Use workspace scope only when sharing the MCP config is intentional. User-level config is safer for private experiments.
Docker alternative
{
"mcpServers": {
"git": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"--mount",
"type=bind,src=/Users/you/projects/my-repo,dst=/workspace",
"mcp/git"
]
}
}
}Use Docker when your team wants a stronger container boundary and explicit bind mounts around repository access.
Pip fallback
pip install mcp-server-git && python -m mcp_server_git --repository /path/to/git/repo
Use this when uvx is unavailable but Python and pip are managed on the machine.
MCP inspector debug command
npx @modelcontextprotocol/inspector uvx mcp-server-git --repository /path/to/git/repo
Use this when the client loads no tools and you need to debug the server outside the normal app.
Read-Only vs Write-Capable Git Tools
Git MCP is more sensitive than a simple package lookup page because several tools can change repository state. Start with status, diff, log, branch list, and show operations. Add stage, commit, reset, branch creation, and checkout only after the review path is explicit.
| Risk group | Tools | Use | Control |
|---|---|---|---|
| Read-first | git_status, git_diff_unstaged, git_diff_staged, git_diff, git_log, git_show, git_branch | Review repository state, inspect diffs, compare commits, and understand history. | Safe first smoke test, but still keep repository scope narrow. |
| Stage and commit | git_add, git_commit, git_reset | Change the index, create commits, or unstage work. | Require human diff review before staging or committing. |
| Branch movement | git_create_branch, git_checkout | Create or switch branches. | Confirm current branch and uncommitted work before branch actions. |
Worked Examples
Read-only repository review
Point Git MCP at a single low-risk repository and ask for git_status plus unstaged diff summary. The goal is to confirm tool visibility and repository scope before any write operation is possible.
Code review helper
Use Git MCP to compare a feature branch against main, summarize changed files, and list test gaps. Keep commit creation outside the assistant path until the review workflow is trusted.
Disposable write pilot
Create a throwaway repository, let the server stage and commit a small test file, then inspect the resulting log. Only promote write-capable usage after the team sees the exact behavior.
Common Errors and Fixes
npm returns E404 for @modelcontextprotocol/server-git.
Likely cause: Git is not published as that scoped npm package in the checked registry state.
Fix: Use uvx mcp-server-git or pip install mcp-server-git instead.
uvx is not found.
Likely cause: The uv toolchain is not installed or is not on the desktop client PATH.
Fix: Install uv, restart the client, or use the pip fallback with python -m mcp_server_git.
The client starts but no repository tools are visible.
Likely cause: The config file was not saved in the right place, or the MCP client was not fully restarted.
Fix: Save the config, quit the client completely, reopen it, and inspect the MCP tools list.
The server sees the wrong repository.
Likely cause: The --repository argument points to a parent folder, old checkout, or unresolved placeholder.
Fix: Replace the path with an absolute path to the exact repository and run git_status first.
A write action affected the wrong branch.
Likely cause: Branch state was not checked before git_add, git_commit, or git_checkout.
Fix: Make git_status and git_branch mandatory before write-capable prompts.