Git MCP Server
About
A Model Context Protocol (MCP) server that exposes comprehensive Git functionality to Large Language Models. It enables LLMs to perform version control operations like repository initialization, cloning, staging, committing, branching, and remote management through a secure…
Details
- Author
- MCP-Mirror
- Downloads
- 274
- Categories
- Developer Tools, AI
Jump to
- Repository initialization and cloning
- File staging, committing, and branch management
- Remote operations, tag handling, and stash management
- Bulk sequential operations with atomic commits
- Path validation and repository state verification
- Comprehensive error reporting and safety features
Clone the repository, install dependencies with npm install, and build with npm run build. Then configure the server in your MCP client settings (e.g., Claude Desktop or IDEs) by specifying the command node and the absolute path to the built index.js. Optionally set the GIT_DEFAULT_PATH environment variable. Always use absolute paths for all Git operations.
Git MCP Server
A Model Context Protocol server that provides comprehensive Git functionality to Large Language Models, enabling them to perform version control operations through a secure and standardized interface.
Table of Contents
- Overview
- Features
- Installation
- Configuration
- Tools
- Best Practices
- Development
- Up Next
- Contributing
- License
Overview
Model Context Protocol Server
The Git MCP Server implements the Model Context Protocol (MCP), created by Anthropic, which provides a standardized communication protocol between LLMs and external systems. The architecture consists of:
- Clients (Claude Desktop, IDEs) that maintain server connections
- Servers that provide tools and resources to clients
- LLMs that interact with servers through client applications
This architecture creates a secure boundary between LLMs and external systems while enabling controlled access to Git functionality. Through the MCP protocol, the Git server empowers LLMs to perform version control operations, manage repositories, and handle complex Git workflows — all within a secure and validated environment.
Features
Core Git Operations
- Repository initialization and cloning - File staging and committing - Branch management - Remote operations - Tag handling - Stash managementBulk Operations
- Sequential operation execution - Atomic commits - Smart defaults - Error resilienceSafety Features
- Path validation - Repository state verification - Embedded repository handling - Comprehensive error reportingInstallation
Setup Steps
1. Clone the repository:
git clone https://github.com/cyanheads/git-mcp-server.git
2. Navigate to the project directory:
cd git-mcp-server
3. Install dependencies:
npm install
4. Build the project:
npm run build
The server is now ready to be configured and used with your MCP client.
Configuration
The Git MCP Server requires configuration in your MCP client settings:
{
"mcpServers": {
"git": {
"command": "node",
"args": ["/path/to/git-mcp-server/build/index.js"],
"env": {
"GIT_DEFAULT_PATH": "/optional/default/path/for/git/operations"
}
}
}
}
Environment Variables
| Variable | Description | Required |
|----------|-------------|----------|
| GIT_DEFAULT_PATH | Default path for Git operations | No |
Path Requirements
All paths must be absolute. For example:
- Repository path: /Users/username/projects/my-repo
- File paths: /Users/username/projects/my-repo/src/file.js
Tools
Basic Operations
init
Initializes a new Git repository.{
"path": string // Path to initialize
}
clone
Clones a repository.{
"url": string, // Repository URL (required)
"path": string // Clone destination
}
status
Gets repository status.{
"path": string // Repository path
}
Bulk Operations
bulk_action
Executes multiple Git operations in sequence. This is the preferred way to execute multiple operations.{
"path": string, // Repository path
"actions": [ // Array of operations to execute
{
"type": "stage",
"files": string[] // Optional - if omitted, stages all changes
},
{
"type": "commit",
"message": string
},
{
"type": "push",
"branch": string,
"remote": string // Optional - defaults to "origin"
}
]
}
Branch Operations
branch_list, branch_create, branch_delete, checkout
Manage branches and working tree.Tag Operations
tag_list, tag_create, tag_delete
Manage repository tags.Remote Operations
remote_list, remote_add, remote_remove
Manage remote repositories.Stash Operations
stash_list, stash_save, stash_pop
Manage working directory changes.Best Practices
Path Management
- Always use absolute paths - Validate paths before operations - Handle embedded repositories properlyBulk Operations
- Use bulk_action for multiple operations - Handle operation dependencies correctly - Provide clear commit messagesError Handling
- Check operation results - Handle partial success scenarios - Validate repository stateDevelopment
```bash
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.




