Git MCP
MCP server for managing Git operations on local repositories.
Installation
Installing via Smithery
To install Git MCP for Claude Desktop automatically via Smithery:
Installing Manually
Configuration
Add the MCP server using the following JSON configuration snippet:
Features and Usage
Environment Variables
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.
Available Methods
list_repositories
Lists all Git repositories in the configured path.
- Parameters: None
- Returns: List of repository names
get_last_git_tag
Finds the last Git tag in the specified repository.
- Parameters:
repo_name
(Name of the Git repository) - Returns: Dictionary with
version
(tag name) anddate
(tag creation date)
list_commits_since_last_tag
Lists commit messages between the last Git tag and HEAD.
- Parameters:
repo_name
: Name of the Git repositorymax_count
(optional): Maximum number of commits to return
- Returns: List of dictionaries with
hash
,author
,date
, andmessage
create_git_tag
Creates a new git tag in the specified repository.
- Parameters:
repo_name
: Name of the git repositorytag_name
: Name of the tag to createmessage
(optional): Message for annotated tag (if not provided, creates a lightweight tag)
- Returns: Dictionary with
status
,version
(tag name),date
(tag creation date), andtype
(annotated or lightweight)
push_git_tag
Pushes an existing git tag to the default remote repository.
- Parameters:
repo_name
: Name of the git repositorytag_name
: Name of the tag to push
- Returns: Dictionary with
status
,remote
(name of the remote),tag
(name of the tag), andmessage
(success message)
refresh_repository
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
, andpull_results
(results for each remote)
Troubleshooting
- Repository Not Found: Ensure
GIT_REPOS_PATH
is set correctly and the repository exists - No Tags Found: The repository doesn't have any tags yet
Development
Testing
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:
local-only server
The server can only run on the client's local machine because it depends on local resources.
Tools
MCP 服务器用于管理本地存储库上的 Git 操作,允许用户通过标准化界面列出存储库、获取和创建标签、列出提交、推送标签以及刷新存储库。
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityMCP Server for the GitLab API, enabling project management, file operations, and more.Last updated -91,67365,360MIT License
- AsecurityFlicenseAqualityMCP Server for the GitHub API, providing features for file operations, repository management, and advanced search, with automatic branch creation and comprehensive error handling.Last updated -1814
- AsecurityFlicenseAqualityThe Git MCP Server allows AI assistants to perform enhanced Git operations via the Model Context Protocol, supporting core Git functions, branch and tag management, GitHub integration, and more.Last updated -21576
- -securityAlicense-qualityAn MCP server that enables communication with GitLab repositories, allowing interaction with GitLab's API to manage projects, issues, and repositories through natural language.Last updated -8,4391MIT License