Git MCP
MCP 服务器用于管理本地存储库上的 Git 操作。
安装
通过 Smithery 安装
要通过Smithery自动为 Claude Desktop 安装 Git MCP:
手动安装
配置
使用以下 JSON 配置片段添加 MCP 服务器:
特点和用途
环境变量
GIT_REPOS_PATH
:包含 Git 存储库的目录的路径(必需)
您可以在您的环境中设置此项,或者在运行服务器的目录中创建一个.env
文件。
可用方法
列出存储库
列出配置路径中的所有 Git 存储库。
参数:无
返回:存储库名称列表
获取最后一个 git 标签
查找指定存储库中的最后一个 Git 标签。
参数:
repo_name
(Git 存储库的名称)返回:带有
version
(标签名称)和date
(标签创建日期)的字典
list_commits_since_last_tag
列出最后一个 Git 标签和 HEAD 之间的提交消息。
参数:
repo_name
:Git 存储库的名称max_count
(可选):返回的最大提交数
返回:包含
hash
、author
、date
和message
字典列表
创建 git 标签
在指定的存储库中创建一个新的 git 标签。
参数:
repo_name
:git 存储库的名称tag_name
:要创建的标签的名称message
(可选):注释标签的消息(如果未提供,则创建轻量级标签)
返回:包含
status
、version
(标签名称)、date
(标签创建日期)和type
(带注释或轻量级)的字典
推送_git_标签
将现有的 git 标签推送到默认远程存储库。
参数:
repo_name
:git 存储库的名称tag_name
:要推送的标签名称
返回:包含
status
、remote
(远程名称)、tag
(标签名称)和message
(成功消息)的字典
刷新存储库
通过检出主分支(或主分支作为后备)并从所有远程拉取来刷新存储库。
参数:
repo_name
:git 存储库的名称
返回:包含
status
、repository
、branch
和pull_results
(每个远程的结果)的字典
故障排除
未找到存储库:确保
GIT_REPOS_PATH
设置正确且存储库存在未找到标签:存储库尚无任何标签
发展
测试
该项目包括两个测试脚本:
test_git_mcp.py
- 直接测试底层 Git 命令功能,无需使用 MCP 服务器。test_mcp_server.py
- 通过启动服务器实例并对其进行调用来测试 MCP 服务器功能。
运行测试:
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 -1,67368,255MIT 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 -1804
- 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 -21396
- -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 -7,5121MIT License