GitHub 企业版 MCP(管理控制台协议)服务器是一款强大的工具,它能让你通过 Cursor 的 AI 聊天功能,直接与 GitHub 企业版实例进行交互。借助该工具,你可以轻松实现仓库管理、代码审查、问题跟踪等多种 GitHub 企业版功能。
在使用 GitHub 企业版 MCP 服务器之前,你需要完成安装和配置工作。以下是详细的操作步骤:
export GHE_HOST=your-enterprise-host.com
export GHE_PORT=443
export GITHUB_TOKEN=your PAT token
npm start --prefix path/to/mcp-server
GHE_HOST
:GitHub 企业版实例的主机名。GHE_PORT
:GitHub 企业版实例使用的端口,默认为 443。GITHUB_TOKEN
:用于身份验证的个人访问令牌(PAT)。--host
:自定义服务器绑定地址,例如 --host 0.0.0.0
。--port
:自定义服务器端口,例如 --port 3000
。--config
:指定配置文件路径,例如 --config ./config.json
。以下是在 Cursor 的 AI 聊天中使用 GitHub 企业版工具的具体示例:
// 列出仓库
mcp_github_enterprise_列出仓库(owner="octocat")
// 获取仓库信息
mcp_github_enterprise_获取仓库(owner="octocat", repo="hello-world")
// 列出拉取请求
mcp_github_enterprise_列出拉取请求(owner="octocat", repo="hello-world", state="open")
// 管理问题
// 列出问题
mcp_github_enterprise_列出问题(owner="octocat", repo="hello-world", state="all")
// 获取问题详情
mcp_github_enterprise_获取问题(owner="octocat", repo="hello-world", issue_number=1)
// 获取问题/拉取请求评论
mcp_github_enterprise_列出问题评论(owner="octocat", repo="hello-world", issue_number=1)
// 创建新问题
mcp_github_enterprise_创建问题(
owner="octocat",
repo="hello-world",
title="发现了一个错误",
body="这里是对错误的描述",
labels=["bug", "important"]
)
// 操作仓库内容
mcp_github_enterprise_获取内容(owner="octocat", repo="hello-world", 路径="README.md")
// 管理仓库设置
// 创建新仓库
mcp_github_enterprise_创建仓库(
name="new-project",
description="这是一个新项目",
private=true,
auto_init=true
)
// 更新仓库设置
mcp_github_enterprise_更新仓库(
owner="octocat",
repo="hello-world",
description="更新后的描述",
has_issues=true
)
// 设置仓库策略
mcp_github_enterprise_设置仓库策略(
owner="octocat",
repo="hello-world",
required_linear_history=true,
required_signatures=true
)
GitHub 企业版 MCP 服务器支持以下企业级功能:
GitHub 企业版 MCP 服务器遵循 MIT 许可证,允许个人和商业用途。