Skip to main content
Glama
Git MCP Server

Git MCP Server

by DanyelKirsch

Git MCP Server

A Model Context Protocol (MCP) server for Git operations that provides comprehensive Git functionality to MCP clients like Claude Desktop.

Features

  • Context-aware: Automatically detects the current project based on working directory

  • Comprehensive Git operations: status, branches, diffs, logs, file contents, commits, and more

  • Multi-project support: Works seamlessly across different project directories

  • Error handling: Proper MCP error responses

  • Branch management: Create, switch, and manage branches

  • Remote operations: Push, pull, and fetch from remote repositories

Related MCP server: mcp-git

Installation

npm install -g git-mcp-server

Option 2: Local Development Setup

  1. Clone and install:

    git clone https://github.com/yourusername/git-mcp-server.git
    cd git-mcp-server
    npm install
  2. Build the project:

    npm run build

Configuration

Claude Desktop

Add this server to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

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

Other MCP Clients

For other MCP clients, use the server binary directly:

git-mcp-server

The server will automatically use the current working directory as the Git repository context.

Usage

Once configured, you can use Git operations through your MCP client. The server automatically detects the Git repository in your current working directory.

Example Commands

Ask your MCP client (like Claude) to perform Git operations:

  • "What's the current git status?"

  • "Show me the diff with the main branch"

  • "Create a new branch called feature/new-feature"

  • "Commit these changes with message 'Fix bug in parser'"

  • "Push the current branch to origin"

Testing the Server

You can test the server manually from any Git repository:

cd /path/to/your/git/repo
git-mcp-server

Available Tools

Repository Information

  • git_status - Get current git status

  • git_current_branch - Get current branch name

  • git_staged_changes - Get staged changes

  • git_working_directory - Get current working directory info

File and History Operations

  • git_diff - Show diff between branches/commits

  • git_log - Get commit history

  • git_show_file - Show file contents at specific commit

Branch Operations

  • git_branches - List all branches

  • git_checkout - Switch to different branch or create new branch

Staging and Commit Operations

  • git_add - Add files to staging area

  • git_commit - Create commits with message and files

Remote Operations

  • git_pull - Pull changes from remote repository

  • git_fetch - Fetch changes from remote without merging

Repository Management

  • git_init - Initialize a new git repository

Prerequisites

  • Node.js 18+

  • npm or yarn

  • Git installed on your system

Contributing

  1. Fork the repository

  2. Create a feature branch

  3. Make your changes

  4. Add tests if applicable

  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Project Structure

git-mcp-server/
├── package.json          # Project dependencies and scripts
├── tsconfig.json         # TypeScript configuration
├── src/
│   └── index.ts         # Main server implementation
├── build/
│   └── index.js         # Compiled JavaScript (generated)
└── README.md            # This file

Development

  • npm run build - Build the TypeScript code

  • npm run dev - Watch mode for development

  • npm start - Run the built server

Available Tools

16 tools
git_addC

Add files to the staging area

Inputs: files, all.

git_branchesC

List all branches

Inputs: remote.

git_checkoutC

Switch to a different branch or create a new branch

Inputs: branch (required), create.

git_commitC

Create a new commit with the specified message and files

Inputs: message (required), files.

git_create_branchB

Create a new branch and switch to it (git checkout -b)

Inputs: branchName (required), startPoint.

git_current_branchA

Get the current branch name

Inputs: no named parameters.

git_diffC

Show diff between branches or commits

Inputs: target, staged.

git_fetchA

Fetch changes from remote repository without merging

Inputs: remote.

git_initC

Initialize a new git repository

Inputs: bare, initialBranch.

git_logC

Get commit history

Inputs: limit, oneline.

git_pullC

Pull changes from remote repository

Inputs: remote, branch.

git_pushC

Push changes to remote repository

Inputs: remote, branch, setUpstream.

git_show_fileC

Show contents of a file at a specific commit

Inputs: file (required), commit.

git_staged_changesB

Get the currently staged changes

Inputs: no named parameters.

git_statusB

Get the current git status of the repository

Inputs: no named parameters.

git_working_directoryB

Get the current working directory of the git server

Inputs: no named parameters.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 16 tools

    Disambiguation4/5

    Most tools have distinct purposes with clear boundaries, such as git_add for staging, git_commit for committing, and git_pull for fetching and merging. However, git_checkout and git_create_branch have overlapping functionality (both can create branches), which could cause slight confusion for an agent.

    Naming Consistency5/5

    All tool names follow a consistent git_verb_noun pattern, using snake_case throughout. This predictability makes it easy for agents to understand and select tools based on their names, with no deviations or mixed conventions.

    Tool Count4/5

    With 16 tools, the server is slightly heavy but reasonable for covering core Git operations like init, add, commit, push, pull, and branch management. It includes essential utilities but might benefit from consolidation, such as merging git_checkout and git_create_branch.

    Completeness5/5

    The tool set provides comprehensive coverage of Git workflows, including repository setup (git_init), staging (git_add), committing (git_commit), branching (git_branches, git_create_branch), remote operations (git_fetch, git_pull, git_push), and inspection (git_status, git_log, git_diff). No obvious gaps exist for typical agent tasks.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • 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