Sponsored by Deepsite.site

Git MCP Server

Created By
MCP-Mirrora year ago
Mirror of
Content

Git MCP Server

TypeScript Model Context Protocol License Status

A Model Context Protocol server that provides comprehensive Git functionality to Large Language Models, enabling them to perform version control operations through a secure and standardized interface.

Table of Contents

Overview

Model Context Protocol Server

The Git MCP Server implements the Model Context Protocol (MCP), created by Anthropic, which provides a standardized communication protocol between LLMs and external systems. The architecture consists of:

  • Clients (Claude Desktop, IDEs) that maintain server connections
  • Servers that provide tools and resources to clients
  • LLMs that interact with servers through client applications

This architecture creates a secure boundary between LLMs and external systems while enabling controlled access to Git functionality. Through the MCP protocol, the Git server empowers LLMs to perform version control operations, manage repositories, and handle complex Git workflows — all within a secure and validated environment.

Features

Core Git Operations

  • Repository initialization and cloning
  • File staging and committing
  • Branch management
  • Remote operations
  • Tag handling
  • Stash management

Bulk Operations

  • Sequential operation execution
  • Atomic commits
  • Smart defaults
  • Error resilience

Safety Features

  • Path validation
  • Repository state verification
  • Embedded repository handling
  • Comprehensive error reporting

Installation

Setup Steps

  1. Clone the repository:
git clone https://github.com/cyanheads/git-mcp-server.git
  1. Navigate to the project directory:
cd git-mcp-server
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

The server is now ready to be configured and used with your MCP client.

Configuration

The Git MCP Server requires configuration in your MCP client settings:

{
  "mcpServers": {
    "git": {
      "command": "node",
      "args": ["/path/to/git-mcp-server/build/index.js"],
      "env": {
        "GIT_DEFAULT_PATH": "/optional/default/path/for/git/operations"
      }
    }
  }
}

Environment Variables

VariableDescriptionRequired
GIT_DEFAULT_PATHDefault path for Git operationsNo

Path Requirements

All paths must be absolute. For example:

  • Repository path: /Users/username/projects/my-repo
  • File paths: /Users/username/projects/my-repo/src/file.js

Tools

Basic Operations

init

Initializes a new Git repository.

{
  "path": string  // Path to initialize
}

clone

Clones a repository.

{
  "url": string,  // Repository URL (required)
  "path": string  // Clone destination
}

status

Gets repository status.

{
  "path": string  // Repository path
}

Bulk Operations

bulk_action

Executes multiple Git operations in sequence. This is the preferred way to execute multiple operations.

{
  "path": string,     // Repository path
  "actions": [        // Array of operations to execute
    {
      "type": "stage",
      "files": string[]  // Optional - if omitted, stages all changes
    },
    {
      "type": "commit",
      "message": string
    },
    {
      "type": "push",
      "branch": string,
      "remote": string   // Optional - defaults to "origin"
    }
  ]
}

Branch Operations

branch_list, branch_create, branch_delete, checkout

Manage branches and working tree.

Tag Operations

tag_list, tag_create, tag_delete

Manage repository tags.

Remote Operations

remote_list, remote_add, remote_remove

Manage remote repositories.

Stash Operations

stash_list, stash_save, stash_pop

Manage working directory changes.

Best Practices

Path Management

  • Always use absolute paths
  • Validate paths before operations
  • Handle embedded repositories properly

Bulk Operations

  • Use bulk_action for multiple operations
  • Handle operation dependencies correctly
  • Provide clear commit messages

Error Handling

  • Check operation results
  • Handle partial success scenarios
  • Validate repository state

Development

# Build the project
npm run build

# Watch for changes
npm run watch

# Run MCP inspector
npm run inspector

Error Handling

The server provides detailed error information:

  • Invalid paths or arguments
  • Git command failures
  • Repository state errors
  • Permission issues

Contributing

I welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

For bugs and feature requests, please create an issue.

License

Apache License 2.0


Built with the Model Context Protocol
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Playwright McpPlaywright MCP server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
RedisA Model Context Protocol server that provides access to Redis databases. This server enables LLMs to interact with Redis key-value stores through a set of standardized tools.
WindsurfThe new purpose-built IDE to harness magic
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
ChatWiseThe second fastest AI chatbot™
DeepChatYour AI Partner on Desktop
Amap Maps高德地图官方 MCP Server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Tavily Mcp
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Serper MCP ServerA Serper MCP Server
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
CursorThe AI Code Editor
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.