Skip to main content
Glama
mcp-server-git

mcp-server-git

by Arnabdaz

mcp-server-git: A git MCP server

Overview

A Model Context Protocol server for Git repository interaction and automation. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.

Please note that mcp-server-git is currently in early development. The functionality and available tools are subject to change and expansion as we continue to develop and improve the server.

Tools

  1. git_status

    • Shows the working tree status

    • Input:

      • repo_path (string): Path to Git repository

    • Returns: Current status of working directory as text output

  2. git_diff_unstaged

    • Shows changes in working directory not yet staged

    • Inputs:

      • repo_path (string): Path to Git repository

      • context_lines (number, optional): Number of context lines to show (default: 3)

    • Returns: Diff output of unstaged changes

  3. git_diff_staged

    • Shows changes that are staged for commit

    • Inputs:

      • repo_path (string): Path to Git repository

      • context_lines (number, optional): Number of context lines to show (default: 3)

    • Returns: Diff output of staged changes

  4. git_diff

    • Shows differences between branches or commits

    • Inputs:

      • repo_path (string): Path to Git repository

      • target (string): Target branch or commit to compare with

      • context_lines (number, optional): Number of context lines to show (default: 3)

    • Returns: Diff output comparing current state with target

  5. git_commit

    • Records changes to the repository

    • Inputs:

      • repo_path (string): Path to Git repository

      • message (string): Commit message

    • Returns: Confirmation with new commit hash

  6. git_add

    • Adds file contents to the staging area

    • Inputs:

      • repo_path (string): Path to Git repository

      • files (string[]): Array of file paths to stage

    • Returns: Confirmation of staged files

  7. git_reset

    • Unstages all staged changes

    • Input:

      • repo_path (string): Path to Git repository

    • Returns: Confirmation of reset operation

  8. git_log

    • Shows the commit logs

    • Inputs:

      • repo_path (string): Path to Git repository

      • max_count (number, optional): Maximum number of commits to show (default: 10)

    • Returns: Array of commit entries with hash, author, date, and message

  9. git_create_branch

    • Creates a new branch

    • Inputs:

      • repo_path (string): Path to Git repository

      • branch_name (string): Name of the new branch

      • base_branch (string, optional): Starting point for the new branch

    • Returns: Confirmation of branch creation

  10. git_checkout

  • Switches branches

  • Inputs:

    • repo_path (string): Path to Git repository

    • branch_name (string): Name of branch to checkout

  • Returns: Confirmation of branch switch

  1. git_show

  • Shows the contents of a commit

  • Inputs:

    • repo_path (string): Path to Git repository

    • revision (string): The revision (commit hash, branch name, tag) to show

  • Returns: Contents of the specified commit

  1. git_init

  • Initializes a Git repository

  • Inputs:

    • repo_path (string): Path to directory to initialize git repo

  • Returns: Confirmation of repository initialization

  1. git_branch

  • List Git branches

  • Inputs:

    • repo_path (string): Path to the Git repository.

    • branch_type (string): Whether to list local branches ('local'), remote branches ('remote') or all branches('all').

    • contains (string, optional): The commit sha that branch should contain. Do not pass anything to this param if no commit sha is specified

    • not_contains (string, optional): The commit sha that branch should NOT contain. Do not pass anything to this param if no commit sha is specified

  • Returns: List of branches

  1. git_cherry_pick

  • Cherry-pick a commit to the current branch

  • Inputs:

    • repo_path (string): Path to Git repository

    • commit_sha (string): The commit hash to cherry-pick

    • no_commit (boolean, optional): If true, cherry-pick without committing (default: false)

  • Returns: Confirmation of cherry-pick operation

  1. git_list_remotes

  • List configured remotes

  • Inputs:

    • repo_path (string): Path to Git repository

    • verbose (boolean, optional): Show remote URLs if true (default: false)

  • Returns: List of configured remotes

  1. git_pull

  • Pull changes from remote repository

  • Inputs:

    • repo_path (string): Path to Git repository

    • remote (string): Name of the remote

    • branch (string): Name of the branch to pull

  • Returns: Confirmation of pull operation

  1. git_push

  • Push changes to remote repository

  • Inputs:

    • repo_path (string): Path to Git repository

    • remote (string): Name of the remote

    • branch (string): Name of the branch to push

    • force (boolean, optional): Force push if true (default: false)

  • Returns: Confirmation of push operation

  1. git_fetch

  • Fetch changes from remote repository

  • Inputs:

    • repo_path (string): Path to Git repository

    • remote (string): Name of the remote

    • branch (string, optional): Specific branch to fetch (default: all branches)

    • all_remotes (boolean, optional): Fetch from all remotes if true (default: false)

  • Returns: Confirmation of fetch operation

  1. git_switch_create

  • Switches to a new branch or creates it from an optional base branch

  • Inputs:

    • repo_path (string): Path to Git repository

    • branch_name (string): Name of the branch to create and switch to

    • base_branch (string, optional): Base branch for the new branch

  • Returns: Confirmation of branch creation and switch

Related MCP server: Gitingest MCP Server

Installation

When using uv no specific installation is needed. We will use uvx to directly run mcp-server-git.

Using PIP

Alternatively you can install mcp-server-git via pip:

pip install mcp-server-git

After installation, you can run it as a script using:

python -m mcp_server_git

Configuration

Usage with Claude Desktop

Add this to your claude_desktop_config.json:

"mcpServers": {
  "git": {
    "command": "uvx",
    "args": ["mcp-server-git", "--repository", "path/to/git/repo"]
  }
}
  • Note: replace '/Users/username/projects' with the specific project path you want to be accessible

  • For security, only mount the specific directories you need, not entire user directories

"mcpServers": {
  "git": {
    "command": "docker",
    "args": [
      "run", "--rm", "-i",
      "--security-opt=no-new-privileges:true",
      "--read-only",
      "--tmpfs", "/tmp:rw,noexec,nosuid,size=100m",
      "--mount", "type=bind,src=/Users/username/projects,dst=/workspace,readonly",
      "--user", "1000:1000",
      "mcp/git",
      "--repository", "/workspace/your-repo"
    ]
  }
}
"mcpServers": {
  "git": {
    "command": "python",
    "args": ["-m", "mcp_server_git", "--repository", "path/to/git/repo"]
  }
}

Usage with VS Code

For quick installation, use one of the one-click install buttons below...

Install with UV in VS Code Install with UV in VS Code Insiders

Install with Docker in VS Code Install with Docker in VS Code Insiders

For manual installation, add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing Ctrl + Shift + P and typing Preferences: Open Settings (JSON).

Optionally, you can add it to a file called .vscode/mcp.json in your workspace. This will allow you to share the configuration with others.

Note that the mcp key is not needed in the .vscode/mcp.json file.

{
  "mcp": {
    "servers": {
      "git": {
        "command": "uvx",
        "args": ["mcp-server-git"]
      }
    }
  }
}

For Docker installation (secure configuration):

{
  "mcp": {
    "servers": {
      "git": {
        "command": "docker",
        "args": [
          "run",
          "--rm",
          "-i",
          "--security-opt=no-new-privileges:true",
          "--read-only",
          "--tmpfs",
          "/tmp:rw,noexec,nosuid,size=100m",
          "--mount",
          "type=bind,src=${workspaceFolder},dst=/workspace",
          "--user",
          "1000:1000",
          "mcp/git",
          "--repository",
          "/workspace"
        ]
      }
    }
  }
}

Usage with Zed

Add to your Zed settings.json:

"context_servers": [
  "mcp-server-git": {
    "command": {
      "path": "uvx",
      "args": ["mcp-server-git"]
    }
  }
],
"context_servers": {
  "mcp-server-git": {
    "command": {
      "path": "python",
      "args": ["-m", "mcp_server_git"]
    }
  }
},

Usage with Zencoder

  1. Go to the Zencoder menu (...)

  2. From the dropdown menu, select Agent Tools

  3. Click on the Add Custom MCP

  4. Add the name (i.e. git) and server configuration from below, and make sure to hit the Install button

{
  "command": "uvx",
  "args": ["mcp-server-git", "--repository", "path/to/git/repo"]
}

Debugging

You can use the MCP inspector to debug the server. For uvx installations:

npx @modelcontextprotocol/inspector uvx mcp-server-git

Or if you've installed the package in a specific directory or are developing on it:

cd path/to/servers/src/git
npx @modelcontextprotocol/inspector uv run mcp-server-git

Running tail -n 20 -f ~/Library/Logs/Claude/mcp*.log will show the logs from the server and may help you debug any issues.

Development

If you are doing local development, there are two ways to test your changes:

  1. Run the MCP inspector to test your changes. See Debugging for run instructions.

  2. Test using the Claude desktop app. Add the following to your claude_desktop_config.json:

Docker

{
  "mcpServers": {
    "git": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "--mount",
        "type=bind,src=/Users/username/Desktop,dst=/projects/Desktop",
        "--mount",
        "type=bind,src=/path/to/other/allowed/dir,dst=/projects/other/allowed/dir,ro",
        "--mount",
        "type=bind,src=/path/to/file.txt,dst=/projects/path/to/file.txt",
        "mcp/git"
      ]
    }
  }
}

UVX

{
  "mcpServers": {
    "git": {
      "command": "uv",
      "args": [
        "--directory",
        "/<path to mcp-servers>/mcp-servers/src/git",
        "run",
        "mcp-server-git"
      ]
    }
  }
}

Build

Docker build:

cd src/git
docker build -t mcp/git .

License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

Available Tools

19 tools
git_addC

Adds file contents to the staging area

Inputs: files (required), repo_path (required).

git_branchC

List Git branches

Inputs: repo_path (required), branch_type (required), contains, not_contains.

git_checkoutC

Switches branches

Inputs: repo_path (required), branch_name (required).

git_cherry_pickC

Cherry-pick a commit to the current branch

Inputs: repo_path (required), commit_sha (required), no_commit.

git_commitC

Records changes to the repository

Inputs: message (required), repo_path (required).

git_create_branchC

Creates a new branch from an optional base branch

Inputs: repo_path (required), branch_name (required), base_branch.

git_diffC

Shows differences between branches or commits

Inputs: target (required), repo_path (required), context_lines.

git_diff_stagedC

Shows changes that are staged for commit

Inputs: repo_path (required), context_lines.

git_diff_unstagedB

Shows changes in the working directory that are not yet staged

Inputs: repo_path (required), context_lines.

git_fetchC

Fetch changes from remote repository

Inputs: remote (required), repo_path (required), branch, all_remotes.

git_initC

Initialize a new Git repository

Inputs: repo_path (required).

git_list_remotesC

List configured remotes

Inputs: repo_path (required), verbose.

git_logC

Shows the commit logs

Inputs: repo_path (required), max_count.

git_pullC

Pull changes from remote repository

Inputs: branch (required), remote (required), repo_path (required).

git_pushC

Push changes to remote repository

Inputs: branch (required), remote (required), repo_path (required), force.

git_resetC

Unstages all staged changes

Inputs: repo_path (required).

git_showC

Shows the contents of a commit

Inputs: revision (required), repo_path (required).

git_statusC

Shows the working tree status

Inputs: repo_path (required).

git_switch_createC

Switches to a new branch or creates it from an optional base branch

Inputs: repo_path (required), branch_name (required), base_branch.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 19 tools

    Disambiguation3/5

    Most tools are clearly distinct, but the branch-related tools overlap: git_switch_create, git_create_branch, and git_checkout can be confused depending on whether creation, switching, or both are intended. The descriptions help somewhat, but the boundaries between these operations are not crisp.

    Naming Consistency5/5

    All tools use a consistent git_ prefix followed by snake_case action names, matching standard Git command terminology. Even compound names like git_switch_create and git_diff_unstaged follow the same predictable pattern.

    Tool Count4/5

    With 19 tools, the server covers a broad but reasonable set of Git operations. The count is slightly above the typical 3-15 range, but not excessive for the scope of Git workflows.

    Completeness3/5

    Core operations like status, diff, add, commit, log, pull, push, fetch, branch, and checkout are covered. However, notable gaps remain, including merge, stash, tag management, branch deletion, and remote add/remove operations.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • 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
      Enables Git repository interaction and automation via LLMs, providing tools to read, search, and manipulate Git repositories.
      15
      72 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to perform full Git operations including branching, committing, pushing, stashing, rebasing, and more, with safety features and support for advanced workflows like Git Flow and LFS.
      1
      MIT