git-mcp

git-mcp

2.5

git-mcp is a Model Context Protocol (MCP) server that facilitates interactions with Git repositories. It allows users to manage Git operations, view commit histories, and track file changes effectively.

git-mcp

This project is a Model Context Protocol (MCP) server designed to interact with Git repositories. It provides functionality for managing and interacting with Git repositories through MCP tools.


šŸš€ Features

āœ… Git Repository Management: Execute Git operations and manage repositories.
āœ… Repository History: View commit history and file changes over time.
āœ… File Tracking: Track file changes and view file history.
āœ… Diff Operations: View detailed file differences between commits.


šŸ“‹ Requirements

  • Go 1.23.0 or later
  • Git installed on your system
  • Access to Git repositories

āš™ļø Setup

1ļøāƒ£ Install the Package

go install github.com/wricardo/git-mcp@latest

2ļøāƒ£ Configure MCP Client Settings

Add the following configuration to your MCP settings:

"git-mcp": {
  "command": "git-mcp",
  "env": {
    "WORKDIR": "/path/to/your/git/repository"
  },
  "disabled": false,
  "autoApprove": []
}

ā–¶ļø Usage

Run the MCP server:

git-mcp

šŸ› ļø Tools

šŸ”¹ git-log

Display git commit history with commit hash, author, date, and message.

šŸ“Œ Parameters:
  • limit (optional): Number of commits to display (default: 10)
šŸ“Œ Example Response:
[
  {
    "hash": "1234567890abcdef",
    "author": "John Doe",
    "date": "2024-03-20",
    "message": "Initial commit"
  }
]

šŸ”¹ git-changed-files

List files changed between HEAD and a specified number of commits back.

šŸ“Œ Parameters:
  • commits_back (required): Number of commits to look back from HEAD
šŸ“Œ Example Response:
[
  {
    "path": "README.md",
    "changeType": "modified"
  }
]

šŸ”¹ git-file-diff

View detailed file differences between commits.

šŸ“Œ Parameters:
  • file_path (required): Path to the file to view differences
  • commits_back (required): Number of commits to look back from HEAD
šŸ“Œ Example Response:
{
  "path": "README.md",
  "changes": [
    {
      "type": "add",
      "content": "New line added",
      "lineNumber": 42
    }
  ]
}

šŸ”¹ git-file-history

View the commit history for a specific file.

šŸ“Œ Parameters:
  • file_path (required): Path to the file to view history
  • limit (optional): Number of commits to display (default: 10)
šŸ“Œ Example Response:
[
  {
    "hash": "1234567890abcdef",
    "author": "John Doe",
    "date": "2024-03-20",
    "message": "Update README.md"
  }
]