git

Local 2025-08-31 23:24:12 0

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.


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

  1. git_status
  2. Shows the working tree status
  3. Input:
    • repo_path (string): Path to Git repository
  4. Returns: Current status of working directory as text output

  5. git_diff_unstaged

  6. Shows changes in working directory not yet staged
  7. Input:
    • repo_path (string): Path to Git repository
  8. Returns: Diff output of unstaged changes

  9. git_diff_staged

  10. Shows changes that are staged for commit
  11. Input:
    • repo_path (string): Path to Git repository
  12. Returns: Diff output of staged changes

  13. git_diff

  14. Shows differences between branches or commits
  15. Inputs:
    • repo_path (string): Path to Git repository
    • target (string): Target branch or commit to compare with
  16. Returns: Diff output comparing current state with target

  17. git_commit

  18. Records changes to the repository
  19. Inputs:
    • repo_path (string): Path to Git repository
    • message (string): Commit message
  20. Returns: Confirmation with new commit hash

  21. git_add

  22. Adds file contents to the staging area
  23. Inputs:
    • repo_path (string): Path to Git repository
    • files (string[]): Array of file paths to stage
  24. Returns: Confirmation of staged files

  25. git_reset

  26. Unstages all staged changes
  27. Input:
    • repo_path (string): Path to Git repository
  28. Returns: Confirmation of reset operation

  29. git_log

  30. Shows the commit logs
  31. Inputs:
    • repo_path (string): Path to Git repository
    • max_count (number, optional): Maximum number of commits to show (default: 10)
  32. Returns: Array of commit entries with hash, author, date, and message

  33. git_create_branch

  34. Creates a new branch
  35. Inputs:
    • repo_path (string): Path to Git repository
    • branch_name (string): Name of the new branch
    • start_point (string, optional): Starting point for the new branch
  36. Returns: Confirmation of branch creation
  37. git_checkout
  38. Switches branches
  39. Inputs:
    • repo_path (string): Path to Git repository
    • branch_name (string): Name of branch to checkout
  40. Returns: Confirmation of branch switch
  41. git_show
  42. Shows the contents of a commit
  43. Inputs:
    • repo_path (string): Path to Git repository
    • revision (string): The revision (commit hash, branch name, tag) to show
  44. Returns: Contents of the specified commit
  45. git_init
  46. Initializes a Git repository
  47. Inputs:
    • repo_path (string): Path to directory to initialize git repo
  48. Returns: Confirmation of repository initialization

Installation

When using uv no specific installation is needed. We will use uvx to directly run mcp-server-git.

Using PIP

Alternatively you can install mcp-server-git via pip:

pip install mcp-server-git

After installation, you can run it as a script using:

python -m mcp_server_git

Configuration

Usage with Claude Desktop

Add this to your claude_desktop_config.json:

Using uvx
"mcpServers": {
  "git": {
    "command": "uvx",
    "args": ["mcp-server-git", "--repository", "path/to/git/repo"]
  }
}
Using docker * Note: replace '/Users/username' with the a path that you want to be accessible by this tool
"mcpServers": {
  "git": {
    "command": "docker",
    "args": ["run", "--rm", "-i", "--mount", "type=bind,src=/Users/username,dst=/Users/username", "mcp/git"]
  }
}
Using pip installation
"mcpServers": {
  "git": {
    "command": "python",
    "args": ["-m", "mcp_server_git", "--repository", "path/to/git/repo"]
  }
}

Usage with Zed

Add to your Zed settings.json:

Using uvx
"context_servers": [
  "mcp-server-git": {
    "command": {
      "path": "uvx",
      "args": ["mcp-server-git"]
    }
  }
],
Using pip installation
"context_servers": {
  "mcp-server-git": {
    "command": {
      "path": "python",
      "args": ["-m", "mcp_server_git"]
    }
  }
},

Debugging

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

npx @modelcontextprotocol/inspector uvx mcp-server-git

Or if you've installed the package in a specific directory or are developing on 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:

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

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

Docker

{
  "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

{
"mcpServers": {
  "git": {
    "command": "uv",
    "args": [ 
      "--directory",
      "/<path to mcp-servers>/mcp-servers/src/git",
      "run",
      "mcp-server-git"
    ]
  }
}

Build

Docker build:

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.

[
  {
    "description": "Shows the working tree status",
    "inputSchema": {
      "properties": {
        "repo_path": {
          "title": "Repo Path",
          "type": "string"
        }
      },
      "required": [
        "repo_path"
      ],
      "title": "GitStatus",
      "type": "object"
    },
    "name": "git_status"
  },
  {
    "description": "Shows changes in the working directory that are not yet staged",
    "inputSchema": {
      "properties": {
        "repo_path": {
          "title": "Repo Path",
          "type": "string"
        }
      },
      "required": [
        "repo_path"
      ],
      "title": "GitDiffUnstaged",
      "type": "object"
    },
    "name": "git_diff_unstaged"
  },
  {
    "description": "Shows changes that are staged for commit",
    "inputSchema": {
      "properties": {
        "repo_path": {
          "title": "Repo Path",
          "type": "string"
        }
      },
      "required": [
        "repo_path"
      ],
      "title": "GitDiffStaged",
      "type": "object"
    },
    "name": "git_diff_staged"
  },
  {
    "description": "Shows differences between branches or commits",
    "inputSchema": {
      "properties": {
        "repo_path": {
          "title": "Repo Path",
          "type": "string"
        },
        "target": {
          "title": "Target",
          "type": "string"
        }
      },
      "required": [
        "repo_path",
        "target"
      ],
      "title": "GitDiff",
      "type": "object"
    },
    "name": "git_diff"
  },
  {
    "description": "Records changes to the repository",
    "inputSchema": {
      "properties": {
        "message": {
          "title": "Message",
          "type": "string"
        },
        "repo_path": {
          "title": "Repo Path",
          "type": "string"
        }
      },
      "required": [
        "repo_path",
        "message"
      ],
      "title": "GitCommit",
      "type": "object"
    },
    "name": "git_commit"
  },
  {
    "description": "Adds file contents to the staging area",
    "inputSchema": {
      "properties": {
        "files": {
          "items": {
            "type": "string"
          },
          "title": "Files",
          "type": "array"
        },
        "repo_path": {
          "title": "Repo Path",
          "type": "string"
        }
      },
      "required": [
        "repo_path",
        "files"
      ],
      "title": "GitAdd",
      "type": "object"
    },
    "name": "git_add"
  },
  {
    "description": "Unstages all staged changes",
    "inputSchema": {
      "properties": {
        "repo_path": {
          "title": "Repo Path",
          "type": "string"
        }
      },
      "required": [
        "repo_path"
      ],
      "title": "GitReset",
      "type": "object"
    },
    "name": "git_reset"
  },
  {
    "description": "Shows the commit logs",
    "inputSchema": {
      "properties": {
        "max_count": {
          "default": 10,
          "title": "Max Count",
          "type": "integer"
        },
        "repo_path": {
          "title": "Repo Path",
          "type": "string"
        }
      },
      "required": [
        "repo_path"
      ],
      "title": "GitLog",
      "type": "object"
    },
    "name": "git_log"
  },
  {
    "description": "Creates a new branch from an optional base branch",
    "inputSchema": {
      "properties": {
        "base_branch": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": {
            "path": "tsconfig.json",
            "type": "blob"
          },
          "title": "Base Branch"
        },
        "branch_name": {
          "title": "Branch Name",
          "type": "string"
        },
        "repo_path": {
          "title": "Repo Path",
          "type": "string"
        }
      },
      "required": [
        "repo_path",
        "branch_name"
      ],
      "title": "GitCreateBranch",
      "type": "object"
    },
    "name": "git_create_branch"
  },
  {
    "description": "Switches branches",
    "inputSchema": {
      "properties": {
        "branch_name": {
          "title": "Branch Name",
          "type": "string"
        },
        "repo_path": {
          "title": "Repo Path",
          "type": "string"
        }
      },
      "required": [
        "repo_path",
        "branch_name"
      ],
      "title": "GitCheckout",
      "type": "object"
    },
    "name": "git_checkout"
  },
  {
    "description": "Shows the contents of a commit",
    "inputSchema": {
      "properties": {
        "repo_path": {
          "title": "Repo Path",
          "type": "string"
        },
        "revision": {
          "title": "Revision",
          "type": "string"
        }
      },
      "required": [
        "repo_path",
        "revision"
      ],
      "title": "GitShow",
      "type": "object"
    },
    "name": "git_show"
  },
  {
    "description": "Initialize a new Git repository",
    "inputSchema": {
      "properties": {
        "repo_path": {
          "title": "Repo Path",
          "type": "string"
        }
      },
      "required": [
        "repo_path"
      ],
      "title": "GitInit",
      "type": "object"
    },
    "name": "git_init"
  }
]