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.
- Overview
- Features
- Installation
- Configuration
- Tools
- Best Practices
- Development
- Up Next
- Contributing
- License
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.
- Repository initialization and cloning
- File staging and committing
- Branch management
- Remote operations
- Tag handling
- Stash management
- Sequential operation execution
- Atomic commits
- Smart defaults
- Error resilience
- Path validation
- Repository state verification
- Embedded repository handling
- Comprehensive error reporting
- Clone the repository:
git clone https://github.com/cyanheads/git-mcp-server.git
- Navigate to the project directory:
cd git-mcp-server
- Install dependencies:
npm install
- Build the project:
npm run build
The server is now ready to be configured and used with your MCP client.
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"
}
}
}
}
Variable | Description | Required |
---|---|---|
GIT_DEFAULT_PATH | Default path for Git operations | No |
All paths must be absolute. For example:
- Repository path:
/Users/username/projects/my-repo
- File paths:
/Users/username/projects/my-repo/src/file.js
Initializes a new Git repository.
{
"path": string // Path to initialize
}
Clones a repository.
{
"url": string, // Repository URL (required)
"path": string // Clone destination
}
Gets repository status.
{
"path": string // Repository path
}
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"
}
]
}
Manage branches and working tree.
Manage repository tags.
Manage remote repositories.
Manage working directory changes.
- Always use absolute paths
- Validate paths before operations
- Handle embedded repositories properly
- Use bulk_action for multiple operations
- Handle operation dependencies correctly
- Provide clear commit messages
- Check operation results
- Handle partial success scenarios
- Validate repository state
# Build the project
npm run build
# Watch for changes
npm run watch
# Run MCP inspector
npm run inspector
The server provides detailed error information:
- Invalid paths or arguments
- Git command failures
- Repository state errors
- Permission issues
I welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
For bugs and feature requests, please create an issue.
Apache License 2.0