Labsco
modelcontextprotocol logo

Git

โœ“ Officialโ˜… 88,000

from modelcontextprotocol

Tools to read, search, and manipulate Git repositories

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeQuick setup

mcp-server-git: A git MCP server

Overview

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.

Please note that mcp-server-git is currently in early development. The functionality and available tools are subject to change and expansion as we continue to develop and improve the server.

Tools

git_status

  • Shows the working tree status

  • Input:

  • repo_path (string): Path to Git repository

  • Returns: Current status of working directory as text output

git_diff_unstaged

  • Shows changes in working directory not yet staged

  • Inputs:

  • repo_path (string): Path to Git repository

  • context_lines (number, optional): Number of context lines to show (default: 3)

  • Returns: Diff output of unstaged changes

git_diff_staged

  • Shows changes that are staged for commit

  • Inputs:

  • repo_path (string): Path to Git repository

  • context_lines (number, optional): Number of context lines to show (default: 3)

  • Returns: Diff output of staged changes

git_diff

  • Shows differences between branches or commits

  • Inputs:

  • repo_path (string): Path to Git repository

  • target (string): Target branch or commit to compare with

  • context_lines (number, optional): Number of context lines to show (default: 3)

  • Returns: Diff output comparing current state with target

git_commit

  • Records changes to the repository

  • Inputs:

  • repo_path (string): Path to Git repository

  • message (string): Commit message

  • Returns: Confirmation with new commit hash

git_add

  • Adds file contents to the staging area

  • Inputs:

  • repo_path (string): Path to Git repository

  • files (string[]): Array of file paths to stage

  • Returns: Confirmation of staged files

git_reset

  • Unstages all staged changes

  • Input:

  • repo_path (string): Path to Git repository

  • Returns: Confirmation of reset operation

git_log

  • Shows the commit logs with optional date filtering

  • Inputs:

  • repo_path (string): Path to Git repository

  • max_count (number, optional): Maximum number of commits to show (default: 10)

  • start_timestamp (string, optional): Start timestamp for filtering commits. Accepts ISO 8601 format (e.g., '2024-01-15T14:30:25'), relative dates (e.g., '2 weeks ago', 'yesterday'), or absolute dates (e.g., '2024-01-15', 'Jan 15 2024')

  • end_timestamp (string, optional): End timestamp for filtering commits. Accepts ISO 8601 format (e.g., '2024-01-15T14:30:25'), relative dates (e.g., '2 weeks ago', 'yesterday'), or absolute dates (e.g., '2024-01-15', 'Jan 15 2024')

  • Returns: Array of commit entries with hash, author, date, and message

git_create_branch

  • Creates a new branch

  • Inputs:

  • repo_path (string): Path to Git repository

  • branch_name (string): Name of the new branch

  • base_branch (string, optional): Base branch to create from (defaults to current branch)

  • Returns: Confirmation of branch creation

git_checkout

  • Switches branches

  • Inputs:

  • repo_path (string): Path to Git repository

  • branch_name (string): Name of branch to checkout

  • Returns: Confirmation of branch switch

  • git_show

  • Shows the contents of a commit

  • Inputs:

  • repo_path (string): Path to Git repository

  • revision (string): The revision (commit hash, branch name, tag) to show

  • Returns: Contents of the specified commit

  • git_branch

  • List Git branches

  • Inputs:

  • repo_path (string): Path to the Git repository.

  • branch_type (string): Whether to list local branches ('local'), remote branches ('remote') or all branches('all').

  • contains (string, optional): The commit sha that branch should contain. Do not pass anything to this param if no commit sha is specified

  • not_contains (string, optional): The commit sha that branch should NOT contain. Do not pass anything to this param if no commit sha is specified

  • Returns: List of branches

Debugging

You can use the MCP inspector to debug the server. For uvx installations:

Copy & paste โ€” that's it
npx @modelcontextprotocol/inspector uvx mcp-server-git

Or if you've installed the package in a specific directory or are developing on it:

Copy & paste โ€” that's it
cd path/to/servers/src/git
npx @modelcontextprotocol/inspector uv run mcp-server-git

Running tail -n 20 -f ~/Library/Logs/Claude/mcp*.log will show the logs from the server and may help you debug any issues.

Development

If you are doing local development, there are two ways to test your changes:

Run the MCP inspector to test your changes. See Debugging for run instructions.

Test using the Claude desktop app. Add the following to your claude_desktop_config.json:

Docker

Copy & paste โ€” that's it
{
 "mcpServers": {
 "git": {
 "command": "docker",
 "args": [
 "run",
 "--rm",
 "-i",
 "--mount", "type=bind,src=/Users/username/Desktop,dst=/projects/Desktop",
 "--mount", "type=bind,src=/path/to/other/allowed/dir,dst=/projects/other/allowed/dir,ro",
 "--mount", "type=bind,src=/path/to/file.txt,dst=/projects/path/to/file.txt",
 "mcp/git"
 ]
 }
 }
}

UVX

Copy & paste โ€” that's it
{
"mcpServers": {
 "git": {
 "command": "uv",
 "args": [
 "--directory",
 "/ /mcp-servers/src/git",
 "run",
 "mcp-server-git"
 ]
 }
 }
}

Build

Docker build:

Copy & paste โ€” that's it
cd src/git
docker build -t mcp/git .

License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.