Git MCP

Git MCP

用于管理本地仓库 Git 操作的 MCP 服务器,允许用户通过标准化接口列出仓库、获取和创建标签、列出提交、推送标签以及刷新仓库。

版本控制
开发者工具
文件系统
本地
Python
访问服务器

Tools

get_last_git_tag

Find the last git tag in the repository Args: repo_name: Name of the git repository Returns: Dictionary containing tag version and date

list_commits_since_last_tag

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

list_repositories

List all git repositories in the configured path Returns: List of repository names

create_git_tag

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

push_git_tag

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

refresh_repository

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

README

Git MCP

smithery badge 用于管理本地仓库 Git 操作的 MCP 服务器。

安装

通过 Smithery 安装

要通过 Smithery 为 Claude Desktop 自动安装 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 标签和 HEAD 之间的提交消息。

  • 参数:
    • 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

通过检出主分支(或备用分支 master)并从所有远程仓库拉取来刷新仓库。

  • 参数:
    • repo_name:git 仓库的名称
  • 返回值:包含 statusrepositorybranchpull_results(每个远程仓库的结果)的字典

故障排除

  • Repository Not Found(仓库未找到):确保 GIT_REPOS_PATH 设置正确并且仓库存在
  • No Tags Found(未找到标签):仓库还没有任何标签

开发

# 安装依赖
uv pip install -r requirements.txt

# 在带有 Inspector 的开发模式下运行
mcp dev git_mcp/server.py

测试

该项目包含两个测试脚本:

  1. test_git_mcp.py - 直接测试底层 Git 命令功能,而不使用 MCP 服务器。
  2. test_mcp_server.py - 通过启动服务器实例并对其进行调用来测试 MCP 服务器功能。

要运行测试:

# 测试 Git 命令功能
python test_git_mcp.py

# 测试 MCP 服务器(需要安装 git-mcp 包)
python test_mcp_server.py

推荐服务器

Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
Excel MCP Server

Excel MCP Server

一个模型上下文协议服务器,使 AI 助手能够读取和写入 Microsoft Excel 文件,支持诸如 xlsx、xlsm、xltx 和 xltm 等格式。

精选
本地
Go
Playwright MCP Server

Playwright MCP Server

提供一个利用模型上下文协议的服务器,以实现类人浏览器的自动化,该服务器使用 Playwright,允许控制浏览器行为,例如导航、元素交互和滚动。

精选
本地
TypeScript
MCP Package Docs Server

MCP Package Docs Server

促进大型语言模型高效访问和获取 Go、Python 和 NPM 包的结构化文档,通过多语言支持和性能优化来增强软件开发。

精选
本地
TypeScript
Claude Code MCP

Claude Code MCP

一个实现了 Claude Code 作为模型上下文协议(Model Context Protocol, MCP)服务器的方案,它可以通过标准化的 MCP 接口来使用 Claude 的软件工程能力(代码生成、编辑、审查和文件操作)。

精选
本地
JavaScript
@kazuph/mcp-taskmanager

@kazuph/mcp-taskmanager

用于任务管理的模型上下文协议服务器。它允许 Claude Desktop(或任何 MCP 客户端)在基于队列的系统中管理和执行任务。

精选
本地
JavaScript
Apple MCP Server

Apple MCP Server

通过 MCP 协议与 Apple 应用(如“信息”、“备忘录”和“通讯录”)进行交互,从而使用自然语言发送消息、搜索和打开应用内容。

精选
本地
TypeScript
Gitingest-MCP

Gitingest-MCP

一个用于 gitingest 的 MCP 服务器。它允许像 Claude Desktop、Cursor、Cline 等 MCP 客户端快速提取关于 Github 仓库的信息,包括仓库摘要、项目目录结构、文件内容等。

精选
本地
Python