Dev Tools·
intermediate
·14 min read·Apr 4, 2026·Updated Oct 10, 2026
By Rad Tome·Lead AI Systems Architect·How we verify this

Git MCP Server Configuration Guide

Configure the official Git MCP server for Claude Desktop, Cursor, and Codex CLI: Automated branch management, staging, commits, and diff inspection.

gitversion-controlcommitsbranchesdiffworkflowmcpdeveloper-tools
Config Target: claude_desktop_config.json
{
  "mcpServers": {
    "git": {
      "command": "uvx",
      "args": [
        "mcp-server-git",
        "--repository",
        "."
      ]
    }
  }
}
Interactive Tool
1-Click Export

Generate & Test Git MCP Server Config

One-click export with environment variables & path locators for Claude Desktop, Cursor, Windsurf, and OpenAI Codex CLI.

Open in Generator

Git MCP Server Configuration Guide

Integrating version control directly into large language model development workflows eliminates friction across modern software engineering cycles. Instead of constantly context-switching between chat windows and terminal shells to stage changed files, draft descriptive conventional commit messages, and inspect diffs, developers can empower AI assistants in Claude Desktop, Cursor, or OpenAI Codex CLI to manage local repository lifecycles directly via the Model Context Protocol (MCP).

The official Git MCP server wraps local Git operations inside structured JSON-RPC 2.0 tools. Through this interface, an agent can inspect modified working trees, branch off from main, apply commits, and trace recent commit histories while respecting repository boundaries.

This guide provides an operational breakdown of the Git MCP server, including multi-client configuration blocks, tool schema references, JSON-RPC wire frames, and failure mitigation strategies.


1. System Architecture: Scoped Repository Operations

The Git MCP server is authored in Python and distributed via PyPI as mcp-server-git. When launched by an AI host application, it executes as a child process communicating over Standard Input and Output (stdio).

diagram

Repository Sandboxing

Outside Scope

Valid Repository

AI Host: Claude Desktop / Cursor / Codex CLI

stdio JSON-RPC Transport

Git MCP Server Process: mcp-server-git

Target Path == Registered Repo?

-32004 Access Denied

Git Core Process Engine

.git Directory & Working Tree

Protocol Mechanics and Operational Safety

  1. ▸Explicit Repository Scoping: The server requires explicit --repository path arguments at launch. The agent cannot navigate outside of registered repositories to run arbitrary Git commands across your filesystem.
  2. ▸Deterministic Diff Chunking: Sprawling diffs across thousands of lines can overflow model context windows. The Git MCP server isolates staged from unstaged changes and allows path filtering to constrain payload token costs.
  3. ▸Local-Only Boundary: The Git MCP server focuses strictly on local repository manipulation (git status, git diff, git commit, git checkout). Remote operations requiring network credentials (git push, git fetch) are segregated to prevent unintentional deployment triggers.

2. Environment Prerequisites and Software Matrix

Ensure your development environment meets the following software requirements:

ComponentMinimum VersionInstallation VerificationPurpose
Python>= 3.10python3 --versionRuntime environment for the server
uv / uvx>= 0.4.0uv --versionHigh-speed Python package runner
Git>= 2.38.0git --versionCore version control binary
mcp-server-gitLatest releasePyPI RegistryOfficial Model Context Protocol Git server

Verify that your repository is cleanly initialized:

bash
git status

3. Multi-Host Configuration Snippets

Configure your MCP clients to launch mcp-server-git via uvx. Ensure you provide absolute paths to your local repositories.

Claude Desktop Configuration (claude_desktop_config.json)

On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%\Claude\claude_desktop_config.json

json
{
  "mcpServers": {
    "git": {
      "command": "uvx",
      "args": [
        "mcp-server-git",
        "--repository",
        "/Users/developer/projects/webapp"
      ]
    }
  }
}

To expose multiple repositories simultaneously, repeat the --repository argument:

json
{
  "mcpServers": {
    "git": {
      "command": "uvx",
      "args": [
        "mcp-server-git",
        "--repository", "/Users/developer/projects/frontend",
        "--repository", "/Users/developer/projects/backend"
      ]
    }
  }
}

Cursor IDE Configuration (.cursor/mcp.json)

json
{
  "mcpServers": {
    "git": {
      "command": "uvx",
      "args": ["mcp-server-git", "--repository", "./"]
    }
  }
}

OpenAI Codex CLI Configuration (~/.codex/config.toml)

toml
[mcp_servers.git]
command = "uvx"
args = ["mcp-server-git", "--repository", "/home/developer/projects/webapp"]

4. Exposed Tools and Capability Reference

The Git MCP server provides tools mapping directly to standard developer workflows:

Tool NameParametersDescription
git_statusrepo_pathReturns working tree state, tracking staged, unstaged, and untracked files
git_diff_unstagedrepo_pathGenerates a unified diff of modified files not yet added to the index
git_diff_stagedrepo_pathGenerates a unified diff of staged modifications prepared for commit
git_addrepo_path, filesStages specified file paths into the Git index
git_resetrepo_path, filesUnstages files from the index without discarding working tree modifications
git_commitrepo_path, messageCreates a commit with the specified commit message
git_logrepo_path, max_countRetrieves recent commit history, including hashes, authors, and messages
git_create_branchrepo_path, branch_nameCreates a new branch from the current HEAD
git_checkoutrepo_path, branch_nameSwitches the active branch or checks out a specific commit reference

5. JSON-RPC 2.0 Wire Payloads

Understanding the protocol message structure simplifies debugging when testing with the MCP Inspector or reviewing host logs.

Tool Call: Checking Working Tree Status (tools/call)

json
{
  "jsonrpc": "2.0",
  "id": "git-cmd-01",
  "method": "tools/call",
  "params": {
    "name": "git_status",
    "arguments": {
      "repo_path": "/Users/developer/projects/webapp"
    }
  }
}

Result Payload

json
{
  "jsonrpc": "2.0",
  "id": "git-cmd-01",
  "result": {
    "content": [
      {
        "type": "text",
        "text": "On branch main\nChanges not staged for commit:\n  modified:   src/auth.ts\n\nUntracked files:\n  tests/auth.test.ts"
      }
    ]
  }
}

Tool Call: Creating a Conventional Commit

json
{
  "jsonrpc": "2.0",
  "id": "git-cmd-02",
  "method": "tools/call",
  "params": {
    "name": "git_commit",
    "arguments": {
      "repo_path": "/Users/developer/projects/webapp",
      "message": "feat(auth): add OAuth2 token refresh interceptor"
    }
  }
}

6. Common Errors and Production Troubleshooting

When operating the Git MCP server in automated coding pipelines, monitor for these failure conditions:

Error: fatal: not a git repository

  • ▸Root Cause: The directory path passed in --repository or repo_path does not contain an initialized .git directory.
  • ▸Resolution: Ensure the path points to the root of the Git project, not a nested subdirectory or an uninitialized folder.

Error: fatal: index.lock: File exists

  • ▸Root Cause: Another Git process (such as an IDE background file watcher or previous crashed command) left an uncleaned .git/index.lock file.
  • ▸Resolution: Verify no background Git processes are running, then remove the lock file: rm .git/index.lock.

Error: Uncommitted Changes Blocking Branch Switching

  • ▸Root Cause: The agent attempts git_checkout to switch branches while local files contain unstaged edits that would be overwritten.
  • ▸Resolution: Instruct the agent to commit current changes, stage them, or stash modifications prior to switching branches.

7. External Citations and Security Guardrails

Running version control tools via language models requires adherence to core safety guidelines:

Technical Changelog

Weekly Protocol Diffs & Verified Drops

New server guides, benchmarks, and security audits. No spam. Unsubscribe anytime.

Zero marketing spam. 1-click unsubscribe anytime.

Ready to Deploy?

Build your full agent toolstack in the Visual Generator

Combine Git with databases, search APIs, and memory graphs in a single configuration file.

Customize in Generator
Developer Verification & Feedback
0 reports

Did this setup guide work with your AI host?

Help test this configuration across Claude, Cursor, and Codex CLI. Be the first to report:

Git MCP Server Configuration Guide FAQ

What is the Git MCP Server Configuration Guide?

Configure the official Git MCP server for Claude Desktop, Cursor, and Codex CLI: Automated branch management, staging, commits, and diff inspection.

How do I configure Git MCP Server Configuration Guide in Claude Desktop or Cursor?

You can copy the configuration JSON from our guide or launch the interactive MCP Codex Config Generator at https://mcp-codex.com/generator to export valid configs in 1 click.

Can I use Git MCP Server Configuration Guide with the OpenAI Codex CLI?

Yes, OpenAI Codex CLI supports Model Context Protocol. You can add it directly to ~/.codex/config.toml or pass arguments to codex mcp add.

RT

Written by Rad Tome

Lead AI Systems Architect & Maintainer, MCP Codex

@RadTome

Specializing in Model Context Protocol (MCP) integrations, autonomous AI agent orchestration, and distributed developer toolchains. Researches and benchmarks production MCP client-server architectures across OpenAI Codex, Claude, and Cursor.

Editorial Integrity: Package names are checked against the npm registry and repositories against the GitHub API. Where a package could not be verified, the guide says so instead of giving you a command to run.

Related Guides