CI/CD工作流编排服务

一个基于Model Context Protocol (MCP) v1.0的服务器,用于通过JSON-RPC 2.0 over HTTP编排GitHub Actions和Jenkins的CI/CD工作流。

  • by padawanabhi
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 padawanabhi/ci_orchestrator_mcp

使用说明

CI编排器MCP服务器

一个模型上下文协议(MCP)v1.0服务器,用于通过HTTP使用JSON-RPC 2.0在GitHub Actions(包括自托管运行器)和Jenkins之间编排CI/CD工作流。

特性

  • 列出并触发GitHub Actions工作流、运行者和作业
  • 列出并触发Jenkins作业、流日志
  • JSON-RPC 2.0 API(MCP v1.0)
  • 通过SSE/JSON-RPC通知实时传输日志
  • 基于安全令牌的身份验证
  • 用于演示和手动测试的Web UI

快速启动

1.克隆和安装

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

2.配置环境

复制 .env.example 向 .env 并填写您的GitHub和Jenkins凭据。

所需的环境变量:

  • GITHUB_TOKEN:GitHub个人访问令牌(经典或细粒度)
  • GITHUB_OWNER:GitHub组织或用户名
  • GITHUB_REPO:GitHub存储库名称

建议的GitHub令牌权限:

  • repo, workflow, admin:org, admin:repo_hook
  • 对于细粒度令牌:“操作:读写”、“自托管运行程序:读”和仓库访问

3.运行服务器

uvicorn src.main:app --host 0.0.0.0 --port 8080

4.Web用户界面(演示)

打开 webui/index.html 在您的浏览器中。UI将连接到您正在运行的MCP服务器 http://localhost:8080.

UI允许您:

  • 列出GitHub工作流、运行和运行者
  • 触发工作流
  • 工作流运行的流日志(带有作业/步骤上下文)
  • 查看错误消息和状态

5.Docker

docker build -t ci-orchestrator .
docker run --env-file .env -p 8080:8080 ci-orchestrator

API

  • 发布 /jsonrpc --JSON-RPC 2.0端点
  • 获取 /healthz --健康检查
  • 获取 /stream/logs?run_id=... --工作流运行的流日志(SSE)

github/execute 方法

参数:

  • action:其中之一 trigger_workflow, cancel_run, rerun_run, fetch_logs
  • 其他字段取决于操作:
    • trigger_workflow: workflow_id (int), ref (str), inputs (字典,可选)
    • cancel_run/rerun_run/fetch_logs: run_id (int)

示例:

触发工作流:

{
  "jsonrpc": "2.0",
  "method": "github/execute",
  "params": {
    "action": "trigger_workflow",
    "workflow_id": 123456,
    "ref": "main",
    "inputs": {"param1": "value"}
  },
  "id": 1
}

取消工作流运行:

{
  "jsonrpc": "2.0",
  "method": "github/execute",
  "params": {
    "action": "cancel_run",
    "run_id": 789012
  },
  "id": 2
}

获取运行日志:

{
  "jsonrpc": "2.0",
  "method": "github/execute",
  "params": {
    "action": "fetch_logs",
    "run_id": 789012
  },
  "id": 3
}

光标集成

您可以通过在中指向本地MCP服务器,直接将此服务器与Cursor的MCP客户端一起使用 cursor.yaml:

mcpServers:
  - name: ci-orchestrator
    command: ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8080"]
    transport: http
    port: 8080

发展

  • Python 3.11+
  • FastAPI、httpx、pytest

许可证

麻省理工学院