MCP Git 工具库
为模型上下文协议 (MCP) 提供的 Git 工具集成库。
快速入门
安装
- 克隆仓库:
git clone https://github.com/lileeei/mcp-git-tools.git
- 进入目录:
cd mcp-git-tools
- 构建项目:
cargo build
使用
作为独立服务器运行
运行命令:cargo run --bin mcp-git-server
在 MCP 客户端中使用
创建客户端连接并调用工具,例如获取仓库状态:
let status = client.call_tool("git_status", serde_json::json!({ "repo_path": "/path/to/repo" })).await?;
println!("Git 状态: {:?}", status);
集成到自定义 MCP 服务器
注册 Git 工具:
use mcp_git_tools::register_git_tools;
let mut builder = McpServerBuilder::new("my-server", "1.0.0");
register_git_tools(&mut builder);
支持的工具包括 git_status
、git_branches
、git_log
等。