Skip to main content
Glama
rriesco

Git MCP Server

by rriesco

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

Related MCP server: Git Workflow MCP Server

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

Available Tools

6 tools
git_commitA

Create conventional commit (type: message) with Claude attribution.

Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert

Options:

  • files: commit specific files only (default: all changes)

  • skip_hooks: bypass pre-commit hooks via --no-verify

Returns: {sha, stats: {files_changed, insertions, deletions}, message}

ParametersJSON Schema
NameRequiredDescriptionDefault
typeYes
messageYes
filesNo
skip_hooksNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must carry behavioral disclosure. It mentions return structure and options (files, skip_hooks), but lacks details on side effects (e.g., automatic staging, error handling, or repository state requirements). Incomplete but not missing.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise (6 lines), front-loads the main action, and each sentence provides distinct value: type list, options, and return format. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers purpose, parameters, and return value, but lacks prerequisites (e.g., staged changes, git repo requirement) and error conditions. Given no annotations and moderate complexity (4 params), more context would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant meaning beyond the schema: it lists allowed types (feat, fix, etc.) where schema only has a string, explains 'files' defaults to all changes, and clarifies 'skip_hooks' bypasses pre-commit hooks. Schema coverage is 0%, so description compensates well.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's action: 'Create conventional commit (type: message) with Claude attribution.' It specifies the verb (create), resource (commit), and format (conventional), distinguishing it from sibling tools like git_push or git_status.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for committing changes but does not explicitly provide when-to-use vs alternatives or exclusions. Options like 'files' and 'skip_hooks' offer some context, but no direct guidance on tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

git_create_branchA

Create and checkout a git branch.

Naming: branch_name (explicit) OR issue_number/description (auto: issue-N-desc or feature-desc). Options: from_branch (default: HEAD or main if auto-naming), pull_latest (default: False).

Returns: {branch_name, previous_branch, sha, based_on}

ParametersJSON Schema
NameRequiredDescriptionDefault
branch_nameNo
issue_numberNo
descriptionNo
from_branchNo
pull_latestNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, but the description discloses the behavior: creates and checks out a branch, outlines auto-naming logic, and specifies the return structure. It does not mention potential issues like a dirty working directory or error conditions, but for a creation tool, it is fairly transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very concise and well-structured: a clear one-line purpose, followed by a paragraph on naming and options, then a short return specification. Every sentence adds value without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With 5 parameters, no required fields, and no output schema (though return fields are listed), the description covers naming, options, and returns. It does not address error conditions or preconditions, but for a straightforward creation tool, it is sufficiently complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, so the description carries the full burden. It adds meaning to parameters: explains that branch_name is explicit, while issue_number/description trigger auto-naming, and describes options like from_branch and pull_latest with defaults.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action: 'Create and checkout a git branch.' This is a specific verb and resource, and it distinguishes the tool from siblings like git_commit or git_pull.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides naming conventions (explicit or auto) and options (from_branch, pull_latest) with defaults. It gives some guidelines but does not explicitly state when not to use this tool or when alternatives might be better.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

git_pullB

Pull commits from remote. Uses GITHUB_TOKEN from env if available.

Fails if there are uncommitted changes (commit or stash first).

Returns: {branch, remote, sha_before, sha_after, commits_pulled, files_changed, up_to_date}

ParametersJSON Schema
NameRequiredDescriptionDefault
remoteNoorigin
branchNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It discloses that the tool uses GITHUB_TOKEN and fails with uncommitted changes. However, it does not cover conflict resolution or error scenarios beyond the precondition.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very concise, using three short sentences and a bulleted return format. All information is front-loaded and no words are wasted.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (two optional params, output schema described), the description covers auth, a key precondition, and the return structure. It is sufficiently complete for an agent to use the tool correctly in most cases.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, but the description adds no parameter details beyond the names in the schema. The defaults and types are in the schema, but the description could have clarified the branch parameter's role (e.g., current branch if null).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Pull commits from remote', specifying the action (pull) and resource (commits from remote). It distinguishes itself from siblings like git_push and git_commit through the pull action, but lacks explicit differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides usage context by noting the tool fails if there are uncommitted changes, advising to commit or stash first. However, it does not mention when not to use it or alternatives like git_sync_with_main.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

git_pushA

Push commits to remote. Uses GITHUB_TOKEN from env if available.

Options:

  • branch: specific branch (default: current)

  • set_upstream: track new branches (default: True)

  • force: force push (use with caution!)

Returns: {branch, remote, sha, commits_pushed, is_new_branch, force}

ParametersJSON Schema
NameRequiredDescriptionDefault
remoteNoorigin
branchNo
set_upstreamNo
forceNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It discloses that the tool pushes commits (a write operation), notes authentication via GITHUB_TOKEN, warns about force push, and specifies the return value. However, it does not mention potential side effects like overwriting remote commits or failure scenarios.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very concise: one sentence for purpose, then a bullet list of options, and a return description. It is front-loaded and every sentence adds value without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple git push tool, the description covers the purpose, parameters, and return values. It lacks explicit context about prerequisites (e.g., having a remote configured) or full authentication details, but the output schema is provided. Overall, it is adequate given the tool's complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description compensates thoroughly by explaining all four parameters: branch (specific, defaults to current), set_upstream (track new branches), force (force push with caution), and remote (implied by default 'origin'). This adds significant meaning beyond the schema's bare names.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Push commits to remote' clearly states the verb (push) and resource (commits to remote). The tool name 'git_push' aligns perfectly, and it distinguishes itself from sibling tools like git_commit, git_create_branch, etc., which have different purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description includes usage notes like using GITHUB_TOKEN and a caution for force push, but it does not explicitly state when to use this tool over siblings (e.g., vs. git_pull or git_commit). The context is implied but not fully explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

git_statusA

Get repository status: branch, tracking info, and file changes.

Returns: {branch, tracking, ahead, behind, staged, modified, untracked, clean}

clean=True means no staged, modified, or untracked files.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It explains what each returned field means and the condition for clean=True (no changes). Provides useful behavioral context beyond the empty input schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Description is two sentences, no wasted words. First sentence states purpose, second clarifies output structure. Well front-loaded and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no parameters and output schema (implied by returns description), the description fully explains what the tool does and what it returns. No gaps for a status-checking tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has 0 parameters, so schema coverage is 100%. Baseline is 4 because parameter meaning is not needed. Description adds no param info but none is required.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states it gets repository status including branch, tracking info, and file changes. This verb+resource combination is distinct from sibling tools like git_commit, git_create_branch, git_pull, git_push, git_sync_with_main.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this vs alternatives, but siblings are all different actions (commit, branch, pull, push, sync), so usage context is implied. Adequate but lacks when-not or prerequisite statements.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

git_sync_with_mainA

Sync current branch with main. Fetches latest and merges/rebases.

Options:

  • main_branch: branch to sync from (default: "main")

  • strategy: "merge" (default) or "rebase"

Fails if on main branch or has uncommitted changes.

Returns: {branch, main_branch, strategy, sha_before, sha_after, commits_added, up_to_date, files_changed}

ParametersJSON Schema
NameRequiredDescriptionDefault
main_branchNomain
strategyNomerge

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.6/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It states it fetches and then merges or rebases, implies it modifies the branch history, and lists return fields including sha changes. It fails with uncommitted changes, indicating a precondition. It does not mention push behavior or destructive implications of rebase, but overall it provides good transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very concise: one introductory sentence, then a bullet-like list of options and return fields. It is front-loaded with the main purpose and uses minimal words. Every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (git sync with merge/rebase), two optional parameters, and an output schema, the description is complete. It covers purpose, parameters, failure conditions, and return format. The output schema exists, so the return list is supplementary but not redundant.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has no descriptions (0% coverage), so the description fully supplies meaning for both parameters: main_branch defaults to 'main', strategy defaults to 'merge' with option 'rebase'. This adds essential context beyond the schema's bare type declarations.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool syncs the current branch with main by fetching latest and merging or rebasing. This distinguishes it from siblings like git_pull (generic) and git_push (push only), as it is specifically about updating the current branch relative to main.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly provides failure conditions: fails if on main branch or has uncommitted changes. This tells when not to use it. It also lists options and defaults, giving clear usage context. However, it does not explicitly compare with alternatives like git_merge or git_rebase, though the siblings are sufficiently distinct.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A4.2/5.0
Disambiguation5/5

Each tool has a distinct purpose: commit, create branch, pull, push, status, and sync with main. There is no ambiguity or overlap between them.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern using snake_case (e.g., git_commit, git_push), making them predictable and easy to distinguish.

Tool Count5/5

With 6 tools, the server is well-scoped for common Git operations. The number is neither too large nor too small for the domain.

Completeness4/5

The tool set covers core Git workflows (commit, branch, push/pull, status, sync). Minor gaps include no explicit diff or log tools, but these are not essential for basic operations.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • -
    license
    B
    quality
    Not graded
    maintenance
    Enables comprehensive Git and GitHub operations through 30 DevOps tools including repository management, file operations, workflows, and advanced Git features. Provides complete Git functionality without external dependencies for seamless integration with Gitea and GitHub platforms.
    18
    819
  • F
    license
    Not graded
    quality
    Not graded
    maintenance
    Enables AI assistants to interact with local Git repositories for operations like status, commits, branching, and diffs, plus GitHub API integration for managing pull requests when authenticated.
  • A
    license
    B
    quality
    D
    maintenance
    Provides comprehensive Git functionality to MCP clients, enabling users to manage repositories through operations like commits, diffs, and branch management via natural language. It automatically detects the current working directory and supports multi-project workflows across different local environments.
    16
    607
    2
    MIT
  • A
    license
    A
    quality
    A
    maintenance
    Local-first MCP server and CLI wrapper for AI coding agents. SAGE routes shell commands through a tracked local runner, stores command history on the user’s machine, and returns compressed terminal output to reduce noisy context.
    16
    10
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rriesco/git-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server