# Git MCP server security: what mcp-server-git can reach

> What the Git MCP server can read and change, why --repository matters, and how to limit its tools in Claude Code and Codex with exact rules and keys.

The Git MCP server, `mcp-server-git`, lives in the `modelcontextprotocol/servers` repository and runs locally on your Mac. It has 14 tools, including `git_commit`, `git_reset`, `git_checkout` and `git_merge`, and it lists no push tool. Start it with `--repository` so it stays inside one repo. Without that flag, the README says it “reads and writes any Git repository the server process can reach.”

## Who maintains it and how it runs

The server sits in the [modelcontextprotocol/servers](https://github.com/modelcontextprotocol/servers/tree/main/src/git) repository. Its README says it is “currently in early development,” so tools and behavior may change. The page does not say whether the server is archived or part of a reference set, and this guide does not either.

It is a local process with no sign-in of its own. The recommended install is `uvx mcp-server-git`, or `pip install mcp-server-git` followed by `python -m mcp_server_git`. A streamable HTTP mode exists with `--transport streamable-http`, listening on `127.0.0.1:3001` by default. Setting `HOST=0.0.0.0` exposes that endpoint to other machines, so do it deliberately.

## What the tools can do

| Group | Tools |
| --- | --- |
| Read | `git_status`, `git_diff_unstaged`, `git_diff_staged`, `git_diff`, `git_log`, `git_show`, `git_branch`, `git_remote` |
| Write | `git_add`, `git_reset`, `git_commit`, `git_create_branch`, `git_checkout`, `git_merge` |

The README lists no `git_push` and no fetch tool, and no tool that deletes a branch. Local history is still at risk. `git_reset` can discard staged work, `git_checkout` can switch away from uncommitted changes in some states, and `git_merge` changes the branch. Commit identity comes from `GIT_AUTHOR_*` and `GIT_COMMITTER_*` variables, then Git config.

## Risks

- **Reach.** Each tool call names its own `repo_path`. With no `--repository`, the agent can point the server at any repo your user can open.
- **Untrusted content.** Commit messages, diffs and file contents in a cloned repo are text the model reads. The README says to set `--repository` when prompts or content are not fully trusted.
- **Repo-defined programs.** The README says the server does not run programs a repository defines in its config or hooks. It also disables hooks, external diff and textconv, filter and merge drivers, and automatic GC.
- **Other routes.** The same agent can still run `git push` through a shell tool. This server’s tool list does not control that.

## Limit it in Claude Code

Add it with a fixed repository.

```bash
claude mcp add git -- uvx mcp-server-git --repository /Users/you/code/project
```

Then control the write tools by name.

```json
{
  "permissions": {
    "ask": ["mcp__git__git_commit", "mcp__git__git_merge"],
    "deny": ["mcp__git__git_reset"]
  }
}
```

The `git` part is the name you gave the server. Use local scope, the default, so the path to one project stays out of shared config.

## Limit it in Codex

```toml
[mcp_servers.git]
command = "uvx"
args = ["mcp-server-git", "--repository", "/Users/you/code/project"]
disabled_tools = ["git_reset", "git_merge"]
default_tools_approval_mode = "prompt"
```

The README has no Codex snippet, so this follows the Codex config keys for stdio servers. `codex mcp list` shows the result.

## Checklist

1. Always pass `--repository`.
2. Deny `git_reset` and ask before `git_commit` and `git_merge`.
3. Keep the HTTP mode on `127.0.0.1` unless you need otherwise.
4. Pin the package version where you can, instead of taking whatever `uvx` fetches next.
5. Protect shared branches at the Git host. See [Git protection](https://www.excellent.so/docs/git).
6. If history changed, read [what to do after a force push](https://www.excellent.so/guides/ai-agent-force-pushed-main).
7. For the GitHub side of the work, see the [GitHub MCP server guide](https://www.excellent.so/guides/github-mcp-server). The general rules are in the [MCP security hub](https://www.excellent.so/guides/mcp-server-security).

Checked against the vendor documentation on November 25, 2026. [mcp-server-git](https://github.com/modelcontextprotocol/servers/tree/main/src/git) · [Claude Code permissions](https://code.claude.com/docs/en/permissions) · [Codex MCP](https://developers.openai.com/codex/mcp)

## What Excellent covers

Excellent does not inspect MCP servers themselves. Its free scan reads supported logs on the Mac and reports findings for review. It reads the session logs of Claude Code, Codex, Grok Build, GitHub Copilot CLI, Gemini CLI and Qwen Code, so it can show what an agent did after it called a tool. It does not read Cursor’s, OpenClaw’s or Claude Cowork’s logs. For a local report without installing an app, [run the free scan](https://www.excellent.so/scan). Its script uses Python 3.9 or later when your Mac has it and the shell when it doesn’t, reads the logs locally and makes no network requests. [See a sample report](https://www.excellent.so/r/sample).

Excellent Pro adds checks before supported actions. Claude Code can display an ask prompt. With Codex, an Excellent “ask” refuses the action and tells the agent to ask you. Commands sent into an already running Codex shell fall outside that check. [Agent coverage](https://www.excellent.so/agents) · [Pricing](https://www.excellent.so/pricing). Pro is US-only for now.

Source: https://www.excellent.so/guides/git-mcp-server
