MCP server for managing Git operations
Project description
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:
npx -y @smithery/cli install @kjozsa/git-mcp --client claude
Installing Manually
uvx install git-mcp
Configuration
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"
}
}
}
}
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_PATHis set correctly and the repository exists - No Tags Found: The repository doesn't have any tags yet
Development
# Install dependencies
uv pip install -r requirements.txt
# Run in dev mode with Inspector
mcp dev git_mcp/server.py
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:
# Test the Git command functionality
python test_git_mcp.py
# Test the MCP server (requires the git-mcp package to be installed)
python test_mcp_server.py
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file git_mcp-0.3.2.tar.gz.
File metadata
- Download URL: git_mcp-0.3.2.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa0153cf41cf2a60abd04e0f2f5266fc31df4f0402b621952f41657ed6857f0f
|
|
| MD5 |
88e589a44048a757479d52d2dac21fea
|
|
| BLAKE2b-256 |
9d3e85090fb9aa3af30fa69372dac37d4ae60f08214c96d01b1a20fa907353a0
|
File details
Details for the file git_mcp-0.3.2-py3-none-any.whl.
File metadata
- Download URL: git_mcp-0.3.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c38191d99a000147d22a202ec2420be1a88046f20467ab3a08c84d6d20691858
|
|
| MD5 |
0fc9b636de5bcc9cfdc2a6d718085273
|
|
| BLAKE2b-256 |
bc03de09b1aeeddf1c14678043835c16f1e4c4c12f3478b359b90c9eb7546650
|