Git MCP
👁 铁匠徽章
MCP 服务器用于管理本地存储库上的 Git 操作。
安装
通过 Smithery 安装
要通过Smithery自动为 Claude Desktop 安装 Git MCP:
npx -y @smithery/cli install @kjozsa/git-mcp --client claude手动安装
uvx install git-mcpRelated MCP server: MCP Git Server
配置
使用以下 JSON 配置片段添加 MCP 服务器:
{
"mcpServers": {
"git-mcp": {
"command": "uvx",
"args": ["git-mcp"],
"env": {
"GIT_REPOS_PATH": "/path/to/your/git/repositories"
}
}
}
}特点和用途
环境变量
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设置正确且存储库存在未找到标签:存储库尚无任何标签
发展
# Install dependencies
uv pip install -r requirements.txt
# Run in dev mode with Inspector
mcp dev git_mcp/server.py测试
该项目包括两个测试脚本:
test_git_mcp.py- 直接测试底层 Git 命令功能,无需使用 MCP 服务器。test_mcp_server.py- 通过启动服务器实例并对其进行调用来测试 MCP 服务器功能。
运行测试:
# 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.pyMaintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/kjozsa/git-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
