home / mcp / git mcp server

Git MCP Server

Provides Git operations via MCP for AI assistants, including clone, status, add, commit, push, pull, branch and stash management.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "sheshiyer-git-mcp-v2": {
      "command": "node",
      "args": [
        "path/to/git-mcp-v2/build/index.js"
      ],
      "env": {
        "GIT_DEFAULT_PATH": "\\/path\\/to\\/default\\/git\\/directory",
        "GITHUB_PERSONAL_ACCESS_TOKEN": "your-github-pat"
      }
    }
  }
}

You can run a dedicated MCP server that exposes a full suite of Git operations through a standardized MCP interface. This makes it easy for AI assistants to manage repositories, branches, remotes, stashes, and more with consistent, automated commands.

How to use

You interact with the Git MCP Server through an MCP client. Use it to initialize repositories, clone or pull changes, check status, add and commit changes, push to remotes, and pull updates from remotes. Manage branches and tags, configure remotes, and handle work-in-progress with stash operations. You can also execute multiple operations in sequence to automate common workflows and integrate Git with GitHub using a Personal Access Token.

Typical usage patterns include creating a new repository in a chosen directory, cloning existing projects, and performing routine maintenance like checking status, staging changes, committing with messages, and syncing with a remote. You can list, create, or delete branches, switch between them, and manage tags. Remotes can be listed, added, or removed, and stash operations allow you to save and apply work cleanly.

How to install

Prerequisites: ensure you have Node.js installed on your system. You will also need a working shell environment to run commands.

Step 1: Clone the server repository to your workstation.

Step 2: Install dependencies.

Step 3: Build the project before you start it.

Step 4: Start the server using the standard MCP runtime command shown in the configuration example.

Configuration and notes

Configure the MCP server by adding an entry to your MCP settings that points to the local runtime of the server. The following example shows how to run the server locally with Node and the built index file, including environment variables for default paths and GitHub authentication.

{
  "mcpServers": {
    "git_v2": {
      "type": "stdio",
      "command": "node",
      "args": ["path/to/git-mcp-v2/build/index.js"],
      "env": {
        "GIT_DEFAULT_PATH": "/path/to/default/git/directory",
        "GITHUB_PERSONAL_ACCESS_TOKEN": "your-github-pat"
      }
    }
  }
}

Environment variables

GIT_DEFAULT_PATH: Optional default path for Git operations. GITHUB_PERSONAL_ACCESS_TOKEN: Optional GitHub Personal Access Token for GitHub operations.

Available tools

init

Initialize a new Git repository in the current directory, creating the .git folder and initial metadata.

clone

Clone a repository to a new directory, fetching all branches and tags.

status

Show the working tree status including staged and unstaged changes.

add

Stage changes by adding file paths to the index for the next commit.

commit

Record changes to the repository with a message describing the commit.

push

Push committed changes to a remote repository along with associated branches.

pull

Fetch and integrate changes from a remote repository into your current branch.

branch_list

List all branches in the current repository.

branch_create

Create a new branch from the current HEAD or a specified base.

branch_delete

Delete a local branch.

checkout

Switch to another branch or restore working tree files from a commit.

tag_list

List all tags in the repository.

tag_create

Create a new tag pointing at a commit.

tag_delete

Delete an existing tag.

remote_list

List all configured remotes for the repository.

remote_add

Add a new remote with a name and URL.

remote_remove

Remove an existing remote by name.

stash_list

List all stashes saved in the repository.

stash_save

Save current changes to a new stash.

stash_pop

Apply the latest stash and remove it from the stash list.

bulk_action

Execute multiple Git operations in sequence as a single workflow.