Skip to main content

Git MCP Server

Python MCP (Model Context Protocol) server for local git operations, providing native tool integration with Claude Code and other MCP clients.

Features

  • 6 Git Tools: Commit, branch, push, pull, status, and sync operations
  • Native MCP Integration: Works seamlessly with Claude Code
  • Conventional Commits: Enforced commit message format with type prefixes
  • Branch Naming: Enforced conventions (issue-N-description, feature-*, etc.)
  • Token Authentication: Automatic GitHub token injection for remote operations

Installation

From PyPI

pip install git-mcp-server
# or with uv
uvx git-mcp-server

From Source

git clone https://github.com/rriesco/git-mcp-server.git
cd git-mcp-server
uv sync

Configuration

Environment Variables

Variable Required Description
GITHUB_TOKEN For push/pull GitHub Personal Access Token for authenticated git operations

Claude Code Configuration

Add to your MCP configuration (~/.config/claude-code/mcp-config.json):

{
  "mcpServers": {
    "git-manager": {
      "type": "stdio",
      "command": "uvx",
      "args": ["git-mcp-server"],
      "env": {
        "GITHUB_TOKEN": "${GITHUB_TOKEN}"
      }
    }
  }
}

Available Tools

Tool Description
git_create_branch Create and checkout a new branch with naming conventions
git_commit Create conventional commit with Claude attribution
git_push Push commits to remote with upstream tracking
git_pull Pull commits from remote
git_status Get current branch, tracking info, and file changes
git_sync_with_main Sync current branch with main (merge or rebase)

Usage Examples

Create a Branch

result = git_create_branch(
    issue_number=42,
    description="add-feature-x"
)
# Creates: issue-42-add-feature-x

Commit Changes

result = git_commit(
    type="feat",
    message="implement user authentication"
)
# Creates: feat: implement user authentication
#
# Co-Authored-By: Claude <noreply@anthropic.com>

Check Status

result = git_status()
# Returns: {branch, tracking, ahead, behind, staged, modified, untracked, clean}

Sync with Main

result = git_sync_with_main(
    main_branch="main",
    strategy="merge"  # or "rebase"
)

Commit Types

The git_commit tool enforces conventional commit types:

Type Description
feat New feature
fix Bug fix
docs Documentation only
style Code style (formatting, semicolons, etc.)
refactor Code refactoring
perf Performance improvement
test Adding or fixing tests
build Build system or dependencies
ci CI/CD configuration
chore Maintenance tasks
revert Revert previous commit

Branch Naming

The git_create_branch tool enforces naming conventions:

  • issue-<N>-<description> - For GitHub issues
  • feature-<description> - For features without issues
  • fix-<description> - For bug fixes
  • refactor-<description> - For refactoring

Development

Prerequisites

  • Python >= 3.10
  • uv (recommended) or pip
  • Git

Setup

git clone https://github.com/rriesco/git-mcp-server.git
cd git-mcp-server
uv sync

Running Tests

# Unit tests only (fast)
uv run pytest -m "not integration" -v

# Integration tests (creates real git repos in temp directories)
uv run pytest -m integration -v

# All tests with coverage
uv run pytest --cov=git_mcp_server --cov-report=term-missing

Type Checking

uv run mypy src/git_mcp_server --strict

Architecture

Claude Code / MCP Client
      |
      | MCP Protocol (stdio)
      v
┌─────────────────────────────┐
│  Python FastMCP Server      │
│  - Tool Registry            │
│  - GitPython Client         │
│  - Error Handling           │
│  - Type Validation          │
└─────────────┬───────────────┘
              |
              | GitPython
              v
        Local Git Repo

Project Structure

git-mcp-server/
├── src/git_mcp_server/
│   ├── server.py              # Server entry point
│   ├── tools/
│   │   ├── branch.py          # Branch operations
│   │   ├── commit.py          # Commit operations
│   │   ├── remote.py          # Push/pull operations
│   │   ├── status.py          # Status queries
│   │   └── sync.py            # Sync with main
│   └── utils/
│       ├── git_client.py      # Singleton Repo instance
│       └── errors.py          # Structured error handling
└── tests/
    ├── test_*.py              # Unit tests
    └── integration/           # Integration tests

License

MIT License - see LICENSE for details.

Contributing

Contributions are welcome! Please read the contributing guidelines before submitting PRs.

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes with tests
  4. Submit a pull request

Metadata

Release files for rriesco-mcp-git 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rriesco-mcp-git 0.1.6
File Size Uploaded Provenance
rriesco_mcp_git-0.1.6.tar.gz 35.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for rriesco-mcp-git 0.1.6
File Interpreter ABI Platform
rriesco_mcp_git-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 54.3 kB

Release files / rriesco_mcp_git-0.1.6.tar.gz

Download URL rriesco_mcp_git-0.1.6.tar.gz
Size 35.7 kB
Tags Source
SHA-256 checksum
How to use checksums
71c83767f5705015e2e895b6324fa6c8317a4729d8475d596a5d56100d4cc8aa
BLAKE2b-256 checksum
How to use checksums
4a8d15bbae092510e1251ec62f31281f445800fa49d84d3ba921910714fdfe84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rriesco_mcp_git-0.1.6-py3-none-any.whl

Download URL rriesco_mcp_git-0.1.6-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5537c084e8236b9acca41ef3543dbffc76c06132ef2bcae9fb96fc7eee81f03b
BLAKE2b-256 checksum
How to use checksums
b38708cb36188793a83f6e4a400b33aee0679f3ffe996de4641380522cc42672
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for rriesco-mcp-git 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page