Skip to main content
Glama
GIT MCP Server

GIT MCP Server

by markheramis

GIT MCP Server

Node.js server implementing Model Context Protocol (MCP) for git operations.

Features

  • Git repository management through MCP protocol

  • Support for common Git operations

  • Type-safe command execution with Zod schema validation

  • Robust error handling with detailed git error messages

  • Comprehensive test suite covering all operations

Related MCP server: git-mcp-server

API

The server provides the following Git operations:

git_clone

Clone a git repository to a local directory.

{
    repository: string;    // Git repository URL to clone
    directory?: string;    // Target directory for the repository
    branch?: string;       // Branch to checkout
}

git_status

Get the status of a git repository, showing changed files and branch information.

{
    repository_path: string;  // Path to the git repository
}

git_pull

Pull changes from a remote repository into your local repository.

{
    repository_path: string;  // Path to the git repository
    remote?: string;         // Remote name
    branch?: string;         // Branch name
}

git_push

Push local changes to a remote repository.

{
    repository_path: string;  // Path to the git repository
    remote?: string;         // Remote name
    branch?: string;         // Branch name
}

git_commit

Commit changes to the repository with a message.

{
    repository_path: string;  // Path to the git repository
    message: string;         // Commit message
    add_all?: boolean;       // Add all files before committing
}

git_checkout

Checkout a branch or specific commit.

{
    repository_path: string;  // Path to the git repository
    branch: string;          // Branch or commit to checkout
    create?: boolean;        // Create new branch if it does not exist
}

git_log

Show commit history.

{
    repository_path: string;  // Path to the git repository
    count?: number;          // Number of commits to show
}

git_branch

List all branches in the repository.

{
    repository_path: string;  // Path to the git repository
    show_remote?: boolean;   // Show remote branches as well
}

git_add

Add files to the staging area.

{
    repository_path: string;  // Path to the git repository
    files: string[];         // Files to add to the staging area
}

git_init

Initialize a new git repository.

{
    repository_path: string;  // Path for the new git repository
    bare?: boolean;          // Create a bare repository
}

git_remote

Manage remote repositories.

{
    repository_path: string;  // Path to the git repository
    action: 'add' | 'remove' | 'set-url' | 'list';  // Action to perform on remote
    name?: string;           // Name of the remote
    url?: string;            // URL of the remote repository
}

Error Handling

The server provides robust error handling for git operations:

  • All git commands are executed with proper error capturing

  • Error messages are cleaned and formatted for improved readability

  • Specific git error patterns are detected and extracted from command output

  • Each tool returns structured error responses with isError: true flag

  • Errors include descriptive messages that match standard git error formats

Installation

npm install
npm run build

Usage

The server can be run using:

npm start

Or directly using the built executable:

./dist/index.js

Testing

The project includes a comprehensive test suite that verifies all git operations work correctly. To run the tests:

npm test

The tests:

  • Create a temporary git repository

  • Test the full git workflow (clone, branch, add, commit, etc.)

  • Verify proper error handling for invalid operations

  • Clean up resources after test execution

For continuous test development, you can also use:

npm run test:watch

Docker

A Docker image is available for easy deployment:

docker build -t mcp-git .
docker run mcp-git

Development

npm run dev  # Start development mode with watch
npm run build  # Build the project

Using with Cursor AI Chat

For detailed instructions on using this Git MCP server with Cursor's AI assistant, please see using with cursor.

License

MIT

Available Tools

11 tools
git_addD

Inputs: repository_path (required), files (required).

git_branchD

Inputs: repository_path (required), show_remote.

git_checkoutD

Inputs: repository_path (required), branch (required), create.

git_cloneD

Inputs: repository (required), directory, branch.

git_commitD

Inputs: repository_path (required), message (required), add_all.

git_initD

Inputs: repository_path (required), bare.

git_logD

Inputs: repository_path (required), count.

git_pullD

Inputs: repository_path (required), remote, branch.

git_pushD

Inputs: repository_path (required), remote, branch.

git_remoteD

Inputs: repository_path (required), action (required), name, url.

git_statusD

Inputs: repository_path (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    C2.1/5.0

    Scored across 11 tools

    Disambiguation5/5

    Every tool corresponds to a distinct Git command with well-known, non-overlapping purposes in version control workflows. The lack of descriptions doesn't hinder disambiguation since these are standard Git operations that agents can reliably differentiate based on common knowledge.

    Naming Consistency5/5

    All tool names follow a perfectly consistent 'git_' prefix with the exact Git command name in lowercase, adhering to a uniform snake_case pattern throughout. This predictability makes it easy for agents to understand and use the toolset without confusion.

    Tool Count5/5

    With 11 tools, this server covers essential Git operations for basic repository management, which is well-scoped and typical for a Git-focused MCP server. Each tool represents a core Git command that earns its place in the set, avoiding bloat or thin coverage.

    Completeness4/5

    The toolset provides strong coverage of fundamental Git workflows, including repository setup (init, clone), changes (add, commit, status), branching (branch, checkout), and synchronization (pull, push, remote). Minor gaps exist, such as missing tools for advanced operations like git merge, git rebase, or git stash, but core functionality is well-covered for most agent tasks.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      B
      maintenance
      A Model Context Protocol server for Git repository interaction and automation. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.
      14
      115,976 PyPI
      92,301
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      A Model Context Protocol server that enables Large Language Models to interact with Git repositories through a robust API, supporting operations like repository initialization, cloning, file staging, committing, and branch management.
      28
      6,847 npm
      246
      Apache 2.0
    • A
      license
      B
      quality
      D
      maintenance
      A Model Context Protocol server that enables LLMs to interact with Git repositories, providing tools to read, search, and manipulate Git repositories through commands like status, diff, commit, and branch management.
      12
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      A Model Context Protocol server that provides Git version control operations as structured tools for AI coding agents. It enables LLMs to programmatically manage repositories through actions like committing changes, rolling back code, and comparing diffs.
      10
      Apache 2.0