Back to MCP directory
publicPublicdnsLocal runtime

git-mcp

Git MCP是一个用于管理本地Git仓库操作的MCP服务器,提供列出仓库、获取标签、创建推送标签等功能。

article

README

🚀 Git MCP 使用指南

用于管理本地仓库中Git操作的MCP服务器。借助它,你可以更高效地对本地Git仓库进行管理和操作。

smithery badge

🚀 快速开始

安装说明

通过Smithery安装

要自动通过Smithery为Claude桌面安装Git MCP,可使用以下命令:

npx -y @smithery/cli install @kjozsa/git-mcp --client claude

手动安装

手动安装可使用以下命令:

uvx install git-mcp

配置说明

使用以下JSON配置代码片段添加MCP服务器:

{
  "mcpServers": {
    "git-mcp": {
      "command": "uvx",
      "args": ["git-mcp"],
      "env": {
        "GIT_REPOS_PATH": "/path/to/your/git/repositories"
      }
    }
  }
}

✨ 主要特性

环境变量

  • GIT_REPOS_PATH:包含Git仓库的目录路径(必填)。你可以在运行服务器的目录中创建一个.env文件,或者将其添加到你的环境中。

可用方法

list_repositories

  • 功能:列出配置路径下的所有Git仓库。
  • 参数:无
  • 返回值:仓库名称列表

get_last_git_tag

  • 功能:获取指定仓库中的最后一个Git标签。
  • 参数
    • repo_name(必填):Git仓库的名称
  • 返回值:包含version(标签名称)和date(创建日期)的字典

list_commits_since_last_tag

  • 功能:列出从最后一个Git标签到最新提交之间的提交信息。
  • 参数
    • repo_name:Git仓库的名称
    • max_count(可选):返回的最大提交数量
  • 返回值:包含hashauthordatemessage的字典列表

create_git_tag

  • 功能:在指定仓库中创建新的Git标签。
  • 参数
    • repo_name:Git仓库的名称
    • tag_name:要创建的标签名称
    • message(可选):注释信息(如果未提供,默认创建轻量级标签)
  • 返回值:包含statusversion(标签名称)、date(创建日期)和type(注释或轻量级)的字典

push_git_tag

  • 功能:将现有的Git标签推送到默认远程仓库。
  • 参数
    • repo_name:Git仓库的名称
    • tag_name:要推送的标签名称
  • 返回值:包含statusremote(远程名称)、tag(标签名称)和message(成功消息)的字典

refresh_repository

  • 功能:通过检查出main分支(或回退到master分支作为备用)并拉取最新更改来刷新仓库。
  • 参数
    • repo_name:Git仓库的名称
  • 返回值:无返回值,操作完成后输出状态信息

🔧 技术细节

故障排除

未找到仓库

如果你看到类似“找不到仓库”的错误,请检查以下内容:

  1. 确保路径/path/to/your/git/repositories是有效的,并且包含Git仓库。
  2. 确保仓库名称拼写正确。

提交为空

如果返回的提交列表为空,请执行以下操作:

  1. 检查是否已创建标签。
  2. 确认仓库中是否有任何提交记录。

开发说明

开发前,可使用以下命令安装依赖:

uv pip install -r requirements.txt

测试说明

运行测试

要运行测试,可使用以下命令:

# 对于基本功能测试
uvx test

# 对于扩展功能测试
python3 tests.py

测试脚本

  • test:对核心功能进行快速测试。
  • tests.py:提供更全面的测试,涵盖更多使用场景。

通过以上指南,你可以轻松配置和使用Git MCP服务器来管理你的Git仓库。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client