git-mcp-server

eslamegy173/git-mcp-server

3.1

If you are the rightful owner of git-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Git MCP Server is a Flask-based server that provides a RESTful API for interacting with local Git repositories.

Git MCP Server

This is a simple Flask-based server that acts as a Multi-Capability Provider (MCP) for local git command-line operations. It exposes a set of RESTful API endpoints to allow an AI agent or any other script to interact with local Git repositories in a structured way.

Installation & Running

  1. Install dependencies:

    pip install -r requirements.txt
    
  2. Run the server:

    python main.py
    

    The server will run on http://localhost:8888 by default.


API Reference

/ping

  • Method: GET
  • Description: Checks if the server is alive.
  • Example:
    curl http://localhost:8888/ping
    

/git/clone

  • Method: POST
  • Description: Clones a remote repository to a local path.
  • Body (JSON):
    {
        "repo_url": "https://github.com/user/repo.git",
        "path": "/path/to/clone/into"
    }
    
  • Example:
    curl -X POST -H "Content-Type: application/json" -d '{"repo_url": "https://github.com/owner/repo.git", "path": "/data/data/com.termux/files/home/my-repo"}' http://localhost:8888/git/clone
    

/git/status

  • Method: POST
  • Description: Gets the status of a local repository using git status --porcelain.
  • Body (JSON):
    {
        "path": "/path/to/your/repo"
    }
    
  • Example:
    curl -X POST -H "Content-Type: application/json" -d '{"path": "/data/data/com.termux/files/home/my-repo"}' http://localhost:8888/git/status
    

/git/add

  • Method: POST
  • Description: Adds one or more files to the staging area.
  • Body (JSON):
    {
        "path": "/path/to/your/repo",
        "files": ["file1.txt", "src/file2.py"] // or ["."] to add all
    }
    
  • Example:
    curl -X POST -H "Content-Type: application/json" -d '{"path": "/data/data/com.termux/files/home/my-repo", "files": ["."]}' http://localhost:8888/git/add
    

/git/commit

  • Method: POST
  • Description: Commits the staged changes.
  • Body (JSON):
    {
        "path": "/path/to/your/repo",
        "message": "Your commit message"
    }
    
  • Example:
    curl -X POST -H "Content-Type: application/json" -d '{"path": "/data/data/com.termux/files/home/my-repo", "message": "feat: Implement new feature"}' http://localhost:8888/git/commit
    

/git/push

  • Method: POST
  • Description: Pushes the committed changes to the remote repository.
  • Body (JSON):
    {
        "path": "/path/to/your/repo"
    }
    
  • Example:
    curl -X POST -H "Content-Type: application/json" -d '{"path": "/data/data/com.termux/files/home/my-repo"}' http://localhost:8888/git/push