Skip to main content
Glama
MCP Git Server

MCP Git Server

by mpfilbin

MCP Git Server

A Model Context Protocol (MCP) server that exposes Git operations as tools for use with GitHub Copilot in VS Code or IntelliJ IDEA.

Features

This MCP server provides comprehensive Git functionality through a standard set of tools:

Repository Management

  • git_status - Show working tree status

  • git_init - Initialize a new repository

  • git_clone - Clone a repository

Branch Operations

  • git_branch_list - List all branches

  • git_branch_create - Create a new branch

  • git_branch_delete - Delete a branch

  • git_checkout - Switch branches or restore files

  • git_merge - Merge branches

File Operations

  • git_diff - Show changes between commits, working tree, etc.

  • git_add - Stage files

  • git_reset - Unstage files

  • git_restore - Restore working tree files

Commit Operations

  • git_commit - Record changes to the repository

  • git_log - Show commit logs

  • git_show - Show commit details

Advanced Operations

  • git_rebase - Reapply commits on top of another base

  • git_stash - Stash changes

  • git_stash_pop - Apply stashed changes

  • git_stash_list - List stashed changes

  • git_cherry_pick - Apply a commit to current branch

Remote Operations

  • git_remote_list - List remotes

  • git_remote_add - Add a new remote

  • git_fetch - Download objects and refs from remote

  • git_pull - Fetch and merge from remote

  • git_push - Update remote refs

Related MCP server: Gitrama MCP Server

Installation

  1. Go to the Releases page of this repository

  2. Download the latest git-mcp_X_Y_Z.zip file

  3. Extract the zip file to a directory of your choice:

    # Example: extract to ~/mcp-servers/git
    mkdir -p ~/mcp-servers/git
    unzip git-mcp_1_0_0.zip -d ~/mcp-servers/git
  4. Note the path to the extracted index.js file (e.g., ~/mcp-servers/git/index.js)

  5. Skip to the Usage section below to configure your IDE

Option 2: Building from Source

If you want to modify the code or contribute to development:

  1. Clone or download this repository

  2. Install dependencies:

    npm install
  3. Build the TypeScript code:

    npm run build

    The build process uses esbuild to create a single bundled file that includes all dependencies. This means:

    • No node_modules folder is needed for the built version

    • The entire application is contained in dist/index.js (plus source maps)

    • Easy to distribute and deploy

Usage

With GitHub Copilot

VS Code

  1. Ensure you have the latest version of VS Code with GitHub Copilot extension installed.

  2. Configure the MCP server by creating or updating your MCP settings. The location depends on your setup:

    • User settings: ~/.config/Code/User/globalStorage/github.copilot-chat/mcp.json

    • Or through VS Code settings UI

  3. Add this server to your mcp.json:

    For downloaded release:

    {
      "mcpServers": {
        "git": {
          "command": "node",
          "args": ["/Users/yourusername/mcp-servers/git/index.js"]
        }
      }
    }

    For source build:

    {
      "mcpServers": {
        "git": {
          "command": "node",
          "args": ["/absolute/path/to/mcp-git-server/dist/index.js"]
        }
      }
    }

    Note: Use the absolute path to wherever you extracted the release or built the project.

  4. Restart VS Code or reload the window.

IntelliJ IDEA

  1. Ensure you have the latest version of IntelliJ IDEA with GitHub Copilot plugin installed.

  2. Configure MCP servers in IntelliJ settings:

    • Go to Settings → Tools → GitHub Copilot → MCP Servers

    • Add a new server configuration

  3. Add the server with:

    • Name: git

    • Command: node

    • Arguments:

      • For downloaded release: /Users/yourusername/mcp-servers/git/index.js

      • For source build: /absolute/path/to/mcp-git-server/dist/index.js

    Note: Use the absolute path to wherever you extracted the release or built the project.

  4. Restart IntelliJ IDEA.

Standalone Usage

You can also run the server standalone and communicate with it via stdio:

npm start

Tool Usage Examples

All tools accept an optional repoPath parameter. If not provided, the current working directory is used.

Check status

{
  "name": "git_status",
  "arguments": {
    "repoPath": "/path/to/repo"  // optional
  }
}

Stage files

{
  "name": "git_add",
  "arguments": {
    "files": ["src/index.ts", "README.md"]
  }
}

Create and checkout a new branch

{
  "name": "git_checkout",
  "arguments": {
    "ref": "feature/new-feature",
    "createBranch": true
  }
}

Commit changes

{
  "name": "git_commit",
  "arguments": {
    "message": "Add new feature",
    "files": ["src/feature.ts"]  // optional, will stage these files first
  }
}

View commit log

{
  "name": "git_log",
  "arguments": {
    "maxCount": 10  // optional
  }
}

Push to remote

{
  "name": "git_push",
  "arguments": {
    "remote": "origin",
    "branch": "main",
    "setUpstream": true  // optional
  }
}

Response Format

All tools return a consistent response format:

{
  "success": boolean,      // true if operation succeeded
  "message": string,       // human-readable message
  "data": any             // optional additional data
}

Example Success Response

{
  "success": true,
  "message": "Staged 2 file(s): src/index.ts, README.md"
}

Example Error Response

{
  "success": false,
  "message": "Failed to stage files: pathspec 'nonexistent.txt' did not match any files"
}

Development

Build

Build the project using esbuild (bundles all dependencies):

npm run build

This creates:

  • dist/index.js - Bundled application with all dependencies included

  • dist/index.js.map - Source map for debugging

  • dist/package.json - Minimal package.json for the distribution

The bundled output is self-contained and doesn't require node_modules to run.

Build Type Definitions Only

If you need just TypeScript type definitions:

npm run build:types

Watch Mode

For development with auto-rebuild on changes:

npm run watch

Note: This uses TypeScript's watch mode, not esbuild bundling.

Clean

Remove build artifacts and release archives:

npm run clean

This removes:

  • dist/ directory

  • All git-mcp_*.zip files

Release Process

This project includes a release script that automates version bumping, building, and publishing to GitHub releases.

Prerequisites

  1. GitHub Personal Access Token: You need a GitHub personal access token with repo scope.

    To create one:

    • Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)

    • Click "Generate new token (classic)"

    • Select the repo scope (full control of private repositories)

    • Generate and copy the token

  2. Set the token as an environment variable:

    export GHE_TOKEN="your_github_token_here"

    For persistence, add it to your ~/.zshrc or ~/.bashrc:

    echo 'export GHE_TOKEN="your_token"' >> ~/.zshrc
    source ~/.zshrc

Running a Release

Execute the release script from the project root:

./bin/release

The script will:

  1. Prompt for version bump type:

    • Option 1: Major version (breaking changes) - e.g., 1.0.0 → 2.0.0

    • Option 2: Minor version (new features) - e.g., 1.0.0 → 1.1.0

    • Option 3: Patch version (bug fixes) - e.g., 1.0.0 → 1.0.1

  2. Update package.json with the new version

  3. Clean previous build artifacts using npm run clean

  4. Build the project using npm run build

  5. Create a zip archive named git-mcp_{major}_{minor}_{patch}.zip containing the dist/ folder

  6. Create a GitHub release with tag v{version}

  7. Upload the zip file as a release asset

After Release

The script will remind you to commit and push the updated package.json:

git add package.json
git commit -m 'Bump version to X.Y.Z'
git push origin master

Notes

  • The script supports both GitHub.com and GitHub Enterprise

  • It automatically detects your repository from the git remote

  • The script will exit with an error if any step fails

Project Structure

mcp-git-server/
├── src/
│   ├── index.ts        # Main server entry point
│   ├── git-tools.ts    # Git operation implementations
│   └── types.ts        # TypeScript type definitions
├── dist/               # Compiled JavaScript output
├── package.json
├── tsconfig.json
└── README.md

Requirements

  • Node.js 18 or higher

  • Git installed and available in PATH

  • GitHub Copilot (for integration with VS Code or IntelliJ)

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Available Tools

25 tools
git_add

Add file contents to the staging area

Inputs: files (required), repoPath.

git_branch_create

Create a new branch

Inputs: branchName (required), repoPath.

git_branch_delete

Delete a branch

Inputs: branchName (required), force, repoPath.

git_branch_list

List all branches in the repository

Inputs: repoPath.

git_checkout

Switch branches or restore working tree files

Inputs: ref (required), repoPath, createBranch.

git_cherry_pick

Apply the changes introduced by an existing commit

Inputs: commit (required), repoPath.

git_clone

Clone a repository from a URL

Inputs: url (required), repoPath, targetPath.

git_commitC

Record changes to the repository

Inputs: message (required), amend, files, repoPath.

git_diff

Show changes between commits, commit and working tree, etc. Supports commit ranges like HEAD...origin/master

Inputs: files, cached, repoPath, toCommit, +2 more.

git_fetch

Download objects and refs from another repository

Inputs: branch, remote, repoPath.

git_init

Initialize a new git repository

Inputs: repoPath.

git_log

Show commit logs

Inputs: file, maxCount, repoPath.

git_merge

Merge a branch into the current branch

Inputs: branch (required), repoPath, noFastForward.

git_pull

Fetch from and integrate with another repository or local branch

Inputs: branch, rebase, remote, repoPath.

git_push

Update remote refs along with associated objects

Inputs: force, branch, remote, repoPath, +1 more.

git_rebase

Reapply commits on top of another base tip

Inputs: branch (required), repoPath, interactive.

git_remote_add

Add a new remote

Inputs: url (required), name (required), repoPath.

git_remote_list

List all configured remotes

Inputs: repoPath.

git_reset

Unstage files or reset current HEAD to specified state

Inputs: mode, files, commit, repoPath.

git_restore

Restore working tree files

Inputs: files (required), staged, repoPath.

git_showC

Show details of a commit

Inputs: ref, repoPath.

git_stash

Stash the changes in a dirty working directory

Inputs: message, repoPath, includeUntracked.

git_stash_list

List all stashed changes

Inputs: repoPath.

git_stash_pop

Apply stashed changes and remove them from stash list

Inputs: index, repoPath.

git_status

Show the working tree status including modified, staged, and untracked files

Inputs: repoPath.

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • 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
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides 15 MCP tools for AI-powered Git intelligence, enabling commit messages, branch creation, PR descriptions, code review, diff analysis, and push operations directly from your AI assistant.
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A complete Git CLI wrapper for the Model Context Protocol (MCP), enabling AI assistants to perform all git operations through MCP tools.
      MIT