Git MCP Server: Setup and Use With Coding Agents

Set up the official Git MCP server (mcp-server-git) in Claude Code, Codex or any MCP client, see all 14 tools it exposes, follow a real agent commit session, and lock it to one repository.

Ashley Innocent

Ashley Innocent

3 December 2026

Git MCP Server: Setup and Use With Coding Agents

Apidog for Enterprise

On-Premises Deploy

SSO & RBAC

SOC 2 Compliant

Explore Apidog Enterprise

The Git MCP server (mcp-server-git) gives your coding agent 14 typed Git tools: status, diffs, add, commit, log, branch, checkout, merge, show and remote. You run it with uvx mcp-server-git --repository <path>, register it in Claude Code, Codex or any MCP client, and the agent calls Git through structured tool calls instead of raw shell commands. It works on local repositories only: there’s no push, pull or fetch.

What is the Git MCP server?

The Git MCP server is the official Model Context Protocol server for Git, maintained in the modelcontextprotocol/servers repository and published on PyPI as mcp-server-git. It exposes local Git operations as typed tools that any MCP client can call, with repo_path arguments and readable text results.

The latest PyPI release is 2026.11.27, built on the MCP Python SDK 2.x. If MCP itself is new to you, start with our Model Context Protocol explainer.

Here’s where it sits between your agent and your code:

Schema: a coding agent calls the Git MCP server over stdio or Streamable HTTP; with --repository it can only reach one local repository, and it has no route to a remote

The key detail is the boundary. With --repository, every tool call must land inside that one repository. Without it, the server can read and write any repository its process can reach.

Git MCP server vs GitHub MCP server

They solve different problems, and many teams run both.

Git MCP server GitHub MCP server
Works on Local repositories on disk GitHub’s hosted API
Typical tools status, diff, commit, branch, merge issues, pull requests, Actions, code search
Auth None (local file access) GitHub token or OAuth
Network Not needed Required
Push and pull No Not a Git transport either
Package mcp-server-git (Python) GitHub’s own server

Use the Git MCP server when the agent works on your checkout: reviewing a diff, staging files, writing commits, switching branches. Use the GitHub MCP server when it needs to open a pull request or triage issues. For more options, see our list of MCP servers for Git tools.

Tools the Git MCP server exposes

These are the 14 tools the server registered in our Claude Code session, matching the official README:

Tool What it does Changes the repo?
git_status Working tree status No
git_diff_unstaged Unstaged changes, context_lines optional No
git_diff_staged Staged changes No
git_diff Diff against a branch, commit or a..b / a...b range No
git_log Commit history, max_count, date filters No
git_show A commit, or a file at a revision (HEAD:path) No
git_branch List local, remote or all branches No
git_remote Remotes with credentials redacted No
git_add Stage files, ["."] stages everything Yes
git_reset Unstage all staged changes Yes
git_commit Commit staged changes with a message Yes
git_create_branch New branch from a branch, tag or SHA Yes
git_checkout Switch branches (or detach at a revision) Yes
git_merge Merge into the current branch, fast-forward only by default Yes

The server also ships two prompts, which clients usually show as slash commands: git_commit_message (drafts a message from the staged diff) and git_summarize_changes (summarizes the working tree or a diff against a target).

A few behaviors are worth knowing before you hand it to an agent:

How to set up the Git MCP server

You need uv (for uvx) and Git 2.31 or later. Then pick your client.

  1. Check the server runs. uvx downloads it on first use:
uvx mcp-server-git --help

You should see three options: -r, --repository, -v, --verbose and --transport [stdio|streamable-http].

  1. Add it to Claude Code. From the repository root:
claude mcp add git -s project -- uvx mcp-server-git --repository "$(pwd)"

-s project writes the entry to .mcp.json, so teammates get the same server when they open the repo. Drop it to keep the server local to you.

  1. Or add it to Codex.
codex mcp add git -- uvx mcp-server-git --repository /path/to/your/repo
  1. Or use a JSON config (Claude Desktop, Cursor, Zed and most other clients). Set the commit identity in env, because git_commit reads it the same way git commit does:
{
  "mcpServers": {
    "git": {
      "command": "uvx",
      "args": ["mcp-server-git", "--repository", "/path/to/your/repo"],
      "env": {
        "GIT_AUTHOR_NAME": "Your Name",
        "GIT_AUTHOR_EMAIL": "you@example.com",
        "GIT_COMMITTER_NAME": "Your Name",
        "GIT_COMMITTER_EMAIL": "you@example.com"
      }
    }
  }
}

A local install usually finds your ~/.gitconfig, so env is optional there. In Docker it’s required: the mcp/git image has no gitconfig and would record commits as something like app <app@3f2a1b9c8d7e>.

  1. Optional: run it over HTTP. For a shared or remote setup:
uvx mcp-server-git --transport streamable-http --repository /path/to/your/repo

It listens on 127.0.0.1:3001 and serves one endpoint, /mcp. Point your client at http://127.0.0.1:3001/mcp. Leave HOST alone unless you mean it: HOST=0.0.0.0 exposes the server to every machine that can reach yours.

Debug a misbehaving tool with npx @modelcontextprotocol/inspector uvx mcp-server-git.

A real agent session with the Git MCP server

We made a throwaway repository with one commit on main, then a feature/subtract branch with a modified calc.py and a new, untracked README.md. Then we ran Claude Code headless with only the Git MCP server allowed:

claude -p "Use the git MCP server tools only (repo_path /tmp/gitmcp-demo). Check status and the unstaged diff, stage both files, write a conventional commit message, commit, then show the last 2 log entries." \
  --mcp-config gitmcp.json --strict-mcp-config --allowedTools "mcp__git__*"

Here’s the order of calls the agent actually made:

Sequence: Claude Code calls git_status, git_diff_unstaged, git_add, git_diff_staged, git_commit and git_log on the Git MCP server, which runs each against the demo repository

The transcript, trimmed to the tool calls:

mcp__git__git_status        {"repo_path": "/tmp/gitmcp-demo"}
mcp__git__git_diff_unstaged {"repo_path": "/tmp/gitmcp-demo"}
mcp__git__git_add           {"repo_path": "/tmp/gitmcp-demo", "files": ["calc.py", "README.md"]}
mcp__git__git_diff_staged   {"repo_path": "/tmp/gitmcp-demo"}
mcp__git__git_commit        {"repo_path": "/tmp/gitmcp-demo", "message": "feat(calc): add subtract function and README"}
mcp__git__git_log           {"repo_path": "/tmp/gitmcp-demo", "max_count": 2}

Two things stood out. First, the agent called git_diff_staged after staging, without being asked. git_diff_unstaged doesn’t show untracked files, so the new README only became visible once it was staged. That’s a good habit to put in your own prompts: stage, read the staged diff, then write the message.

Second, every call was typed. The agent never built a shell string, so there’s no quoting bug, and the server rejects a git_diff target that starts with -.

Lock the Git MCP server to one repository

The README’s warning is blunt: without --repository, the server reads and writes any repository the process can reach, including commits and merges. Always pass it when prompts or content aren’t fully trusted. If you’re weighing the wider risks of tool access, our post on MCP security policies goes deeper.

What the server already does for you, per the official docs:

What it doesn’t do: limit which tools the agent calls. If you want a read-only reviewer, allow only the read tools in your client, for example --allowedTools "mcp__git__git_status,mcp__git__git_diff,mcp__git__git_log,mcp__git__git_show" in Claude Code.

Let your agent test the API change with Apidog CLI

When the commit touches an API (an openapi.yaml, a new route), a clean diff isn’t proof it works. Your agent already has the Git MCP server to read what changed. Give it Apidog CLI too, and it can load the new spec into an isolated branch and run your tests before anyone merges.

Install the CLI and the agent skill once:

npm install -g apidog-cli@latest
apidog login --with-token <YOUR_TOKEN>
npx -y skills add https://apidog.com   # pick your agent when prompted

Then give your agent one prompt:

Use the git MCP server to show what changed in openapi.yaml on this branch versus main.
Then create an Apidog AI branch from main in project <projectId>, import the spec into it,
list the endpoints, and run the "Object CRUD lifecycle" scenario against the test environment.
Summarize any failures. Don't merge the AI branch.

The agent calls git_diff with target: "main", then runs:

apidog branch create --project <projectId> --type ai --name "ai/20261201-from-main-objects" --from main
apidog import --project <projectId> --branch ai/20261201-from-main-objects --format openapi --file ./openapi.yaml --module-map "<info.title>=default"
apidog endpoint list --project <projectId> --branch ai/20261201-from-main-objects
apidog run -t <scenarioId> --project <projectId> --branch ai/20261201-from-main-objects -e <envId> -r cli,junit

The --module-map flag matters: Apidog names an imported module after the spec’s info.title, so mapping it updates endpoints in place instead of creating duplicates. AI branch changes are never written back on their own; your agent should ask you before it merges.

Apidog CLI on a sandbox project: an OpenAPI import into an AI branch, the endpoint list, and the Object CRUD lifecycle scenario passing 7 of 7 assertions

The same apidog run ... -r junit line drops straight into CI; see Apidog CLI in a CI/CD pipeline. For agent-specific setup, read Apidog CLI in Claude Code or in Codex.

Once a team has several agents doing this on different branches, Sharkly lets you hand each run out as a task on a shared board, with the agents working on your own machines through Claude Code or Codex, so you can review what they shipped before it merges. It’s free to start.

Troubleshooting the Git MCP server

FAQ

Is the Git MCP server free? Yes. mcp-server-git is open source under the MIT license, and it runs locally with no account or API key.

Can the Git MCP server push to GitHub? No. Its 14 tools cover local operations only. There’s no git_push, git_pull or git_fetch.

Which clients support the Git MCP server? Any MCP client that can launch a stdio server or reach a Streamable HTTP endpoint. The official README documents Claude Desktop, VS Code, Zed and Zencoder; Claude Code and Codex add it with their mcp add commands.

Is it safe to give an agent commit access? Confine it with --repository, allow only the tools you need, and review commits before they leave your machine. The server already blocks hooks and repository-defined programs.

Explore more

How to Access GPT-6.2 Cyber: API, Codex and Amazon Bedrock

How to Access GPT-6.2 Cyber: API, Codex and Amazon Bedrock

GPT-6.2 Cyber is in early access through the OpenAI API, Codex and Amazon Bedrock, all gated by Daybreak Red. Here's how each route works and how to apply for OpenAI's $25M AWS cyber credits.

2 December 2026

Amazon Ergo Pricing: $1/$3 per Million Tokens and What a Task Costs

Amazon Ergo Pricing: $1/$3 per Million Tokens and What a Task Costs

Amazon Ergo costs $1 per million input tokens, $0.03 cached and $3 output on Bedrock's Global profile. Here's what a call, a cached agent session and a full coding task cost, and how it stacks up against Kimi K3.1 Pro and Claude.

2 December 2026

Amazon Ergo vs Claude Fable 5.2 vs GPT-6.2 Astra: Price, Benchmarks, Cost per Task

Amazon Ergo vs Claude Fable 5.2 vs GPT-6.2 Astra: Price, Benchmarks, Cost per Task

Amazon Ergo vs Claude Fable 5.2 and GPT-6.2 Astra: is the low-cost open model good enough? See where each one wins and what a task costs.

2 December 2026

Practice API Design-first in Apidog

Discover an easier way to build and use APIs

Git MCP Server: Setup and Use With Coding Agents