
GitHub Enterprise MCP Server
一个 MCP 服务器,可以与 GitHub Enterprise API 集成,允许用户通过 Cursor 访问仓库信息、管理议题、拉取请求、工作流以及其他 GitHub 功能。
Tools
list-repositories
get-repository
list-branches
get-content
list-pull-requests
get-pull-request
create-pull-request
merge-pull-request
get-license-info
get-enterprise-stats
create-repository
update-repository
delete-repository
list-workflows
list-workflow-runs
trigger-workflow
README
GitHub Enterprise MCP 服务器
一个用于与 GitHub Enterprise API 集成的 MCP (模型上下文协议) 服务器。此服务器提供一个 MCP 接口,以便在 Cursor 中轻松访问 GitHub Enterprise 中的存储库信息、问题、PR 等。
兼容性
此项目主要为 GitHub Enterprise Server 环境设计,但也适用于:
- GitHub.com
- GitHub Enterprise Cloud
注意: 某些企业特定功能(如许可证信息和企业统计信息)不适用于 GitHub.com 或 GitHub Enterprise Cloud。
主要特性
- 从 GitHub Enterprise 实例检索存储库列表
- 获取详细的存储库信息
- 列出存储库分支
- 查看文件和目录内容
- 管理问题和拉取请求
- 存储库管理(创建、更新、删除)
- GitHub Actions 工作流管理
- 用户管理(列出、创建、更新、删除、暂停/取消暂停用户)
- 访问企业统计信息
- 增强的错误处理和用户友好的响应格式
快速入门
前提条件
- Node.js 18 或更高版本
- 访问 GitHub Enterprise 实例
- 个人访问令牌 (PAT)
Docker 安装和设置
选项 1:使用 Docker 运行
- 构建 Docker 镜像:
docker build -t github-enterprise-mcp .
- 使用环境变量运行 Docker 容器:
docker run -p 3000:3000 \
-e GITHUB_TOKEN="your_github_token" \
-e GITHUB_ENTERPRISE_URL="https://github.your-company.com/api/v3" \
-e DEBUG=true \
github-enterprise-mcp
注意: Dockerfile 默认配置为使用
--transport http
运行。如果需要更改此设置,可以覆盖该命令:
docker run -p 3000:3000 \
-e GITHUB_TOKEN="your_github_token" \
-e GITHUB_ENTERPRISE_URL="https://github.your-company.com/api/v3" \
-e DEBUG=true \
github-enterprise-mcp node dist/index.js --transport http --debug
选项 2:使用 Docker Compose
- 在项目根目录中创建一个包含所需环境变量的
.env
文件:
GITHUB_ENTERPRISE_URL=https://github.your-company.com/api/v3
GITHUB_TOKEN=your_github_token
DEBUG=true
- 使用 Docker Compose 启动容器:
docker-compose up -d
- 检查日志:
docker-compose logs -f
- 停止容器:
docker-compose down
安装和设置
本地开发(使用并发模式)
建议使用此方法进行主动开发,具有自动重新编译和服务器重启功能:
- 克隆存储库并安装所需的软件包:
git clone https://github.com/ddukbg/github-enterprise-mcp.git
cd github-enterprise-mcp
npm install
- 运行开发服务器:
export GITHUB_TOKEN="your_github_token"
export GITHUB_ENTERPRISE_URL="https://github.your-company.com/api/v3"
npm run dev
这将:
- 在文件更改时自动编译 TypeScript 代码
- 在编译后的文件更新时重启服务器
- 在 HTTP 模式下运行服务器以进行基于 URL 的连接
- 使用下面描述的 URL 模式连接到 Cursor
生产环境的安装和设置
选项 1:使用 URL 模式(推荐用于本地开发)
此方法是最稳定的,建议用于本地开发或测试:
- 克隆存储库并安装所需的软件包:
git clone https://github.com/ddukbg/github-enterprise-mcp.git
cd github-enterprise-mcp
npm install
- 构建项目:
npm run build
chmod +x dist/index.js
- 运行服务器:
export GITHUB_TOKEN="your_github_token"
export GITHUB_ENTERPRISE_URL="https://github.your-company.com/api/v3"
node dist/index.js --transport http --debug
-
使用 URL 模式连接到 Cursor:
- 将以下内容添加到 Cursor 的
.cursor/mcp.json
文件中:
{ "mcpServers": { "github-enterprise": { "url": "http://localhost:3000/sse" } } }
- 将以下内容添加到 Cursor 的
选项 2:作为全局命令安装 (npm link)
此方法对于本地开发很有用:
# 克隆存储库后
git clone https://github.com/ddukbg/github-enterprise-mcp.git
cd github-enterprise-mcp
# 安装所需的软件包
npm install
# 构建
npm run build
chmod +x dist/index.js
# 全局链接
npm link
# 作为全局命令运行
export GITHUB_TOKEN="your_github_token"
export GITHUB_ENTERPRISE_URL="https://github.your-company.com/api/v3"
github-enterprise-mcp --transport=http --debug
选项 3:使用 npx(当软件包已发布时)
如果软件包已发布到公共 npm 注册表:
npx @ddukbg/github-enterprise-mcp --token=your_github_token --github-enterprise-url=https://github.your-company.com/api/v3
与 AI 工具集成
Claude Desktop
将以下内容添加到您的 claude_desktop_config.json
中:
{
"mcpServers": {
"github-enterprise": {
"command": "npx",
"args": ["-y", "@ddukbg/github-enterprise-mcp", "--token=YOUR_GITHUB_TOKEN", "--github-enterprise-url=YOUR_GITHUB_ENTERPRISE_URL"]
}
}
}
将 YOUR_GITHUB_TOKEN
和 YOUR_GITHUB_ENTERPRISE_URL
替换为您的实际值。
Cursor
推荐:URL 模式(最稳定)
为了在 Cursor 中获得最可靠的操作,建议使用 URL 模式:
-
在单独的终端窗口中启动服务器:
cd /path/to/github-enterprise-mcp GITHUB_ENTERPRISE_URL="https://github.your-company.com/api/v3" GITHUB_TOKEN="your_github_token" node dist/index.js --transport http
-
配置 Cursor 的 MCP 设置:
- 打开 Cursor 并转到 Settings
- 导航到 AI > MCP Servers
- 编辑您的
.cursor/mcp.json
文件:
{ "mcpServers": { "github-enterprise": { "url": "http://localhost:3000/sse" } } }
-
重启 Cursor 以应用更改
替代方案:命令模式
或者,您可以配置 Cursor 以使用命令模式,尽管 URL 模式更可靠:
- 打开 Cursor 并转到 Settings
- 导航到 AI > MCP Servers
- 点击 Add MCP Server
- 输入以下详细信息:
- Name: GitHub Enterprise
- Command:
npx
- Arguments:
@ddukbg/github-enterprise-mcp
- Environment Variables:
GITHUB_ENTERPRISE_URL
: 您的 GitHub Enterprise API URLGITHUB_TOKEN
: 您的 GitHub 个人访问令牌
或者,您可以手动编辑您的 .cursor/mcp.json
文件以包含:
{
"mcpServers": {
"github-enterprise": {
"command": "npx",
"args": [
"@ddukbg/github-enterprise-mcp"
],
"env": {
"GITHUB_ENTERPRISE_URL": "https://github.your-company.com/api/v3",
"GITHUB_TOKEN": "your_github_token"
}
}
}
}
HTTP 模式下的其他选项
--debug
: 启用调试日志记录--github-enterprise-url <URL>
: 设置 GitHub Enterprise API URL--token <TOKEN>
: 设置 GitHub 个人访问令牌
可用的 MCP 工具
此 MCP 服务器提供以下工具:
工具名称 | 描述 | 参数 | 所需的 PAT 权限 |
---|---|---|---|
list-repositories |
检索用户或组织的存储库列表 | owner : 用户名/组织名称<br>isOrg : 是否为组织<br>type : 存储库类型<br>sort : 排序标准<br>page : 页码<br>perPage : 每页项目数 |
repo |
get-repository |
获取详细的存储库信息 | owner : 存储库所有者<br>repo : 存储库名称 |
repo |
list-branches |
列出存储库的分支 | owner : 存储库所有者<br>repo : 存储库名称<br>protected_only : 是否仅显示受保护的分支<br>page : 页码<br>perPage : 每页项目数 |
repo |
get-content |
检索文件或目录内容 | owner : 存储库所有者<br>repo : 存储库名称<br>path : 文件/目录路径<br>ref : 分支/提交 (可选) |
repo |
list-pull-requests |
列出存储库中的拉取请求 | owner : 存储库所有者<br>repo : 存储库名称<br>state : PR 状态过滤器<br>sort : 排序标准<br>direction : 排序方向<br>page : 页码<br>per_page : 每页项目数 |
repo |
get-pull-request |
获取拉取请求详细信息 | owner : 存储库所有者<br>repo : 存储库名称<br>pull_number : 拉取请求编号 |
repo |
create-pull-request |
创建新的拉取请求 | owner : 存储库所有者<br>repo : 存储库名称<br>title : PR 标题<br>head : Head 分支<br>base : Base 分支<br>body : PR 描述<br>draft : 创建为草稿 PR |
repo |
merge-pull-request |
合并拉取请求 | owner : 存储库所有者<br>repo : 存储库名称<br>pull_number : 拉取请求编号<br>merge_method : 合并方法<br>commit_title : 提交标题<br>commit_message : 提交消息 |
repo |
list-issues |
列出存储库中的问题 | owner : 存储库所有者<br>repo : 存储库名称<br>state : 问题状态过滤器<br>sort : 排序标准<br>direction : 排序方向<br>page : 页码<br>per_page : 每页项目数 |
repo |
get-issue |
获取问题详细信息 | owner : 存储库所有者<br>repo : 存储库名称<br>issue_number : 问题编号 |
repo |
create-issue |
创建新问题 | owner : 存储库所有者<br>repo : 存储库名称<br>title : 问题标题<br>body : 问题正文内容<br>labels : 标签名称数组<br>assignees : 用户登录名数组<br>milestone : 里程碑 ID |
repo |
create-repository |
创建新的存储库 | name : 存储库名称<br>description : 存储库描述<br>private : 是否私有<br>auto_init : 使用 README 初始化<br>gitignore_template : 添加 .gitignore<br>license_template : 添加许可证<br>org : 组织名称 |
repo |
update-repository |
更新存储库设置 | owner : 存储库所有者<br>repo : 存储库名称<br>description : 新描述<br>private : 更改隐私设置<br>default_branch : 更改默认分支<br>has_issues : 启用/禁用问题<br>has_projects : 启用/禁用项目<br>has_wiki : 启用/禁用 Wiki<br>archived : 存档/取消存档 |
repo |
delete-repository |
删除存储库 | owner : 存储库所有者<br>repo : 存储库名称<br>confirm : 确认 (必须为 true) |
delete_repo |
list-workflows |
列出 GitHub Actions 工作流 | owner : 存储库所有者<br>repo : 存储库名称<br>page : 页码<br>perPage : 每页项目数 |
actions:read |
list-workflow-runs |
列出工作流运行 | owner : 存储库所有者<br>repo : 存储库名称<br>workflow_id : 工作流 ID/文件名<br>branch : 按分支筛选<br>status : 按状态筛选<br>page : 页码<br>perPage : 每页项目数 |
actions:read |
trigger-workflow |
触发工作流 | owner : 存储库所有者<br>repo : 存储库名称<br>workflow_id : 工作流 ID/文件名<br>ref : Git 引用<br>inputs : 工作流输入 |
actions:write |
get-license-info |
获取 GitHub Enterprise 许可证信息 | - | 需要 site_admin (管理员) 帐户 |
get-enterprise-stats |
获取 GitHub Enterprise 系统统计信息 | - | 需要 site_admin (管理员) 帐户 |
注意: 对于企业特定工具 (
get-license-info
和get-enterprise-stats
),需要具有 站点管理员 权限的用户。建议使用 Classic Personal Access Token,因为 Fine-grained token 可能不支持这些企业级权限。
在 Cursor 中使用这些工具
设置 MCP 服务器并配置 Cursor 连接到它后,您可以直接在 Cursor 的 AI 聊天中使用 GitHub Enterprise 工具。以下是一些示例:
列出存储库
mcp_github_enterprise_list_repositories(owner="octocat")
获取存储库信息
mcp_github_enterprise_get_repository(owner="octocat", repo="hello-world")
列出拉取请求
mcp_github_enterprise_list_pull_requests(owner="octocat", repo="hello-world", state="open")
管理问题
# 列出问题
mcp_github_enterprise_list_issues(owner="octocat", repo="hello-world", state="all")
# 获取问题详细信息
mcp_github_enterprise_get_issue(owner="octocat", repo="hello-world", issue_number=1)
# 创建新问题
mcp_github_enterprise_create_issue(
owner="octocat",
repo="hello-world",
title="发现了一个 bug",
body="这是 bug 的描述",
labels=["bug", "important"]
)
使用存储库内容
mcp_github_enterprise_get_content(owner="octocat", repo="hello-world", path="README.md")
存储库管理
# 创建新的存储库
mcp_github_enterprise_create_repository(
name="new-project",
description="这是一个新项目",
private=true,
auto_init=true
)
# 更新存储库设置
mcp_github_enterprise_update_repository(
owner="octocat",
repo="hello-world",
description="更新的描述",
has_issues=true
)
用户管理(仅限企业版)
这些功能专门为 GitHub Enterprise Server 环境设计,需要管理权限:
# 列出 GitHub Enterprise 实例中的所有用户
mcp_github_enterprise_list_users(filter="active", per_page=100)
# 获取特定用户的详细信息
mcp_github_enterprise_get_user(username="octocat")
# 创建新用户(仅限企业版)
mcp_github_enterprise_create_user(
login="newuser",
email="newuser@example.com",
name="New User",
company="ACME Inc."
)
# 更新用户信息(仅限企业版)
mcp_github_enterprise_update_user(
username="octocat",
email="updated-email@example.com",
location="San Francisco"
)
# 暂停用户(仅限企业版)
mcp_github_enterprise_suspend_user(
username="octocat",
reason="违反服务条款"
)
# 取消暂停用户(仅限企业版)
mcp_github_enterprise_unsuspend_user(username="octocat")
# 列出用户所属的组织
mcp_github_enterprise_list_user_orgs(username="octocat")
API 改进
- 灵活的 API URL 配置(支持各种环境变量和命令行参数)
- 增强的错误处理和超时管理
- 用户友好的响应格式和消息
贡献
欢迎贡献!请随时提交 Pull Request。
许可证
ISC
推荐服务器

Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。