|
|
6 месяцев назад | |
|---|---|---|
| .. | ||
| README.cn.md | 6 месяцев назад | |
| README.md | 6 месяцев назад | |
| init.go | 6 месяцев назад | |
https://github.com/modelcontextprotocol/servers/tree/main/src/git
一个用于 Git 仓库交互和自动化的模型上下文协议服务器。该服务器提供工具,通过大型语言模型来读取、搜索和操作 Git 仓库。
请注意,mcp-server-git 目前处于早期开发阶段。随着我们继续开发和改进服务器,功能和可用工具可能会发生变化和扩展。
git_status
repo_path (字符串):Git 仓库路径git_diff_unstaged
repo_path (字符串):Git 仓库路径git_diff_staged
repo_path (字符串):Git 仓库路径git_diff
repo_path (字符串):Git 仓库路径target (字符串):要比较的目标分支或提交git_commit
repo_path (字符串):Git 仓库路径message (字符串):提交消息git_add
repo_path (字符串):Git 仓库路径files (字符串数组):要暂存的文件路径数组git_reset
repo_path (字符串):Git 仓库路径git_log
repo_path (字符串):Git 仓库路径max_count (数字,可选):要显示的最大提交数量(默认:10)git_create_branch
repo_path (字符串):Git 仓库路径branch_name (字符串):新分支名称start_point (字符串,可选):新分支的起始点git_checkout
repo_path (字符串):Git 仓库路径branch_name (字符串):要切换到的分支名称git_show
repo_path (字符串):Git 仓库路径revision (字符串):要显示的修订版本(提交哈希、分支名称、标签)git_init
repo_path (字符串):要初始化 git 仓库的目录路径使用 uv 时不需要特定的安装。我们将使用 uvx 直接运行 *mcp-server-git*。
或者您可以通过 pip 安装 mcp-server-git:
pip install mcp-server-git
安装后,您可以使用以下命令作为脚本运行:
python -m mcp_server_git
将以下内容添加到您的 claude_desktop_config.json:
要快速安装,请使用下面的一键安装按钮...
要手动安装,请将以下 JSON 块添加到 VS Code 中的用户设置(JSON)文件。您可以按 Ctrl + Shift + P 并输入 Preferences: Open Settings (JSON) 来执行此操作。
或者,您可以将其添加到工作区中名为 .vscode/mcp.json 的文件中。这将允许您与他人共享配置。
注意在
.vscode/mcp.json文件中不需要mcp键。
{
"mcp": {
"servers": {
"git": {
"command": "uvx",
"args": ["mcp-server-git"]
}
}
}
}
Docker 安装:
{
"mcp": {
"servers": {
"git": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"--mount", "type=bind,src=${workspaceFolder},dst=/workspace",
"mcp/git"
]
}
}
}
}
添加到您的 Zed settings.json:
您可以使用 MCP 检查器来调试服务器。对于 uvx 安装:
npx @modelcontextprotocol/inspector uvx mcp-server-git
或者如果您在特定目录中安装了包或正在开发它:
cd path/to/servers/src/git
npx @modelcontextprotocol/inspector uv run mcp-server-git
运行 tail -n 20 -f ~/Library/Logs/Claude/mcp*.log 将显示服务器的日志,可能有助于您调试任何问题。
如果您正在进行本地开发,有两种方法可以测试您的更改:
运行 MCP 检查器来测试您的更改。运行说明请参见调试。
使用 Claude 桌面应用程序进行测试。将以下内容添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"git": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"--mount", "type=bind,src=/Users/username/Desktop,dst=/projects/Desktop",
"--mount", "type=bind,src=/path/to/other/allowed/dir,dst=/projects/other/allowed/dir,ro",
"--mount", "type=bind,src=/path/to/file.txt,dst=/projects/path/to/file.txt",
"mcp/git"
]
}
}
}
{
"mcpServers": {
"git": {
"command": "uv",
"args": [
"--directory",
"/<path to mcp-servers>/mcp-servers/src/git",
"run",
"mcp-server-git"
]
}
}
Docker 构建:
cd src/git
docker build -t mcp/git .
此 MCP 服务器根据 MIT 许可证授权。这意味着您可以自由使用、修改和分发软件,但需遵守 MIT 许可证的条款和条件。有关更多详细信息,请参阅项目仓库中的 LICENSE 文件。