Git MCP Server is a powerful tool that provides an interface between Large Language Models and Git repositories through the Model Context Protocol (MCP). It allows AI assistants to interact with Git repositories, performing operations like viewing status, making commits, and managing branches.
You can download prebuilt binaries for your platform from the GitHub Releases page.
# Clone the repository
git clone https://github.com/geropl/git-mcp-go.git
cd git-mcp-go
# Build the server
go build -o git-mcp-go .
go install
go install github.com/geropl/git-mcp-go@latest
The Git MCP Server uses a command-line structure with subcommands:
git-mcp-go
├── serve [flags] [repository-paths...]
│ ├── --repository, -r <paths> # Repository paths (multiple ways to specify)
│ ├── --mode <shell|go-git>
│ ├── --write-access
│ └── --verbose, -v
└── setup [flags] [repository-paths...]
├── --repository, -r <paths> # Repository paths (multiple ways to specify)
├── --mode <shell|go-git>
├── --write-access
├── --auto-approve <tool-list|allow-read-only|allow-local-only>
└── --tool <cline,roo-code>
The Git MCP Server can monitor and operate on multiple repositories simultaneously. You can specify repositories in several ways:
-r/--repository
flag:
-r=/path/to/repo1,/path/to/repo2
-r=/path/to/repo1 -r=/path/to/repo2
serve /path/to/repo1 /path/to/repo2
When using multiple repositories, the server will default to the first repository for operations where a specific repository is not specified.
The serve
command starts the Git MCP server:
# Run with verbose logging
./git-mcp-go serve -v /path/to/repo1 /path/to/repo2 /path/to/repo3
# Run with go-git implementation
./git-mcp-go serve --mode go-git -r=/path/to/repo1,/path/to/repo2
# Enable write access for remote operations
./git-mcp-go serve -r=/path/to/repo1,/path/to/repo2 --write-access
The --mode
flag allows you to choose between two different implementations:
The --write-access
flag enables operations that modify remote state (currently only the push operation).
The setup
command configures the Git MCP server for use with an AI assistant:
# Set up for Cline with a single repository
./git-mcp-go setup -r /path/to/git/repository
# Set up with multiple repositories
./git-mcp-go setup /path/to/repo1 /path/to/repo2 /path/to/repo3
# Set up with write access enabled
./git-mcp-go setup -r=/path/to/repo1,/path/to/repo2 --write-access
# Set up with auto-approval for read-only tools
./git-mcp-go setup -r=/path/to/repo1,/path/to/repo2 --auto-approve=allow-read-only
The --auto-approve
flag specifies which tools should be auto-approved:
The server provides the following Git operations as tools:
--write-access
flag)The git_list_repositories
tool lists all available Git repositories that the server is monitoring, showing:
Example output:
Available repositories (3):
1. repo1 (/path/to/repo1)
2. repo2 (/path/to/repo2)
3. another-project (/path/to/another-project)
When running commands that require a repository path:
repo_path
is provided in the command, it will be used.repo_path
is provided and multiple repositories are configured, the first repository will be used as the default.For a quick start, use this script to download and set up the Git MCP server:
# Download linux binary for the latest release
RELEASE="$(curl -s https://api.github.com/repos/geropl/git-mcp-go/releases/latest)"
DOWNLOAD_URL="$(echo $RELEASE | jq -r '.assets[] | select(.name | contains("linux-amd64")) | .browser_download_url')"
curl -L -o ./git-mcp-go $DOWNLOAD_URL
chmod +x ./git-mcp-go
# Setup the mcp server with a single repository
./git-mcp-go setup -r /path/to/git/repository --tool=cline --auto-approve=allow-local-only
rm -f ./git-mcp-go
You can manually add this to your claude_desktop_config.json
:
"mcpServers": {
"git": {
"command": "/path/to/git-mcp-go",
"args": ["serve", "-r=/path/to/repo1,/path/to/repo2", "--mode", "shell"]
}
}
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "git" '{"command":"/path/to/git-mcp-go","args":["serve","-r","/path/to/git/repository"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"git": {
"command": "/path/to/git-mcp-go",
"args": [
"serve",
"-r",
"/path/to/git/repository"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"git": {
"command": "/path/to/git-mcp-go",
"args": [
"serve",
"-r",
"/path/to/git/repository"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect