Integrates with Git repositories to enable version control operations and automation, supporting both shell-based comman...
Created byApr 23, 2025
Git MCP Server (Go)
A Model Context Protocol (MCP) server for Git repository interaction and automation, written in Go. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.
Features
This MCP server provides the following Git operations as tools:
**git_status**: Shows the working tree status
**git_diff_unstaged**: Shows changes in the working directory that are not yet staged
**git_diff_staged**: Shows changes that are staged for commit
**git_diff**: Shows differences between branches or commits
**git_commit**: Records changes to the repository
**git_add**: Adds file contents to the staging area
**git_reset**: Unstages all staged changes
**git_log**: Shows the commit logs
**git_create_branch**: Creates a new branch from an optional base branch
**git_checkout**: Switches branches
**git_show**: Shows the contents of a commit
**git_init**: Initialize a new Git repository
**git_push**: Pushes local commits to a remote repository (requires `--write-access` flag)
**git_list_repositories**: Lists all available Git repositories
Installation
Prerequisites
Go 1.18 or higher
Git installed on your system
Download Prebuilt Binaries
You can download prebuilt binaries for your platform from the [GitHub Releases](https://github.com/geropl/git-mcp-go/releases) page.
Building from Source
Install with `go install`
Usage
Command Line Structure
The Git MCP Server uses a command-line structure with subcommands:
Multi-Repository Support
The Git MCP Server can now monitor and operate on multiple repositories simultaneously. You can specify repositories in several ways:
Using the `-r/--repository` flag:
- With comma-separated paths: `-r=/path/to/repo1,/path/to/repo2`
- With multiple flag instances: `-r=/path/to/repo1 -r=/path/to/repo2`
As positional arguments: `serve /path/to/repo1 /path/to/repo2`
A combination of both approaches
When using multiple repositories, the server will default to the first repository for operations where a specific repository is not specified.
`serve` Command
The `serve` command starts the Git MCP server:
The `--mode` flag allows you to choose between two different implementations:
**shell**: Uses the Git CLI commands via shell execution (default)
**go-git**: Uses the go-git library for Git operations where possible
The `--write-access` flag enables operations that modify remote state (currently only the push operation). By default, this is disabled for safety.
`setup` Command
The `setup` command sets up the Git MCP server for use with an AI assistant. It copies itself to `~/mcp-servers/git-mcp-go` and modifies the tools config (cline: `cline_mcp_settings.json`) to use that binary.
The `--auto-approve` flag allows you to specify which tools should be auto-approved (not require explicit user approval):