GitHub 动作触发器 MCP 服务器
用于 GitHub Actions 集成的模型上下文协议服务器。
概述
这是一个基于 TypeScript 的 MCP 服务器,专为 GitHub Actions 集成而设计。它提供以下功能:
Related MCP server: GitHub MCP Server
特征
工具
get_github_actions - 获取存储库可用的 GitHub Actions
必需参数: owner (仓库所有者,用户名或组织)和repo (仓库名称)
可选参数: token (GitHub个人访问令牌,用于访问私有仓库或增加API速率限制)
返回包含工作流 ID、名称、路径、状态、URL 和内容的 JSON 数据
get_github_action - 获取有关特定 GitHub Action 的详细信息,包括输入及其要求
trigger_github_action - 触发 GitHub 工作流并传递相关参数
必需参数:
可选参数:
ref :触发工作流程的 git 引用(默认值:'main')
inputs :传递给工作流的输入(必须与工作流定义的输入匹配)
token :GitHub 个人访问令牌(必须具有工作流范围)
返回工作流运行信息,包括状态、URL 等。
get_github_release - 从 GitHub 存储库获取最新的 2 个版本
安装
推荐安装:使用 npx
最简单的安装和使用方法是通过 Claude Desktop 配置文件中的npx命令,无需手动本地安装:
{
"mcpServers": {
"github-action-trigger-mcp": {
"command": "npx",
"args": [
"-y",
"@nextdrive/github-action-trigger-mcp"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "your_github_token_here"
}
}
}
}
此方法的好处:
无需安装本地包
自动使用最新版本
一次设置即可使用
内置 GitHub 令牌配置
本地安装
如果您希望手动安装,请按照以下步骤操作:
安装软件包:
npm install -g @nextdrive/github-action-trigger-mcp
在 Claude Desktop 配置中使用:
在 MacOS 上: ~/Library/Application Support/Claude/claude_desktop_config.json在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"github-action-trigger-mcp": {
"command": "@nextdrive/github-action-trigger-mcp",
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "your_github_token_here"
}
}
}
}
GitHub 令牌配置
要访问 GitHub API(尤其是私有仓库或工作流触发器),您需要配置 GitHub 个人访问令牌。有几种方法可以做到这一点:
方法一(推荐):在 Claude Desktop 中直接配置
通过env字段直接在 Claude Desktop 配置文件中设置令牌:
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "your_github_token_here"
}
方法二:全局环境变量
设置GITHUB_TOKEN环境变量:
# On Linux/MacOS
export GITHUB_TOKEN=your_github_token
# On Windows
set GITHUB_TOKEN=your_github_token
方法三:本地配置文件
编辑配置文件:
~/.nextdrive-github-action-trigger-mcp/config.json
设置你的 GitHub 令牌:
{
"githubToken": "your_github_token"
}
服务器第一次启动时会自动创建此配置文件的模板。
发展
安装依赖项:
构建服务器:
对于开发过程中的自动重建:
调试
使用 MCP Inspector 进行调试:
检查器将提供一个 URL 来访问浏览器中的调试工具。
发布到 npm
如果要将此包发布到 npm,请按照以下步骤操作:
确保您已登录 npm 并具有发布到@nextdrive组织的权限:
构建项目:
发布到 npm(组织范围的包默认是私有的,使用--access public将其公开):
npm publish --access public
发布后,任何人都可以使用npx @nextdrive/github-action-trigger-mcp命令运行此工具或在其 Claude Desktop 配置中使用它。
使用示例
获取 GitHub Actions 列表
使用get_github_actions工具获取存储库的 GitHub Actions:
{
"owner": "username-or-org",
"repo": "repository-name"
}
如果配置了默认令牌,则访问私有存储库时将自动使用它。
响应示例:
[
{
"id": 12345678,
"name": "CI",
"path": ".github/workflows/ci.yml",
"state": "active",
"url": "https://github.com/owner/repo/actions/workflows/ci.yml",
"content": "name: CI\n\non:\n push:\n branches: [ main ]\n pull_request:\n branches: [ main ]\n\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v2\n - name: Setup Node.js\n uses: actions/setup-node@v2\n with:\n node-version: 16.x\n - name: Install dependencies\n run: npm ci\n - name: Build\n run: npm run build\n - name: Test\n run: npm test\n"
}
]
获取详细的 GitHub Action 信息
使用get_github_action工具获取特定 Action 的详细信息:
{
"owner": "actions",
"repo": "checkout",
"ref": "v4"
}
响应示例:
{
"name": "Checkout",
"description": "Check out a Git repository at a particular version",
"author": "GitHub",
"inputs": [
{
"name": "repository",
"description": "Repository name with owner. For example, actions/checkout",
"default": "",
"required": false
},
{
"name": "ref",
"description": "The branch, tag or SHA to checkout.",
"default": "",
"required": false
}
],
"runs": {
"using": "node20",
"main": "dist/index.js"
}
}
触发 GitHub 工作流
使用trigger_github_action工具触发GitHub工作流程:
{
"owner": "username-or-org",
"repo": "repository-name",
"workflow_id": "ci.yml",
"inputs": {
"deploy_environment": "production",
"debug_enabled": "true"
}
}
响应示例:
{
"success": true,
"message": "Workflow dispatch event triggered successfully",
"run": {
"id": 12345678,
"url": "https://github.com/owner/repo/actions/runs/12345678",
"status": "queued",
"conclusion": null,
"created_at": "2025-03-19T06:45:12Z",
"triggered_by": "API"
}
}
注意:触发工作流需要:
必须配置工作流以支持workflow_dispatch事件
GitHub 令牌必须具有workflow范围权限
传递的输入参数必须与工作流中定义的参数匹配
获取最新版本
使用get_github_release工具从存储库获取最新的 2 个版本:
{
"owner": "username-or-org",
"repo": "repository-name"
}
响应示例:
{
"count": 2,
"releases": [
{
"id": 12345678,
"name": "v1.0.0",
"tag_name": "v1.0.0",
"published_at": "2025-03-15T10:00:00Z",
"draft": false,
"prerelease": false,
"html_url": "https://github.com/owner/repo/releases/tag/v1.0.0",
"body": "Release notes for version 1.0.0",
"assets": [
{
"name": "app-v1.0.0.zip",
"size": 1234567,
"download_count": 42,
"browser_download_url": "https://github.com/owner/repo/releases/download/v1.0.0/app-v1.0.0.zip",
"created_at": "2025-03-15T10:05:00Z",
"updated_at": "2025-03-15T10:05:00Z"
}
],
"author": {
"login": "username",
"html_url": "https://github.com/username"
}
},
{
"id": 87654321,
"name": "v0.9.0",
"tag_name": "v0.9.0",
"published_at": "2025-03-01T10:00:00Z",
"draft": false,
"prerelease": true,
"html_url": "https://github.com/owner/repo/releases/tag/v0.9.0",
"body": "Pre-release notes for version 0.9.0",
"assets": [],
"author": {
"login": "username",
"html_url": "https://github.com/username"
}
}
]
}