Git MCP Server
Published · Updated
At a glance
- Category
- Code & Git
- GitHub repository
- modelcontextprotocol/servers/tree/main/src/git
- Watch out for
- It works on local repositories only. git_remote can list configured remotes, but there is no push, pull or fetch tool, so publishing changes stays with you.
mcp-server-git is the Python reference server for working with local Git repositories, maintained in the official modelcontextprotocol/servers repository. It gives a model structured tools for status, diffs, staging, commits, branches, logs and merges, rather than leaving it to compose shell commands.
That structure is the main reason to use it. Each tool returns predictable output, errors come back as readable tool results the model can correct, and risky operations have guard rails. git_merge, for example, refuses to run with uncommitted changes or a detached HEAD, defaults to fast-forward only, and if a merge stops on conflicts it aborts the merge and names the conflicting files, leaving the repository as it was.
The server also ships two prompts that clients usually show as slash commands: one drafts a commit message from your staged changes and one summarises what has changed. If your agent already has a shell and you are happy for it to run git directly, you may not need this server. It earns its place in clients without a terminal, or when you want Git access without handing over a general-purpose shell.
How it connects
Your AI app
An assistant or agent that supports MCP
Git MCP Server
Runs as
- Python (uv / pip)
- Docker
Gives the agent
- Status and diffs
- Staging and committing
- History and inspection
- Branches and merges
- Commit message and summary prompts
Your Git repositories
The data or system the tools act on
What it can do
- Status and diffs
- git_status, git_diff_unstaged, git_diff_staged and git_diff (against a branch or commit) show the model exactly what has changed before it does anything.
- Staging and committing
- git_add, git_reset and git_commit cover the normal commit loop. The commit identity comes from GIT_AUTHOR_* and GIT_COMMITTER_* environment variables, or falls back to your Git config.
- History and inspection
- git_log lists commits and git_show displays a commit, or a file or directory as it was at any revision.
- Branches and merges
- git_branch lists branches with contains and not-contains filters, git_create_branch and git_checkout switch work, git_merge merges with the safety checks described above, and git_remote lists remotes with any embedded credentials redacted.
- Commit message and summary prompts
- git_commit_message and git_summarize_changes read the repository when invoked and return a ready prompt, so you get a draft based on the actual diff.
Setting it up
The recommended way to run it is with uv: uvx mcp-server-git --repository path/to/git/repo. You can also pip install mcp-server-git and run it as a module. Always pass --repository. The README warns in bold that without it the server reads and writes any Git repository the process can reach, because each tool call names its own repo_path. With it, every call must stay inside that repository. If commits come out with the wrong author, set GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL in the server's env block. In Docker, mount the repository and either pass those four variables or mount your .gitconfig read-only.
claude mcp add git -- uvx mcp-server-gitRuns the mcp-server-git package from PyPI. Add any API keys, environment variables or extra arguments the setup notes above list. Combine several servers in the MCP config generator
Where each client keeps its MCP config file, and the JSON it expects (cheat sheet)
Where it helps
- Drafting a commit message from staged changes in a client that has no terminal
- Asking what changed on a feature branch compared with main, in plain language
- Letting an assistant create a branch, commit its edits and fast-forward merge them
- Inspecting how a file looked at an older commit while debugging a regression
Limitations and things to watch
- It works on local repositories only. git_remote can list configured remotes, but there is no push, pull or fetch tool, so publishing changes stays with you.
- Without --repository the model can touch any repository your user can reach. Treat that flag as required.
- Merges default to fast-forward only; you must opt in to merge commits, and conflicts are aborted rather than resolved.
- Agents with shell access can already run git, so in those setups this server mainly adds safety, not new abilities.
Sources
Written from the project's own documentation, checked November 2026.
- github.com /modelcontextprotocol/servers/tree/main/src/git
- pypi.org /project/mcp-server-git
- raw.githubusercontent.com /modelcontextprotocol/servers/main/src/git/README.md
How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.