Automate Git Operations with LLMs
Git MCP Server lets LLMs read, diff, commit, and branch across multiple Git repositories via git_status, git_commit, and more.
1.3.1Add to Favorites
Why it matters
Leverage large language models to read, search, and manipulate Git repositories. This asset enables AI-driven code generation, review, and repository management.
Outcomes
What it gets done
Interact with Git repositories using natural language commands.
Automate code generation and review processes.
Manage Git branches, commits, and staging areas.
Query commit history and repository status.
Source
Get it from source
Spark does not host a copy of it.
Open sourceReports
Agent outcome reports
No reports yet
Capabilities
Tools your agent gets
Shows the status of the working tree
Shows changes in the working directory that have not yet been staged
Shows changes that have been staged for commit
Shows differences between branches or commits
Records changes to the repository
Adds file contents to the staging area
Removes all changes from the staging area
Shows the commit history
Overview
Git MCP Server
Git MCP Server, written in Go, gives an LLM Git operations as MCP tools: status, diffs, staging, commits, branching, and gated push access across multiple repositories. Use it when an LLM needs direct, multi-repository Git access for status, diffs, commits, and branching.
What it does
Git MCP Server is an MCP server, written in Go, for Git repository interaction and automation. It gives an LLM a set of Git operations as MCP tools - inspecting status and diffs, staging and committing changes, branching, and more - so it can read, search, and manipulate a Git repository directly instead of shelling out to raw git commands.
When to use - and when NOT to
Use it when you want an LLM to work with one or more local Git repositories: checking status, reviewing diffs, staging and committing changes, creating and switching branches, or inspecting history. It supports monitoring and operating on multiple repositories at once, specified via repeated -r/--repository flags, comma-separated paths, or positional arguments, defaulting to the first repository when none is specified for an operation. Remote-affecting operations like git_push are gated behind an explicit --write-access flag, so by default the server cannot push to a remote; enable that flag deliberately, not as a default posture.
Capabilities
- Inspect: git_status (working tree status), git_diff_unstaged, git_diff_staged, git_diff (between branches or commits), git_log, git_show (contents of a commit)
- Change: git_add (stage files), git_commit (record changes), git_reset (unstage all staged changes)
- Branching: git_create_branch (from an optional base branch), git_checkout (switch branches)
- Repository setup and management: git_init (initialize a new repository), git_list_repositories (list all configured repositories)
- Remote: git_push, which requires the --write-access flag to be enabled
- Two backend modes: shell, invoking the system git binary, or go-git, a pure-Go implementation, selectable via --mode
How to install
Download a prebuilt binary from the GitHub Releases page, or build from source:
git clone https://github.com/geropl/git-mcp-go.git
cd git-mcp-go
go build -o git-mcp-go .
Or install directly with Go:
go install github.com/geropl/git-mcp-go@latest
Requires Go 1.18+ and Git installed. Start the server with the serve subcommand, pointing it at one or more repository paths:
./git-mcp-go serve -v /path/to/repo1 /path/to/repo2 /path/to/repo3
Pass --mode go-git to use the pure-Go implementation instead of shelling out, and add --write-access to allow push operations. A separate setup subcommand exists for auto-approve and tool-specific configuration, accepting flags like --auto-approve and --tool.
Who it's for
Developers building LLM-driven coding workflows that need direct, multi-repository Git access - status, diffs, commits, branching, and history - without the model having to shell out to raw git commands itself. A separate setup subcommand mirrors serve's repository and mode flags while adding auto-approve and tool-specific options for editors such as cline and roo-code. It is released under the MIT License.
Source README
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-accessflag) - 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 page.
Building from Source
# 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 .
Install with go install
go install github.com/geropl/git-mcp-go@latest
Usage
Command Line Structure
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>
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/--repositoryflag:- With comma-separated paths:
-r=/path/to/repo1,/path/to/repo2 - With multiple flag instances:
-r=/path/to/repo1 -r=/path/to/repo2
- With comma-separated paths:
- 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:
# 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:
- 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.
# Set up for Cline with a single repository
./git-mcp-go setup -r /path/to/git/repository
# Set up with repositories as arguments
./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
# Set up with specific tools auto-approved
./git-mcp-go setup -r=/path/to/repo1,/path/to/repo2 --auto-approve=git_status,git_log
# Set up with write access and auto-approval for read-only tools
./git-mcp-go setup -r=/path/to/repo1,/path/to/repo2 --write-access --auto-approve=allow-read-only
The --auto-approve flag allows you to specify which tools should be auto-approved (not require explicit user approval):
- allow-read-only: Auto-approve all read-only tools (git_status, git_diff_unstaged, git_diff_staged, git_log, git_show, git_diff)
- allow-local-only: Auto-approve all local-only tools (incl. git_commit, git_add, git_reset, but not git_push)
- comma-separated list: Auto-approve specific tools (e.g., git_status,git_log)
Repository Management
The git_list_repositories Tool
This tool lists all available Git repositories that the server is monitoring. It shows:
- The total number of repositories
- The path to each repository
- The repository name (derived from the directory name)
Example output:
Available repositories (3):
1. repo1 (/path/to/repo1)
2. repo2 (/path/to/repo2)
3. another-project (/path/to/another-project)
Repository Selection
When running commands that require a repository path:
- If a specific
repo_pathis provided in the command, it will be used. - If no
repo_pathis provided and multiple repositories are configured, the first repository will be used as the default. - Each command output will indicate which repository was used for the operation.
Installation
Automatic Installation and Configuration
The easiest way to install and register the Git MCP server with Cline is to use the setup command:
# 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
# Setup the mcp server with multiple repositories
./git-mcp-go setup -r=/path/to/repo1,/path/to/repo2 --tool=cline --auto-approve=allow-local-only
rm -f ./git-mcp-go
The setup command will:
- Copy the executable to the Cline MCP directory
- Create a registration script that configures Cline to use the Git MCP server
Manual Configuration
Alternatively, 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"]
}
}
"mcpServers": {
"git": {
"command": "/path/to/git-mcp-go",
"args": ["serve", "-r", "/path/to/git/repository"]
}
}
Implementation Details
This server is implemented using:
- mcp-go: Go SDK for the Model Context Protocol
- go-git: Pure Go implementation of Git (used for the
go-gitmode)
For operations not supported by go-git, the server falls back to using the Git CLI.
Development
Testing
The server includes comprehensive tests for all Git operations. The tests are designed to run against both implementation modes:
# Run all tests
go test ./pkg -v
# Run specific tests
go test ./pkg -v -run TestGitOperations/push
The test suite creates temporary repositories for each test case and verifies that the operations work correctly in both modes.
Continuous Integration
This project uses GitHub Actions for continuous integration and deployment:
- Automated tests run on every pull request to the main branch
- Releases are created when a tag with the format
v*is pushed - Each release includes binaries for multiple platforms:
- Linux (amd64, arm64)
- macOS (amd64, arm64)
- Windows (amd64)
To create a new release:
# 1. Update the version in pkg/server.go (line ~26)
# Edit the version string in NewGitServer function
# 2. Commit the version change
git add pkg/server.go
git commit -m "Bump version to v1.3.1"
# 3. Push the commit
git push origin main
# 4. Tag the current commit
git tag v1.3.1
# 5. Push the tag to GitHub (this triggers the release)
git push origin v1.3.1
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.