Labsco
geropl logo

Git MCP Server (Go)

โ˜… 36

from geropl

An MCP server for interacting with and automating Git repositories using Large Language Models.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

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

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:

Copy & paste โ€” that's it
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_path is provided in the command, it will be used.

  • If no repo_path is 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.

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-git mode)

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:

Copy & paste โ€” that's it
# 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:

Copy & paste โ€” that's it
# 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

License

This project is licensed under the MIT License.