Git
An MCP (Model Context Protocol) server enabling LLMs and AI agents to interact with Git repositories. Provides tools for comprehensive Git operations including clone, commit, branch, diff, log, status, push, pull, merge, rebase, worktree, tag managem
What is Git?
Git is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to mcp (model context protocol) server enabling llms and ai agents to interact with git repositories. provides tools for comprehensive git operations including clone, commit, branch, diff, log, status, p...
An MCP (Model Context Protocol) server enabling LLMs and AI agents to interact with Git repositories. Provides tools for comprehensive Git operations including clone, commit, branch, diff, log, status, push, pull, merge, rebase, worktree, tag managem
This server falls under the Version Control category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- git_status
- git_diff_unstaged
- git_diff_staged
- git_diff
- git_commit
Use Cases
Maintainer
Works with
Installation
NPM
npx -y @cyanheads/git-mcp-serverManual Installation
npx -y @cyanheads/git-mcp-serverConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Git
@cyanheads/git-mcp-server is a comprehensive Git integration for AI agents and LLMs, exposing 28 Git tools through the Model Context Protocol. It covers the full Git workflow: initializing and cloning repositories, staging and committing changes, branching, merging, rebasing, cherry-picking, remote operations (push/pull/fetch), tagging, stashing, worktree management, and a changelog analysis tool. It is designed for enterprise use cases where AI agents need reliable, auditable, and configurable access to version control without shell injection risks.
Prerequisites
- Node.js 18+ or Bun runtime
- Git installed and accessible in system PATH
- An MCP-compatible client such as Claude Desktop, Cursor, or VS Code
- Optional: GIT_USERNAME and GIT_EMAIL env vars for commit author attribution
Install and run via npx (no installation required)
The server can be run directly using npx without a global install. This is the recommended approach for most users.
npx -y @cyanheads/git-mcp-server@latestConfigure the MCP client
Add the server to your MCP client configuration file. The server runs as a stdio process launched by npx.
{
"mcpServers": {
"git": {
"command": "npx",
"args": ["-y", "@cyanheads/git-mcp-server@latest"],
"env": {
"GIT_USERNAME": "Your Name",
"GIT_EMAIL": "[email protected]",
"GIT_BASE_DIR": "/path/to/allowed/repos"
}
}
}
}Set environment variables for author attribution
Configure the author identity used for commits. GIT_BASE_DIR restricts which directories the server can access, which is recommended for security.
export GIT_USERNAME="Your Name"
export GIT_EMAIL="[email protected]"
export GIT_BASE_DIR="/home/user/projects"Set a working directory using git_set_working_dir
After connecting, tell the server which repository to operate on by calling the git_set_working_dir tool with the path to your repository. This persists for the session.
Configure transport and logging (optional)
For HTTP transport or verbose logging, set the additional environment variables. The default transport is stdio which works for all standard MCP clients.
export MCP_TRANSPORT_TYPE=stdio
export MCP_LOG_LEVEL=infoGit Examples
Client configuration
Claude Desktop config with author attribution and a restricted base directory for security.
{
"mcpServers": {
"git": {
"command": "npx",
"args": ["-y", "@cyanheads/git-mcp-server@latest"],
"env": {
"GIT_USERNAME": "Your Name",
"GIT_EMAIL": "[email protected]",
"GIT_BASE_DIR": "/Users/yourname/projects",
"MCP_LOG_LEVEL": "info"
}
}
}
}Prompts to try
These prompts work once the server is connected and git_set_working_dir has been called with a valid repo path.
- "Show me the git status and a diff of all unstaged changes in this repository"
- "Create a new branch called feature/auth and switch to it"
- "Stage all modified files and commit with the message 'fix: resolve authentication timeout'"
- "Generate a changelog from the last 20 commits and summarize what changed"
- "Rebase the current branch onto main and resolve any conflicts"
- "List all stashes and apply the most recent one"Troubleshooting Git
Server refuses to access a repository with 'outside base directory' error
The GIT_BASE_DIR env var restricts accessible paths. Either set GIT_BASE_DIR to a parent directory that includes your repo, or remove the variable entirely to allow unrestricted access (not recommended in shared environments).
Commits succeed but show wrong author name or email
Set GIT_USERNAME and GIT_EMAIL in the env block of your MCP client config. These override the values in the system .gitconfig for commits made through the MCP server.
git_push fails with authentication error for remote repositories
The server uses the Git credential store already configured on your system. Run 'git push' manually once in the repository to cache credentials via your OS keychain or credential helper, then retry through MCP.
Frequently Asked Questions about Git
What is Git?
Git is a Model Context Protocol (MCP) server that mcp (model context protocol) server enabling llms and ai agents to interact with git repositories. provides tools for comprehensive git operations including clone, commit, branch, diff, log, status, push, pull, merge, rebase, worktree, tag managem It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Git?
Install via npm with the command: npx -y @cyanheads/git-mcp-server. Then add the server configuration to your AI client's JSON config file (e.g., claude_desktop_config.json or .cursor/mcp.json).
Which AI clients work with Git?
Git works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Git free to use?
Yes, Git is open source and available under the Apache 2.0 license. You can use it freely in both personal and commercial projects.
Git Alternatives — Similar Version Control Servers
Looking for alternatives to Git? Here are other popular version control servers you can use with Claude, Cursor, and VS Code.
Ruiyu MA
★ 30.1kConnect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.
GitMCP
★ 8.1kTransforms any GitHub repository or GitHub Pages site into a documentation hub for AI assistants using the Model Context Protocol. It allows AI tools to access real-time code and documentation to prevent hallucinations and provide accurate API usage
GitHub Codemunch
★ 1.8kA token-efficient MCP server for exploring GitHub repositories using tree-sitter AST parsing to extract symbol signatures and summaries. It enables users to search and retrieve specific code components while significantly reducing token consumption c
Azure DevOps MCP Server
★ 1.7kThis server provides a convenient API for interacting with Azure DevOps services, enabling AI assistants and other tools to manage work items, code repositories, boards, sprints, and more. Built with the Model Context Protocol, it provides a standard
GitHub Official
★ 1.2kOfficial GitHub integration with comprehensive API coverage
Azure DevOps
★ 367Enables interaction with Azure DevOps through Cursor chat, providing tools to manage builds, pipelines, work items, sprints, and board operations. Supports secure authentication via Personal Access Tokens and allows natural language-driven DevOps tas
Browse More Version Control MCP Servers
Explore all version control servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Git in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Git?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.