MCP server, by Model Context Protocol
mcp-server-git
Python MCP server that exposes a fixed set of Git operations on a local repository.
Quick facts
What it does
mcp-server-git is a Python MCP server for Git repository interaction and automation. It wraps twelve Git operations in typed tools: reading (status, diffs, log, show, branch listing) and changing (add, commit, reset, branch creation, checkout). It runs with uvx, pip, or Docker over stdio. The README says it is in early development and its functionality and tools are subject to change, and that it requires MCP Python SDK 2.x (mcp>=2.3,<3).
The reading tools are git_status, git_diff_unstaged and git_diff_staged (each with an optional context_lines, default 3), git_diff (a required target branch or commit to compare with), git_log, git_show and git_branch. git_log takes max_count (default 10) and optional start_timestamp and end_timestamp, which accept ISO 8601, relative dates such as 2 weeks ago, or absolute dates, and returns entries with hash, author, date and message. git_show takes a revision or object spec such as HEAD:path/to/file and returns a commit, file content, or directory listing. git_branch takes branch_type (local, remote or all) and optional contains and not_contains commit shas.
The changing tools are git_add, git_commit, git_reset, git_create_branch and git_checkout. git_add takes a non-empty files array, and ["."] stages everything. git_commit takes a message and returns the new commit hash, or an error if nothing is staged, except while a merge is in progress, where it concludes the merge with HEAD and every MERGE_HEAD as parents. git_reset unstages all staged changes. git_create_branch takes branch_name and an optional base_branch, tag or sha, defaulting to the current branch or the current commit when HEAD is detached. git_checkout reports HEAD is now detached when the name is a sha, tag or other revision.
Every tool takes a repo_path argument. The README says that without --repository the server reads and writes any Git repository the server process can reach, including through the tools that change a repository. The --repository argument (short form -r) is the only confinement offered, and the server never asks the client for Roots in either protocol era. The argument accepts any path inside a Git working tree and walks up to the repository root, so a subdirectory path allows tool calls anywhere in that repository. Each repo_path must then be inside that repository, as must the directories Git uses for it, and a nested repository whose .git file, commondir or core.worktree points outside is refused.
Errors are readable by the model. A failing tool returns isError with text beginning Error executing tool and the tool name, covering Git errors such as an unknown revision, a repo_path that is not a repository or is outside --repository, the flag-injection guards, and arguments that do not match the schema. An unknown tool name is a JSON-RPC -32602 error; the README notes that before 2.0.0 it was an isError result. The server speaks the 2026-07-28 and 2025-11-25 protocol eras over stdio without configuration.
Configuration
Run with uvx mcp-server-git and optionally pass --repository path/to/git/repo, or install with pip install mcp-server-git.
{
"mcpServers": {
"git": {
"command": "uvx",
"args": ["mcp-server-git", "--repository", "path/to/git/repo"]
}
}
}Source: https://github.com/modelcontextprotocol/servers/tree/main/src/git. Placeholders only. Replace them in your own environment, and never commit real keys to a repository.
The official documentation lists no required environment variables.
Tools and features on record
git_status Config checked
Shows the working tree status as text. Argument: repo_path.
git_diff_unstaged and git_diff_staged Config checked
Show unstaged or staged changes. Arguments: repo_path and optional context_lines (default 3).
git_diff Config checked
Compares the current state with a branch or commit. Arguments: repo_path, target, optional context_lines.
git_log Config checked
Lists commits with hash, author, date and message. Arguments: repo_path, max_count (default 10), start_timestamp and end_timestamp as ISO 8601, relative or absolute dates.
git_show Config checked
Shows a commit, or a file or directory at a revision such as HEAD:path/to/file. Arguments: repo_path and revision.
git_branch Config checked
Lists branches. Arguments: repo_path, branch_type (local, remote or all), optional contains and not_contains commit shas.
git_add and git_commit Config checked
git_add stages a non-empty files array (["."] stages everything). git_commit records a commit from a message, errors when nothing is staged, and concludes an in-progress merge.
git_reset Config checked
Unstages all staged changes for the repository at repo_path.
git_create_branch and git_checkout Config checked
Create a branch from an optional base branch, tag or sha, and switch to a branch, or detach HEAD when the name is a sha, tag or other revision.
--repository confinement Config checked
Restricts every repo_path to one repository (any path inside its working tree is accepted and resolved to the root). Without it, any repository the process can reach is in scope.
Security notes
- Without --repository the server reads and writes any Git repository the server process can reach, because each call names its own repo_path. The README calls --repository the only confinement the server offers, so set it whenever the server runs with write tools in an environment you care about.
- A path inside the repository allows tool calls anywhere in that repository, not only under the subdirectory you gave. Scope by repository, not by folder.
- The changing tools are git_add, git_commit, git_reset, git_create_branch and git_checkout. A model can stage everything with files set to ["."], commit it, unstage with git_reset, and switch branches, so enable the server only where those changes are acceptable and review commits before they leave your machine.
- git_checkout changes the working tree. Uncommitted work in a repository the model switches branches on is a risk to plan for before connecting.
- None of the twelve tools is a push, pull or fetch operation, and no credentials are named, so the tools do not send commits to a remote. Reading tools can still return file contents and history, including anything committed earlier such as secrets, back into the model context.
- Nested repositories whose .git file, commondir or core.worktree points outside the allowed repository are refused, and the README documents flag-injection guards. Arguments that do not match the schema return an error result.
- The README states the server is in early development, so pin the package version and re-check the tool list after upgrades.
An MCP server runs with the permissions of the process you start it from. Scope credentials to the narrowest access the job needs, and review what the client will send before connecting anything sensitive.
Stacks featuring this server
Browser QA Stack
Reference workflow for browser regression work: Playwright runs deterministic checks, the Playwright MCP server supports agent-led failure investigation with artifacts.
Coding Assistant Stack
Reference workflow for scoped coding assistance: Filesystem and Git provide repository access, Context7 supplies current library documentation, Sequential Thinking structures multi-step analysis.
Sources and freshness
- Official source: https://github.com/modelcontextprotocol/servers/tree/main/src/git
- Repository: https://github.com/modelcontextprotocol/servers
Checked 2026-11-03. Config-checked means the configuration and feature list trace to the official source above; it does not mean AgentsUse ran the server. Send corrections through the contact page. Back to the MCP server index.