git.com
git.com logo

Git

Integrates with Git repositories using simple-git to enable core version control operations like cloning, committing, an...

Created byApr 22, 2025

GIT MCP Server

A Model Context Protocol (MCP) server that provides tools for interacting with Git repositories. This server allows AI assistants and LLM agents to manage repositories, branches, commits, and files through a standardized interface without requiring direct filesystem or command-line access. It exposes Git operations as MCP resources and tools, leveraging the simple-git library for core functionality while maintaining proper security boundaries.

Table of Contents

  • Overview
  • Features
  • Installation
  • Usage
  • Project Structure
  • Tools
  • Resources
  • Development
  • License

Overview

Key capabilities:
  • Repository Management: Initialize, clone, and check repository status
  • Branch Operations: Create, list, checkout, delete, and merge branches
  • Working Directory: Stage files, commit changes, create diffs
  • Remote Operations: Add remotes, fetch, pull, push
  • Advanced Git Commands: Manage tags, stash changes, cherry-pick, rebase

Architecture & Components

Core system architecture:
Core Components:
  • MCP Server (`server.ts`): Uses the @modelcontextprotocol/sdk to create a server exposing resources and tools.
  • Git Service (`services/git-service.ts`): Abstraction layer over the simple-git library providing clean interfaces for Git operations.
  • Resources (`resources/`): Expose Git data (like status, logs, file content) through MCP resources with consistent URI templates.
  • Tools (`tools/`): Expose Git actions (like commit, push, pull) through MCP tools with well-defined input schemas (validated using Zod).
  • Error Handling (`services/error-service.ts`): Standardized error handling and reporting for Git and MCP operations.
  • Entry Point (`index.ts`): Initializes and starts the server, connecting it to the standard I/O transport.

Features

Resource Access

Expose Git repository information through MCP resources:
  • Repository Information: Access basic Git repository information including current branch, status, and reference details
  • Repository Branches: List all branches in the repository with current branch indicator
  • Repository Remotes: List all configured remote repositories with their URLs
  • Repository Tags: List all tags in the repository with their references
  • File Content: Access content of specific files at a given Git reference
  • Directory Listing: View lists of files and directories at a specific path and reference
  • Diffs: Get differences between references, unstaged changes, or staged changes
  • Commit History: View detailed commit logs with author, date, and message information
  • File Blame: See line-by-line attribution showing which commit last modified each line
  • Commit Details: Access detailed information about specific commits including diff changes

Git Operations

Execute Git commands through MCP tools:
  • Repository Operations: Initialize repositories, clone from remotes, check repository status
  • Branch Operations: Create branches, list branches, checkout, delete branches, merge
  • Working Directory Operations: Stage files, unstage files, commit changes, create diffs
  • Remote Operations: Add remotes, list remotes, fetch, pull, push
  • Advanced Operations: Manage tags, stash changes, cherry-pick commits, rebase branches, reset, clean

Installation

Prerequisites

  • Node.js 16 or higher
  • Git installed and available in the PATH

Install from NPM

Install from Source

Usage

Running the Server

If installed globally via NPM:
If running from source:
The server communicates through stdin/stdout using the Model Context Protocol, making it compatible with any MCP client.

Integration with Claude

Add to your Claude configuration file (e.g., cline_mcp_settings.json or claude_desktop_config.json):

Integration with Other MCP Clients

Use the MCP inspector to test the server:

Project Structure

The codebase follows a modular structure:
Note: Code block was split into 2 parts due to size limits.

Tools

Git MCP Server provides a comprehensive suite of tools for Git operations:

Repository Operations

[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]

Branch Operations

[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]

Working Directory Operations

[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]

Remote Operations

[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]

Advanced Operations

[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]

Resources

Git MCP Server exposes Git data through standard MCP resources:

Repository Resources

[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]

Development

Build and Test

License

Apache License 2.0 - See LICENSE for details.

GIT MCP Server

A Model Context Protocol (MCP) server that provides tools for interacting with Git repositories. This server allows AI assistants and LLM agents to manage repositories, branches, commits, and files through a standardized interface without requiring direct filesystem or command-line access. It exposes Git operations as MCP resources and tools, leveraging the simple-git library for core functionality while maintaining proper security boundaries.

Table of Contents

  • Overview
  • Features
  • Installation
  • Usage
  • Project Structure
  • Tools
  • Resources
  • Development
  • License

Overview

Key capabilities:
  • Repository Management: Initialize, clone, and check repository status
  • Branch Operations: Create, list, checkout, delete, and merge branches
  • Working Directory: Stage files, commit changes, create diffs
  • Remote Operations: Add remotes, fetch, pull, push
  • Advanced Git Commands: Manage tags, stash changes, cherry-pick, rebase

Architecture & Components

Core system architecture:
Core Components:
  • MCP Server (`server.ts`): Uses the @modelcontextprotocol/sdk to create a server exposing resources and tools.
  • Git Service (`services/git-service.ts`): Abstraction layer over the simple-git library providing clean interfaces for Git operations.
  • Resources (`resources/`): Expose Git data (like status, logs, file content) through MCP resources with consistent URI templates.
  • Tools (`tools/`): Expose Git actions (like commit, push, pull) through MCP tools with well-defined input schemas (validated using Zod).
  • Error Handling (`services/error-service.ts`): Standardized error handling and reporting for Git and MCP operations.
  • Entry Point (`index.ts`): Initializes and starts the server, connecting it to the standard I/O transport.

Features

Resource Access

Expose Git repository information through MCP resources:
  • Repository Information: Access basic Git repository information including current branch, status, and reference details
  • Repository Branches: List all branches in the repository with current branch indicator
  • Repository Remotes: List all configured remote repositories with their URLs
  • Repository Tags: List all tags in the repository with their references
  • File Content: Access content of specific files at a given Git reference
  • Directory Listing: View lists of files and directories at a specific path and reference
  • Diffs: Get differences between references, unstaged changes, or staged changes
  • Commit History: View detailed commit logs with author, date, and message information
  • File Blame: See line-by-line attribution showing which commit last modified each line
  • Commit Details: Access detailed information about specific commits including diff changes

Git Operations

Execute Git commands through MCP tools:
  • Repository Operations: Initialize repositories, clone from remotes, check repository status
  • Branch Operations: Create branches, list branches, checkout, delete branches, merge
  • Working Directory Operations: Stage files, unstage files, commit changes, create diffs
  • Remote Operations: Add remotes, list remotes, fetch, pull, push
  • Advanced Operations: Manage tags, stash changes, cherry-pick commits, rebase branches, reset, clean

Installation

Prerequisites

  • Node.js 16 or higher
  • Git installed and available in the PATH

Install from NPM

Install from Source

Usage

Running the Server

If installed globally via NPM:
If running from source:
The server communicates through stdin/stdout using the Model Context Protocol, making it compatible with any MCP client.

Integration with Claude

Add to your Claude configuration file (e.g., cline_mcp_settings.json or claude_desktop_config.json):

Integration with Other MCP Clients

Use the MCP inspector to test the server:

Project Structure

The codebase follows a modular structure:
Note: Code block was split into 2 parts due to size limits.

Tools

Git MCP Server provides a comprehensive suite of tools for Git operations:

Repository Operations

[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]

Branch Operations

[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]

Working Directory Operations

[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]

Remote Operations

[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]

Advanced Operations

[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]

Resources

Git MCP Server exposes Git data through standard MCP resources:

Repository Resources

[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]

Development

Build and Test

License

Apache License 2.0 - See LICENSE for details.