Skip to main content

MCP server for managing Git operations

Project description

Git MCP

smithery badge 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) and date (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 repository
    • max_count (optional): Maximum number of commits to return
  • Returns: List of dictionaries with hash, author, date, and message

create_git_tag

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)

push_git_tag

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)

checkout_and_pull_main

Checkouts the main branch (or master as fallback) and pulls from all remotes.

  • Parameters:
    • repo_name: Name of the git repository
  • Returns: Dictionary with status, repository, branch, and pull_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

# 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:

  1. test_git_mcp.py - Tests the underlying Git command functionality directly, without using the MCP server.
  2. 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

git_mcp-0.3.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_mcp-0.3.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file git_mcp-0.3.0.tar.gz.

File metadata

  • Download URL: git_mcp-0.3.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for git_mcp-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8cd02c386bd2ee36f9a2eee852dfa46f9f46f1253a7a6f2fb20ff0f210256b7b
MD5 39194702b3854b22ce9ffcf2dcb71f23
BLAKE2b-256 8a53b5c150d66dff1e408acaee39ecdb06616fc5fa51df623fb6642026bf64d0

See more details on using hashes here.

File details

Details for the file git_mcp-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: git_mcp-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for git_mcp-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a3f168b096da925eef2ac1a168b59f45d3a1d86438eeff85c7b3e3e3ca77e54b
MD5 ebb1e2fd7591092107728dea98d35481
BLAKE2b-256 628b1aa67a29b641bae5fd46e4eb3f4cd763fc34a310c8f2d4c4b07f410fa7b1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page