git mcp
MCP server for managing Git operations on local repositories, allowing users to list repositories, get and create tags, list commits, push tags, and refresh repositories through a standardized interface.
MCP server for managing Git operations on local repositories, allowing users to list repositories, get and create tags, list commits, push tags, and refresh repositories through a standardized interface.
MCP server for managing Git operations on local repositories.
To install Git MCP for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @kjozsa/git-mcp --client claude
uvx install git-mcp
Add the MCP server using the following JSON configuration snippet:
{
"mcpServers": {
"git-mcp": {
"command": "uvx",
"args": ["git-mcp"],
"env": {
"GIT_REPOS_PATH": "/path/to/your/git/repositories"
}
}
}
}
GIT_REPOS_PATH
: Path to the directory containing your Git repositories (required)You can set this in your environment or create a .env
file in the directory where you run the server.
Lists all Git repositories in the configured path. - Parameters: None - Returns: List of repository names
Finds the last Git tag in the specified repository.
- Parameters: repo_name
(Name of the Git repository)
- Returns: Dictionary with version
(tag name) and date
(tag creation date)
Lists commit messages between the last Git tag and HEAD.
- Parameters:
- repo_name
: Name of the Git repository
- max_count
(optional): Maximum number of commits to return
- Returns: List of dictionaries with hash
, author
, date
, and message
Creates a new git tag in the specified repository.
- Parameters:
- repo_name
: Name of the git repository
- tag_name
: Name of the tag to create
- message
(optional): Message for annotated tag (if not provided, creates a lightweight tag)
- Returns: Dictionary with status
, version
(tag name), date
(tag creation date), and type
(annotated or lightweight)
Pushes an existing git tag to the default remote repository.
- Parameters:
- repo_name
: Name of the git repository
- tag_name
: Name of the tag to push
- Returns: Dictionary with status
, remote
(name of the remote), tag
(name of the tag), and message
(success message)
Refreshes a repository by checking out the main branch (or master as fallback) and pulling from all remotes.
- Parameters:
- repo_name
: Name of the git repository
- Returns: Dictionary with status
, repository
, branch
, and pull_results
(results for each remote)
GIT_REPOS_PATH
is set correctly and the repository exists# Install dependencies
uv pip install -r requirements.txt
# Run in dev mode with Inspector
mcp dev git_mcp/server.py
The project includes two test scripts:
test_git_mcp.py
- Tests the underlying Git command functionality directly, without using the MCP server.test_mcp_server.py
- Tests the MCP server functionality by starting a server instance and making calls to it.To run the tests:
```bash
python test_git_mcp.py
python test_mcp_server.py
[
{
"description": "Find the last git tag in the repository Args: repo_name: Name of the git repository Returns: Dictionary containing tag version and date ",
"inputSchema": {
"properties": {
"repo_name": {
"title": "Repo Name",
"type": "string"
}
},
"required": [
"repo_name"
],
"title": "get_last_git_tagArguments",
"type": "object"
},
"name": "get_last_git_tag"
},
{
"description": "List commit messages since main HEAD and the last git tag Args: repo_name: Name of the git repository max_count: Maximum number of commits to return Returns: List of dictionaries containing commit hash, author, date, and message ",
"inputSchema": {
"properties": {
"max_count": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Max Count"
},
"repo_name": {
"title": "Repo Name",
"type": "string"
}
},
"required": [
"repo_name"
],
"title": "list_commits_since_last_tagArguments",
"type": "object"
},
"name": "list_commits_since_last_tag"
},
{
"description": "List all git repositories in the configured path Returns: List of repository names ",
"inputSchema": {
"properties": {},
"title": "list_repositoriesArguments",
"type": "object"
},
"name": "list_repositories"
},
{
"description": "Create a new git tag in the repository Args: repo_name: Name of the git repository tag_name: Name of the tag to create message: Optional message for annotated tag Returns: Dictionary containing status and tag information ",
"inputSchema": {
"properties": {
"message": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Message"
},
"repo_name": {
"title": "Repo Name",
"type": "string"
},
"tag_name": {
"title": "Tag Name",
"type": "string"
}
},
"required": [
"repo_name",
"tag_name"
],
"title": "create_git_tagArguments",
"type": "object"
},
"name": "create_git_tag"
},
{
"description": "Push a git tag to the default remote Args: repo_name: Name of the git repository tag_name: Name of the tag to push Returns: Dictionary containing status and information about the operation ",
"inputSchema": {
"properties": {
"repo_name": {
"title": "Repo Name",
"type": "string"
},
"tag_name": {
"title": "Tag Name",
"type": "string"
}
},
"required": [
"repo_name",
"tag_name"
],
"title": "push_git_tagArguments",
"type": "object"
},
"name": "push_git_tag"
},
{
"description": "Refresh repository by checking out main branch and pulling all remotes Args: repo_name: Name of the git repository Returns: Dictionary containing status and information about the operation ",
"inputSchema": {
"properties": {
"repo_name": {
"title": "Repo Name",
"type": "string"
}
},
"required": [
"repo_name"
],
"title": "refresh_repositoryArguments",
"type": "object"
},
"name": "refresh_repository"
}
]