GitHub MCP 服务器是一个提供 GitHub 集成功能的模型上下文协议(MCP)服务器。它借助 MCP 工具实现与 GitHub 仓库的交互,支持仓库管理、文件操作和提交处理等功能,极大地提升了开发者在 GitHub 上的操作效率。
使用以下命令安装服务器:
npm install @modelcontextprotocol/server-github
将服务器添加到您的 MCP 设置文件(cline_mcp_settings.json)中:
{
"mcpServers": {
"github": {
"command": "node",
"args": ["/path/to/github-mcp-server/dist/index.js"],
"env": {
"GITHUB_TOKEN_1": "your-github-token",
"GITHUB_OWNER_1": "your-github-username"
},
"disabled": false,
"alwaysAllow": []
}
}
}
{
owner?: string; // 仓库所有者(可选,若已选账户)
name: string; // 仓库名称
description: string; // 仓库描述
private?: boolean; // 是否为私有仓库
}
{
owner?: string; // 仓库所有者
repo: string; // 仓库名称
branch?: string; // 分支名称(默认:main)
outputDir: string; // 克隆到的本地目录
}
{
owner?: string; // 仓库所有者
repo: string; // 当前仓库名称
new_name: string; // 新仓库名称
}
{
owner?: string; // 仓库所有者
repo: string; // 仓库名称
path: string; // 仓库中的目标路径
message: string; // 提交信息
sourcePath: string; // 待推送的本地文件路径
}
{
owner?: string; // 仓库所有者
repo: string; // 仓库名称
path: string; // 仓库中的文件路径
outputDir: string; // 拉取到的本地目录
}
{
owner?: string; // 仓库所有者
repo: string; // 仓库名称
path: string; // 仓库中的文件路径
}
{
owner?: string; // 仓库所有者
repo: string; // 仓库名称
branch: string; // 分支名称
changes: { // 待提交的更改列表
path: string; // 文件路径
content: string; // 文件内容
mode?: string; // 文件模式(可选)
}[]
}
使用以下命令安装开发依赖项:
npm install
构建项目以生成发行版本:
npm run build
GITHUB_TOKEN_:用于身份验证的 GitHub 个人访问令牌。GITHUB_OWNER_:GitHub 用户名或组织名称。本项目采用 MIT 许可证。