Skip to main content
Glama

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

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

Install Server
A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

Node.js server implementing Model Context Protocol for git operations, enabling AI assistants to manage git repositories through natural language commands.

  1. Features
    1. API
      1. git_clone
      2. git_status
      3. git_pull
      4. git_push
      5. git_commit
      6. git_checkout
      7. git_log
      8. git_branch
      9. git_add
      10. git_init
      11. git_remote
    2. Error Handling
      1. Installation
        1. Usage
          1. Testing
            1. Docker
              1. Development
                1. Using with Cursor AI Chat
                  1. License

                    Related MCP Servers

                    • -
                      security
                      A
                      license
                      -
                      quality
                      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.
                      Last updated -
                      12
                      61,341
                      TypeScript
                      MIT License
                    • A
                      security
                      A
                      license
                      A
                      quality
                      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.
                      Last updated -
                      21
                      1,285
                      97
                      TypeScript
                      Apache 2.0
                    • A
                      security
                      F
                      license
                      A
                      quality
                      A Model Context Protocol server that enables AI models to interact with GitHub's API, allowing for repository creation and management with descriptions, topics, and website URLs through natural language commands.
                      Last updated -
                      1
                      JavaScript
                    • -
                      security
                      F
                      license
                      -
                      quality
                      A Model Context Protocol server that enables AI assistants to perform GitHub operations including repository management, file operations, issue tracking, and pull request creation.
                      Last updated -
                      1
                      TypeScript

                    View all related MCP servers

                    MCP directory API

                    We provide all the information about MCP servers via our MCP API.

                    curl -X GET 'https://glama.ai/api/mcp/v1/servers/markheramis/mcp-git'

                    If you have feedback or need assistance with the MCP directory API, please join our Discord server