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.
claude_desktop_config.json{
"mcpServers": {
"git": {
"command": "uvx",
"args": [
"mcp-server-git",
"--repository",
"."
]
}
}
}Generate & Test Git MCP Server Config
One-click export with environment variables & path locators for Claude Desktop, Cursor, Windsurf, and OpenAI Codex CLI.
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).
Protocol Mechanics and Operational Safety
- ▸Explicit Repository Scoping: The server requires explicit
--repositorypath arguments at launch. The agent cannot navigate outside of registered repositories to run arbitrary Git commands across your filesystem. - ▸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.
- ▸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:
| Component | Minimum Version | Installation Verification | Purpose |
|---|---|---|---|
| Python | >= 3.10 | python3 --version | Runtime environment for the server |
| uv / uvx | >= 0.4.0 | uv --version | High-speed Python package runner |
| Git | >= 2.38.0 | git --version | Core version control binary |
| mcp-server-git | Latest release | PyPI Registry | Official Model Context Protocol Git server |
Verify that your repository is cleanly initialized:
git status3. 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
{
"mcpServers": {
"git": {
"command": "uvx",
"args": [
"mcp-server-git",
"--repository",
"/Users/developer/projects/webapp"
]
}
}
}To expose multiple repositories simultaneously, repeat the --repository argument:
{
"mcpServers": {
"git": {
"command": "uvx",
"args": [
"mcp-server-git",
"--repository", "/Users/developer/projects/frontend",
"--repository", "/Users/developer/projects/backend"
]
}
}
}Cursor IDE Configuration (.cursor/mcp.json)
{
"mcpServers": {
"git": {
"command": "uvx",
"args": ["mcp-server-git", "--repository", "./"]
}
}
}OpenAI Codex CLI Configuration (~/.codex/config.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 Name | Parameters | Description |
|---|---|---|
git_status | repo_path | Returns working tree state, tracking staged, unstaged, and untracked files |
git_diff_unstaged | repo_path | Generates a unified diff of modified files not yet added to the index |
git_diff_staged | repo_path | Generates a unified diff of staged modifications prepared for commit |
git_add | repo_path, files | Stages specified file paths into the Git index |
git_reset | repo_path, files | Unstages files from the index without discarding working tree modifications |
git_commit | repo_path, message | Creates a commit with the specified commit message |
git_log | repo_path, max_count | Retrieves recent commit history, including hashes, authors, and messages |
git_create_branch | repo_path, branch_name | Creates a new branch from the current HEAD |
git_checkout | repo_path, branch_name | Switches 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)
{
"jsonrpc": "2.0",
"id": "git-cmd-01",
"method": "tools/call",
"params": {
"name": "git_status",
"arguments": {
"repo_path": "/Users/developer/projects/webapp"
}
}
}Result Payload
{
"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
{
"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
--repositoryorrepo_pathdoes not contain an initialized.gitdirectory. - ▸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.lockfile. - ▸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_checkoutto 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:
- ▸Prevent Automated Pushing: Do not expose automated
git pushtools without explicit developer confirmation to prevent pushing broken or unreviewed code to shared team branches. - ▸Review Commit Content: Before allowing an agent to create commits, inspect the diffs to ensure no sensitive credentials (
.env, private API keys) are accidentally staged. - ▸Official Standards and Repositories:
Weekly Protocol Diffs & Verified Drops
New server guides, benchmarks, and security audits. No spam. Unsubscribe anytime.
Zero marketing spam. 1-click unsubscribe anytime.
Build your full agent toolstack in the Visual Generator
Combine Git with databases, search APIs, and memory graphs in a single configuration file.
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.
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.
Related Guides
OpenCode Free AI Agent Guide
Guide to running OpenCode coding agent completely free without API keys using Zen free tier, local LLMs, and OAuth accounts.
Dev ToolsSelf-Correcting Verification Loops in Agents
Build robust self-correcting /loop verification harnesses for AI agents using Test-Driven Agent Development, dual-agent critics, and MCP test sandboxes.
Dev ToolsAutomated Doc Verification Loops with Claude CLI
Build automated documentation verification loops with Claude CLI and MCP. Validate code snippets, test tool schemas, and sync SDK docs in CI/CD. Verified.