Skip to main content

git-mcp-server: A git MCP server

This repo was extracted from the excellent examples at https://github.com/modelcontextprotocol/servers/tree/main/src/git and extended to add additional git commands, like pull and fetch

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 git-mcp-server 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 with optional date filtering
    • Inputs:
      • repo_path (string): Path to Git repository
      • max_count (number, optional): Maximum number of commits to show (default: 10)
      • start_timestamp (string, optional): Start timestamp for filtering commits. Accepts ISO 8601 format (e.g., '2024-01-15T14:30:25'), relative dates (e.g., '2 weeks ago', 'yesterday'), or absolute dates (e.g., '2024-01-15', 'Jan 15 2024')
      • end_timestamp (string, optional): End timestamp for filtering commits. Accepts ISO 8601 format (e.g., '2024-01-15T14:30:25'), relative dates (e.g., '2 weeks ago', 'yesterday'), or absolute dates (e.g., '2024-01-15', 'Jan 15 2024')
    • 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
      • start_point (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_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_push
  • Perform a git push
  • Inputs:
    • repo_path (string): Path to the Git repository.
    • remote_name (string): name of the remote to push to.
    • branch_name (string): the name of the branch to push
  • Returns: Confirmation of successful push or error.

Installation

Using uv (recommended)

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

Using PIP

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

pip install git-mcp-server

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

python -m git_mcp_server

Configuration

Usage with Claude Desktop

Add this to your claude_desktop_config.json:

Using uvx
"mcpServers": {
  "git": {
    "command": "uvx",
    "args": ["git-mcp-server", "--repository", "path/to/git/repo"]
  }
}
Using docker
  • Note: replace '/Users/username' with the a path that you want to be accessible by this tool
"mcpServers": {
  "git": {
    "command": "docker",
    "args": ["run", "--rm", "-i", "--mount", "type=bind,src=/Users/username,dst=/Users/username", "mcp/git"]
  }
}
Using pip installation
"mcpServers": {
  "git": {
    "command": "python",
    "args": ["-m", "git_mcp_server", "--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, you can configure the MCP server using one of these methods:

Method 1: User Configuration (Recommended) Add the configuration to your user-level MCP configuration file. Open the Command Palette (Ctrl + Shift + P) and run MCP: Open User Configuration. This will open your user mcp.json file where you can add the server configuration.

Method 2: Workspace Configuration Alternatively, you can add the configuration to a file called .vscode/mcp.json in your workspace. This will allow you to share the configuration with others.

For more details about MCP configuration in VS Code, see the official VS Code MCP documentation.

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

For Docker installation:

{
  "mcp": {
    "servers": {
      "git": {
        "command": "docker",
        "args": [
          "run",
          "--rm",
          "-i",
          "--mount", "type=bind,src=${workspaceFolder},dst=/workspace",
          "mcp/git"
        ]
      }
    }
  }
}

Usage with Zed

Add to your Zed settings.json:

Using uvx
"context_servers": [
  "git-mcp-server": {
    "command": {
      "path": "uvx",
      "args": ["git-mcp-server"]
    }
  }
],
Using pip installation
"context_servers": {
  "git-mcp-server": {
    "command": {
      "path": "python",
      "args": ["-m", "git_mcp_server"]
    }
  }
},

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
Using uvx
{
    "command": "uvx",
    "args": ["git-mcp-server", "--repository", "path/to/git/repo"]
}

Debugging

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

npx @modelcontextprotocol/inspector uvx git-mcp-server

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 git-mcp-server

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",
      "git-mcp-server"
    ]
    }
  }
}

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.

Release files for git-mcps 0.7.2

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

Source distribution (sdist)

Source distribution for git-mcps 0.7.2
File Size Uploaded
git_mcps-0.7.2.tar.gz 47.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for git-mcps 0.7.2
File Interpreter ABI Platform
git_mcps-0.7.2-py3-none-any.whl Python 3 none any Details

Total release size: 57.5 kB

Release files / git_mcps-0.7.2.tar.gz

Download URL git_mcps-0.7.2.tar.gz
Size 47.3 kB
Tags Source
SHA-256 checksum
How to use checksums
edcea09067c539bafcbb48f44efee5aba780a69909069dd9b96952c8b98aa37d
BLAKE2b-256 checksum
How to use checksums
f4c21665578896d5bb502ddf0f7c501d841db4e32d0cc2ca74f5157f956824dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release files / git_mcps-0.7.2-py3-none-any.whl

Download URL git_mcps-0.7.2-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cbdfda1de242f870add770a39d08f967d37efd883b1a410f480f1986e9f09b79
BLAKE2b-256 checksum
How to use checksums
4387ebf3e85c94e820cce20f9448f995d3d271f6d979c7b921478f9c936f53de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release history Release notifications | RSS feed

This release

0.7.2 This release

2 release files

0.7.1

2 release files

0.7.0

2 release files

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