返回市场
github企业版mcp

github企业版mcp

作者:ddukbg25 星标更新:2025-09-14

项目介绍

MseeP.ai 安全评估徽章

信任评分

GitHub Enterprise MCP 服务器

image

这是一个用于与 GitHub Enterprise API 集成的 MCP(模型上下文协议)服务器。此服务器提供了一个 MCP 接口,可以轻松地从 GitHub Enterprise 在 Cursor 中访问存储库信息、问题、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 运行

  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)

此方法适用于本地开发:

# 克隆仓库后
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_TOKENYOUR_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 并进入 设置
    • 导航至 AI > MCP 服务器
    • 编辑你的 .cursor/mcp.json 文件:
    {
      "mcpServers": {
        "github-enterprise": {
          "url": "http://localhost:3000/sse"
        }
      }
    }
    
  3. 重启 Cursor 以应用更改

替代方案:命令模式

或者,你可以配置 Cursor 使用命令模式,尽管 URL 模式更可靠:

  1. 打开 Cursor 并进入 设置
  2. 导航至 AI > MCP 服务器
  3. 点击 添加 MCP 服务器
  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 服务器支持英语和韩语。你可以通过以下方式配置语言:

环境变量

# 设置语言为韩语
export LANGUAGE=ko

# 或在 .env 文件中
LANGUAGE=ko

命令行参数

# 设置语言为韩语
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: 用户名/组织名<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: 头部分支<br>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
list-issue-comments列出问题或拉取请求上的评论owner: 存储库所有者<br>repo: 存储库名称<br>issue_number: 问题/PR 编号<br>page: 页码<br>per_page: 每页项数repo
create-issue创建新的问题owner: 存储库所有者<br>repo: 存储库名称<br>title: 问题标题<br>body: 问题正文内容<br>labels: 标签名称数组<br>assignees: 用户登录名数组<br>milestone: 里程碑 IDrepo
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: 启用/禁用维基<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-infoget-enterprise-stats),需要具有 site administrator 特权的用户。建议使用经典个人访问令牌,因为细粒度令牌可能不支持这些企业级别的权限。

在 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)

# 获取问题/PR 评论
mcp_github_enterprise_list_issue_comments(owner="octocat", repo="hello-world", issue_number=1)


# 创建新问题
mcp_github_enterprise_create_issue(
  owner="octocat", 
  repo="hello-world",
  title="发现了一个 bug",
  body="这里是关于该 bug 的描述",
  labels=["bug", "重要"]
)

处理存储库内容

mcp_github_enterprise_get_content(owner="octocat", repo="hello-world", path="README.md")

存储库管理

# 创建新存储库
mcp_github_enterprise_create_repository(
  name="新项目",
  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