GitHub MCP 服务器是一个集成了 GitHub 功能的 Model Context Protocol (MCP) 服务器。它借助 MCP 工具与 GitHub 仓库进行交互,支持仓库管理、文件操作和提交处理等功能,为用户提供便捷的 GitHub 操作体验。
按照以下步骤,你可以快速使用 GitHub MCP 服务器:
使用以下命令安装 GitHub MCP 服务器:
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; // 文件在仓库中的路径
outputPath: string; // 本地保存文件的路径
}
{
owner?: string; // 仓库所有者
repo: string; // 仓库名称
path: string; // 仓库中的目标路径
outputDir: string; // 本地同步的目标目录
}
{
owner?: string; // 仓库所有者
repo: string; // 仓库名称
branch: string; // 分支名称
message: string; // 提交信息
author_name: string; // 提交作者的姓名
author_email: string; // 提交作者的电子邮件
}
在开发过程中,你可以使用以下命令启动开发模式:
npm run dev
GITHUB_TOKEN_1:GitHub 账户 1 的访问令牌。GITHUB_OWNER_1:GitHub 账户 1 的所有者名称。[此处插入许可证信息]