# Git MCP — Version Control Server for AI Agents > MCP server that gives AI agents full Git capabilities. Git MCP enables Claude Code and Cursor to manage repositories, branches, commits, diffs, and history via tool calls. ## Install Merge the JSON below into your `.mcp.json`: ## Quick Use ```json // claude_desktop_config.json or .cursor/mcp.json { "mcpServers": { "git": { "command": "uvx", "args": ["mcp-server-git", "--repository", "/path/to/repo"] } } } ``` ```bash # Or install directly pip install mcp-server-git mcp-server-git --repository /path/to/repo ``` Now ask your AI agent: ``` "Show me the git log for the last week" "What changed in the last 3 commits?" "Create a branch called feature/auth and commit the staged changes" ``` ## What is Git MCP? Git MCP is a Model Context Protocol server that gives AI agents structured access to Git repositories. Instead of running raw shell commands, agents use typed tools for git operations — log, diff, status, branch, commit, and more. It provides clean, parseable output that agents can reason about effectively. **Answer-Ready**: Git MCP is an MCP server for AI agent Git access. Provides typed tools for log, diff, status, branch, commit, and blame operations. Clean structured output for agent reasoning. Part of the official MCP server collection. Works with Claude Code and Cursor. **Best for**: AI agents needing structured Git repository access. **Works with**: Claude Code, Claude Desktop, Cursor, any MCP client. **Setup time**: Under 1 minute. ## Core Tools ### 1. git_status Get working tree status — staged, modified, untracked files. ### 2. git_log View commit history with filtering by author, date, path. ``` Agent: git_log(max_count=10, since="2026-04-01") → Returns structured commit objects with hash, author, date, message ``` ### 3. git_diff Show changes between commits, branches, or working tree. ``` Agent: git_diff(ref1="main", ref2="feature/auth") → Returns structured diff with file paths, additions, deletions ``` ### 4. git_show View contents of a specific commit. ### 5. git_branch List, create, delete, and switch branches. ### 6. git_commit Create commits with message and optional file selection. ### 7. git_blame Annotate file lines with commit information. ## Configuration Options ```json { "mcpServers": { "git": { "command": "uvx", "args": [ "mcp-server-git", "--repository", "/path/to/repo", "--read-only" ] } } } ``` | Flag | Purpose | |------|---------| | `--repository` | Path to git repo | | `--read-only` | Disable write operations | ## Use Cases | Use Case | Tools Used | |----------|-----------| | Code Review | git_log + git_diff + git_show | | Branch Management | git_branch + git_status | | History Analysis | git_log + git_blame | | Automated Commits | git_status + git_commit | ## FAQ **Q: Is it read-only by default?** A: No, it supports both read and write operations. Use `--read-only` flag to restrict to read-only if needed. **Q: Can it handle multiple repos?** A: Configure multiple Git MCP instances with different repository paths. **Q: How does it differ from Claude Code's built-in git?** A: Claude Code has built-in git access via Bash. Git MCP provides structured tool output that is easier for agents to parse and reason about. ## Source & Thanks > Part of the official [Model Context Protocol Servers](https://github.com/modelcontextprotocol/servers) collection. > > [modelcontextprotocol/servers/git](https://github.com/modelcontextprotocol/servers) — Official MCP server ## 快速使用 ```json {"mcpServers": {"git": {"command": "uvx", "args": ["mcp-server-git", "--repository", "."]}}} ``` 让 AI Agent 通过 MCP 工具调用操作 Git。 ## 什么是 Git MCP? MCP 服务器,为 AI Agent 提供结构化 Git 访问。类型化工具替代原始 shell 命令,输出结构化便于推理。 **一句话总结**:Git MCP 服务器,AI Agent 通过工具调用操作 log/diff/status/branch/commit/blame,结构化输出,官方 MCP 服务器集合。 **适合人群**:需要结构化 Git 访问的 AI Agent 用户。 ## 核心工具 1. git_status — 工作区状态 2. git_log — 提交历史 3. git_diff — 变更对比 4. git_branch — 分支管理 5. git_commit — 创建提交 6. git_blame — 行级追溯 ## 常见问题 **Q: 默认只读?** A: 不是,支持读写。用 `--read-only` 限制。 ## 来源与致谢 > [modelcontextprotocol/servers](https://github.com/modelcontextprotocol/servers) — 官方 MCP 服务器 --- Source: https://tokrepo.com/en/workflows/85eacf96-3b2b-43f5-ad6f-fd4413ad0b69 Author: MCP Hub