mcpField
G
GitHub Enterprise MCP Server

GitHub Enterprise MCP Server

本地服务
github.com/containerelic版本控制2959 周前更新

关于 GitHub Enterprise MCP Server

GitHub Enterprise MCP Server 是一个 MCP 服务,用于通过 GitHub Enterprise API 在 Cursor 等客户端中访问仓库、Issue、PR 和 Actions 工作流。主要面向 GitHub Enterprise Server 环境,也兼容 GitHub.com 与 GitHub Enterprise Cloud。

主要功能

  1. 01查询仓库列表与详细信息
  2. 02管理 Issue 与 Pull Request
  3. 03管理仓库设置(创建、更新、删除)
  4. 04查看与触发 GitHub Actions 工作流
  5. 05管理用户与查看企业统计信息

适用场景

  1. 01在 Cursor 中查看与创建 Pull Request
  2. 02通过 AI 对话管理企业内部仓库的 Issue
  3. 03查询与触发 GitHub Actions 工作流

MCP 相关

该项目是 MCP 服务,通过 list-repositories、create-issue、trigger-workflow 等工具向 MCP 客户端提供 GitHub Enterprise 的操作能力。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"github-enterprise-mcp-containerelic": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"build"
]
}
}
}
启动命令docker run -i --rm build

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
ocibuild

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

MseeP.ai Security Assessment Badge

Trust Score

GitHub Enterprise MCP 服务

image

一个用于与 GitHub Enterprise API 集成的 MCP(Model Context Protocol)服务。此服务提供 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 实例
  • Personal Access Token (PAT)
Docker 安装和设置
选项 1:使用 Docker 运行
  1. 构建 Docker 镜像:

    docker build -t github-enterprise-mcp .
    
  2. 使用环境变量运行 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
  1. 在项目根目录创建 .env 文件,并写入所需的环境变量:

    GITHUB_ENTERPRISE_URL=https://github.your-company.com/api/v3
    GITHUB_TOKEN=your_github_token
    DEBUG=true
    
  2. 使用 Docker Compose 启动容器:

    docker-compose up -d
    
  3. 查看日志:

    docker-compose logs -f
    
  4. 停止容器:

    docker-compose down
    
安装和设置
本地开发(使用并发模式)

此方法推荐用于活跃开发,支持自动重新编译和重启服务:

  1. 克隆仓库并安装所需软件包:

    git clone https://github.com/ddukbg/github-enterprise-mcp.git
    cd github-enterprise-mcp
    npm install
    
  2. 运行开发服务:

    export GITHUB_TOKEN="your_github_token"
    export GITHUB_ENTERPRISE_URL="https://github.your-company.com/api/v3"
    npm run dev
    

    这将:

    • 在文件发生更改时自动编译 TypeScript 代码
    • 在编译后的文件更新时重启服务
    • 以 HTTP 模式运行服务,以便通过 URL 连接
  3. 按照下文所述,使用 URL 模式连接到 Cursor

生产环境的安装和设置
选项 1:使用 URL 模式(推荐用于本地开发)

此方法最稳定,推荐用于本地开发或测试:

  1. 克隆仓库并安装所需软件包:

    git clone https://github.com/ddukbg/github-enterprise-mcp.git
    cd github-enterprise-mcp
    npm install
    
  2. 构建项目:

    npm run build
    chmod +x dist/index.js
    
  3. 运行服务:

    export GITHUB_TOKEN="your_github_token"
    export GITHUB_ENTERPRISE_URL="https://github.your-company.com/api/v3"
    node dist/index.js --transport http --debug
    
  4. 使用 URL 模式连接到 Cursor:

    • 将以下内容添加到 Cursor 的 .cursor/mcp.json 文件中:
    {
      "mcpServers": {
        "github-enterprise": {
          "url": "http://localhost:3000/sse"
        }
      }
    }
    
选项 2:安装为全局命令(npm link)

此方法适用于本地开发:

# After cloning the repository
git clone https://github.com/ddukbg/github-enterprise-mcp.git
cd github-enterprise-mcp

# Install required packages
npm install

# Build
npm run build
chmod +x dist/index.js

# Link globally
npm link

# Run as a global command
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 模式:

  1. 在单独的终端窗口中启动服务:

    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
    
  2. 配置 Cursor 的 MCP 设置:

    • 打开 Cursor,然后前往 Settings
    • 前往 AI > MCP Servers
    • 编辑 .cursor/mcp.json 文件:
    {
      "mcpServers": {
        "github-enterprise": {
          "url": "http://localhost:3000/sse"
        }
      }
    }
    
  3. 重启 Cursor 以应用更改

替代方案:命令模式

你也可以将 Cursor 配置为使用命令模式,但 URL 模式更可靠:

  1. 打开 Cursor,然后前往 Settings
  2. 前往 AI > MCP Servers
  3. 点击 Add MCP Server
  4. 输入以下详细信息:
    • 名称:GitHub Enterprise
    • 命令:npx
    • 参数:@ddukbg/github-enterprise-mcp
    • 环境变量:
      • GITHUB_ENTERPRISE_URL:GitHub Enterprise API URL
      • GITHUB_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"
      }
    }
  }
}

语言配置

此 MCP 服务支持英语和韩语。你可以通过以下方式配置语言:

环境变量
# Set language to Korean
export LANGUAGE=ko

# Or in .env file
LANGUAGE=ko
命令行参数
# Set language to Korean
node dist/index.js --language ko

如果未指定,默认语言为英语。

HTTP 模式下的其他选项

  • --debug:启用调试日志
  • --github-enterprise-url <URL>:设置 GitHub Enterprise API URL
  • --token <TOKEN>:设置 GitHub 个人访问令牌
  • --language <LANG>:设置语言(en 或 ko,默认值:en)

可用的 MCP 工具

此 MCP 服务提供以下工具:

工具名称描述参数所需的 PAT 权限
list-repositories获取用户或组织的仓库列表owner:用户名/组织名称
isOrg:是否为组织
type:仓库类型
sort:排序条件
page:页码
perPage:每页项目数
repo
get-repository获取仓库详细信息owner:仓库所有者
repo:仓库名称
repo
list-branches列出仓库的分支owner:仓库所有者
repo:仓库名称
protected_only:是否只显示受保护的分支
page:页码
perPage:每页项目数
repo
get-content获取文件或目录内容owner:仓库所有者
repo:仓库名称
path:文件/目录路径
ref:分支/提交(可选)
repo
list-pull-requests列出仓库中的拉取请求owner:仓库所有者
repo:仓库名称
state:PR 状态筛选条件
sort:排序条件
direction:排序方向
page:页码
per_page:每页项目数
repo
get-pull-request获取拉取请求详情owner:仓库所有者
repo:仓库名称
pull_number:拉取请求编号
repo
create-pull-request创建新的拉取请求owner:仓库所有者
repo:仓库名称
title:PR 标题
head:源分支
base:目标分支
body:PR 描述
draft:创建为草稿 PR
repo
merge-pull-request合并拉取请求owner:仓库所有者
repo:仓库名称
pull_number:拉取请求编号
merge_method:合并方式
commit_title:提交标题
commit_message:提交信息
repo
list-issues列出仓库中的议题owner:仓库所有者
repo:仓库名称
state:议题状态筛选条件
sort:排序条件
direction:排序方向
page:页码
per_page:每页项目数
repo
get-issue获取议题详情owner:仓库所有者
repo:仓库名称
issue_number:议题编号
repo
list-issue-comments列出议题或拉取请求中的评论owner:仓库所有者
repo:仓库名称
issue_number:议题/PR 编号
page:页码
per_page:每页项目数
repo
create-issue创建新议题owner:仓库所有者
repo:仓库名称
title:议题标题
body:议题正文内容
labels:标签名称数组
assignees:用户登录名数组
milestone:里程碑 ID
repo
create-repository创建新仓库name:仓库名称
description:仓库描述
private:是否为私有仓库
auto_init:使用 README 初始化
gitignore_template:添加 .gitignore
license_template:添加许可证
org:组织名称
repo
update-repository更新仓库设置owner:仓库所有者
repo:仓库名称
description:新描述
private:更改隐私设置
default_branch:更改默认分支
has_issues:启用/禁用议题
has_projects:启用/禁用项目
has_wiki:启用/禁用 wiki
archived:归档/取消归档
repo
delete-repository删除仓库owner:仓库所有者
repo:仓库名称
confirm:确认(必须为 true)
delete_repo
list-workflows列出 GitHub Actions 工作流owner:仓库所有者
repo:仓库名称
page:页码
perPage:每页项目数
actions:read
list-workflow-runs列出工作流运行记录owner:仓库所有者
repo:仓库名称
workflow_id:工作流 ID/文件名
branch:按分支筛选
status:按状态筛选
page:页码
perPage:每页项目数
actions:read
trigger-workflow触发工作流owner:仓库所有者
repo:仓库名称
workflow_id:工作流 ID/文件名
ref:Git 引用
inputs:工作流输入
actions:write
get-license-info获取 GitHub Enterprise 许可证信息-需要 site_admin(管理员)账户
get-enterprise-stats获取 GitHub Enterprise 系统统计信息-需要 site_admin(管理员)账户

注意:对于 Enterprise 专用工具(get-license-info 和 get-enterprise-stats),需要具有站点管理员权限的用户。建议使用 Classic Personal Access Token,因为 Fine-grained token 可能不支持这些 Enterprise 级别的权限。

在 Cursor 中使用工具

设置 MCP 服务并配置 Cursor 连接到该服务后,你可以直接在 Cursor 的 AI 聊天中使用 GitHub Enterprise 工具。以下是一些示例:

列出仓库
mcp_github_enterprise_list_repositories(owner="octocat")
获取仓库信息
mcp_github_enterprise_get_repository(owner="octocat", repo="hello-world")
列出 Pull Request
mcp_github_enterprise_list_pull_requests(owner="octocat", repo="hello-world", state="open")
管理议题
# List issues
mcp_github_enterprise_list_issues(owner="octocat", repo="hello-world", state="all")
# Get issue details
mcp_github_enterprise_get_issue(owner="octocat", repo="hello-world", issue_number=1)

# Get issue/PR comments
mcp_github_enterprise_list_issue_comments(owner="octocat", repo="hello-world", issue_number=1)


# Create a new issue
mcp_github_enterprise_create_issue(
  owner="octocat", 
  repo="hello-world",
  title="Found a bug",
  body="Here is a description of the bug",
  labels=["bug", "important"]
)
使用仓库内容
mcp_github_enterprise_get_content(owner="octocat", repo="hello-world", path="README.md")
仓库管理
# Create a new repository
mcp_github_enterprise_create_repository(
  name="new-project",
  description="This is a new project",
  private=true,
  auto_init=true
)

# Update repository settings
mcp_github_enterprise_update_repository(
  owner="octocat",
  repo="hello-world",
  description="Updated description",
  has_issues=true
)
用户管理(仅限 Enterprise)

这些功能专为 GitHub Enterprise Server 环境设计,需要管理员权限:

# List all users in the GitHub Enterprise instance
mcp_github_enterprise_list_users(filter="active", per_page=100)

# Get a specific user's details
mcp_github_enterprise_get_user(username="octocat")

# Create a new user (Enterprise only)
mcp_github_enterprise_create_user(
  login="newuser",
  email="[email protected]",
  name="New User",
  company="ACME Inc."
)

# Update a user's information (Enterprise only)
mcp_github_enterprise_update_user(
  username="octocat",
  email="[email protected]",
  location="San Francisco"
)

# Suspend a user (Enterprise only)
mcp_github_enterprise_suspend_user(
  username="octocat",
  reason="Violation of terms of service"
)

# Unsuspend a user (Enterprise only)
mcp_github_enterprise_unsuspend_user(username="octocat")

# List organizations a user belongs to
mcp_github_enterprise_list_user_orgs(username="octocat")

API 改进

  • 灵活配置 API URL(支持各种环境变量和命令行参数)
  • 增强错误处理和超时管理
  • 更易于用户理解的响应格式和消息

贡献

欢迎贡献!请随时提交 Pull Request。

许可证

ISC

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。