LO

Local Git MCP Server with Push Support

Enable LLMs to interact with a local git repository via an MCP server, including optional push support for seamless code updates.

Quick Install
npx -y @geropl/git-mcp-go

Overview

This MCP (Model Context Protocol) server lets language models interact directly with a local Git repository. It implements a small HTTP-based MCP toolset that exposes common git operations—file reads, diffs, commits, branch creation, and optionally pushes—so an LLM agent can explore code, propose edits, and apply changes back to the repository in a controlled way.

Running the server locally is useful for developer automation, code review assistants, and interactive programming agents. Because the server operates on a repository you control, it preserves your local workflow and security model while enabling programmatic, model-driven code changes. Push support is optional and gated so you can safely decide whether the server may push commits to a remote origin.

Features

  • Exposes Git operations as MCP tools for LLMs:
    • Read file contents, list files and directories
    • Show diffs and commit history
    • Create commits and branches
    • Optional: push commits to configured remote
  • Scoped access controls to limit which directories are exposed
  • Lightweight single-binary implementation written in Go
  • Works entirely on a local repository; no cloud access required
  • Configurable authentication token for client-to-server calls
  • Logs and audit trails for actions performed by the model

Installation / Configuration

Prerequisites: Go 1.20+ (or use the prebuilt binary if provided on GitHub releases).

Clone and build from source:

git clone https://github.com/geropl/git-mcp-go.git
cd git-mcp-go
go build ./cmd/git-mcp-go
# produces ./git-mcp-go (or similar)

Run with a repository path and basic options:

# run on localhost:8080, serve /path/to/repo, enable push
./git-mcp-go --repo /path/to/repo --addr :8080 --enable-push --auth-token-file /path/to/token

Example configuration (YAML) — many deployments prefer a config file:

repo: /home/dev/projects/myrepo
addr: :8080
enable_push: true
allowed_dirs:
  - src/
  - docs/
auth_token_file: /etc/git-mcp/token
log_level: info

Start with Docker (example):

docker run --rm -p 8080:8080 \
  -v /home/dev/projects/myrepo:/repo:rw \
  -v /etc/git-mcp/token:/token:ro \
  ghcr.io/your-image/git-mcp-go:latest \
  --repo /repo --addr :8080 --auth-token-file /token --enable-push

Configuration options (typical; refer to the binary’s –help for exact flags):

OptionPurpose
–repoPath to the local git repository to expose
–addrNetwork address to bind (e.g., :8080)
–enable-pushEnable forceable push to remote origin (optional)
–allowed-dirsRestrict operations to listed subdirectories
–auth-token-fileFile containing the shared token for client authentication

Available Tools / Resources

The server presents a set of model-callable tools (MCP resources). Typical tools include:

  • git/list — List files and directories with optional glob or depth
  • git/read — Read file content (path, byte limits supported)
  • git/diff — Show a diff between working tree / commits / branches
  • git/commit — Create a commit from a patch or staged changes
  • git/branch — Create or checkout branches
  • git/push — Push a branch to remote (only if push is enabled)
  • git/log — Show recent commits and metadata

Each tool returns structured JSON results suitable for model consumption, including truncated content indicators and suggested next actions. The server also provides status and health endpoints for orchestration.

Use Cases

  1. Interactive code edits via an assistant

    • The model reads a file (git/read), proposes an edit, and submits a patch to commit (git/commit). If push is enabled, it can push the change to a remote branch (git/push). This enables a back-and-forth workflow where the assistant iterates on code until tests pass.
  2. Automated dependency update

    • An automation agent scans dependency files, proposes updates, runs local tests, commits the updated files, and pushes a branch for review. The MCP server lets the agent perform file edits and commits without exposing the full filesystem.
  3. Code review summarization and refactoring suggestions

    • A model can read multiple files and the commit history (git/log), produce a code summary, and suggest refactorings as a set of diffs. Changes can be staged as a commit and left for a human reviewer, or pushed to a feature branch for CI.
  4. Incident triage and hotfix creation

    • During urgent fixes, an assistant can search the repo, apply a minimal patch, create a branch, and (if permitted) push a hotfix for immediate deployment.

Security & Best Practices

  • Default to push disabled. Enable push only when you have appropriate controls (branch protections, CI).
  • Use the auth token and run the server on localhost or a private network. Do not expose it to untrusted networks.
  • Restrict allowed_dirs so the model cannot access sensitive files (configs, secrets).
  • Log actions and keep an audit trail for any automated commits/pushes.
  • Run the server under a dedicated system user with minimal privileges to the repository.

Repository and further development information: https://github.com/geropl/git-mcp-go.