mcpField
O
ops-deploy

ops-deploy

github.com/davepoon云与 DevOps3.7k76 次安装今天更新
代码仓库

关于 ops-deploy

ops-deploy 是用于检查 ECS、GitHub Actions 和 Vercel 部署状态的 Claude 技能。它汇总服务与 CI 信息并生成仪表板,提供按状态展示日志查看或经确认的部署操作。

主要功能

  1. 01检查 ECS 集群与服务健康状况
  2. 02查看近期 GitHub Actions 运行
  3. 03查看 Vercel 项目部署
  4. 04生成含相关操作的部署仪表板
  5. 05实时监控部署并跟踪任务

适用场景

  1. 01核对 ECS 服务运行数与目标数
  2. 02查找失败的 CI 运行并查看日志
  3. 03按项目检查近期 Vercel 部署
  4. 04监控正在进行的部署

MCP 相关

使用 Vercel MCP 工具列出项目和部署并获取构建日志。若这些工具不可用,文档提供 Vercel API 备用方式。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/davepoon/buildwithclaude --skill ops-deploy

安装后在 Claude Code 中输入/ops-deploy确认已加载。

详细介绍

OPS ► 部署状态

运行时上下文

执行前,加载可用的上下文:

  1. 偏好设置:读取 ${CLAUDE_PLUGIN_DATA_DIR:-$HOME/.claude/plugins/data/ops-ops-marketplace}/preferences.json

    • timezone — 以正确的时区显示所有部署时间戳
  2. 守护进程健康状态:读取 ${CLAUDE_PLUGIN_DATA_DIR}/daemon-health.json

    • 检查 infra-monitor 状态 — 如果未运行,请注明 ECS 数据可能已过期
  3. 密钥:需要 AWS 和 Vercel 凭据。

    密钥解析
    • AWS:检查 $AWS_PROFILE / $AWS_ACCESS_KEY_ID → doppler secrets get AWS_ACCESS_KEY_ID --plain → 根据偏好设置中的命令查询 vault
    • Vercel 令牌:检查 $VERCEL_TOKEN → doppler secrets get VERCEL_TOKEN --plain → vault

CLI/API 参考

aws CLI
命令用途输出
aws ecs list-clusters --output json所有 ECS 集群{clusterArns: [...]}
aws ecs list-services --cluster <name> --output json集群中的服务{serviceArns: [...]}
aws ecs describe-services --cluster <name> --services <arn> --output json服务健康状态{services: [{serviceName, status, runningCount, desiredCount, pendingCount}]}
aws logs tail /ecs/<service> --since 1h --format shortECS 日志日志行
gh CLI(GitHub)
命令用途输出
gh run list --repo <owner/repo> --limit 5 --json status,conclusion,name,headBranch,createdAt,databaseIdCI 运行记录JSON 数组
gh run view <id> --repo <repo> --log-failed失败的 CI 日志日志输出
gh run watch <run-id> --repo <repo>实时跟踪 CI 运行实时输出(与 Monitor 配合使用)

Agent Teams 支持

如果设置了 CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1,并行检查部署平台时使用 Agent Teams。这样可以:

  • Agent 共享上下文,并能在执行过程中协调
  • 你可以实时调整优先级
  • Agent 完成后会报告进度

团队设置(仅在启用该标志时):

TeamCreate("deploy-team")
Agent(team_name="deploy-team", name="ecs-checker", prompt="List all ECS clusters and describe service health, running/desired counts")
Agent(team_name="deploy-team", name="vercel-checker", prompt="List Vercel projects and recent deployments with status")
Agent(team_name="deploy-team", name="ci-checker", prompt="Check GitHub Actions runs across all registered repos for failures")

如果未设置该标志,则使用标准的即发即弃子 Agent。

阶段 1 — 并行收集部署数据

ECS 服务(所有集群)
${CLAUDE_PLUGIN_ROOT}/bin/ops-infra 2>/dev/null || \
aws ecs list-clusters --output json 2>/dev/null
ECS 服务详情
for cluster in $(aws ecs list-clusters --output json 2>/dev/null | jq -r '.clusterArns[]'); do
  cluster_name=$(basename "$cluster")
  aws ecs list-services --cluster "$cluster_name" --output json 2>/dev/null | \
    jq -r '.serviceArns[]' | while read svc; do
    aws ecs describe-services --cluster "$cluster_name" --services "$svc" \
      --output json 2>/dev/null | jq '.services[] | {name: .serviceName, desired: .desiredCount, running: .runningCount, pending: .pendingCount, image: (.taskDefinition // "unknown"), status: .status}'
  done
done
最近的 GitHub Actions 运行记录(由注册表驱动)
REGISTRY="${CLAUDE_PLUGIN_ROOT}/scripts/registry.json"
[ -f "$REGISTRY" ] || REGISTRY="${CLAUDE_PLUGIN_ROOT}/scripts/registry.example.json"
for repo in $(jq -r '.projects[] | select(.gsd == true) | .repos[]' "$REGISTRY" 2>/dev/null); do
  echo "=== $repo ==="
  gh run list --repo "$repo" --limit 5 --json status,conclusion,name,headBranch,createdAt,databaseId 2>/dev/null
done
Vercel 部署

使用 mcp__claude_ai_Vercel__list_projects,然后对每个项目使用 mcp__claude_ai_Vercel__list_deployments(每个项目最多 5 条)。


阶段 2 — 呈现仪表板

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 OPS ► DEPLOY STATUS — [timestamp]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ECS SERVICES
 CLUSTER    SERVICE         D/R/P   STATUS   LAST DEPLOY
 ─────────────────────────────────────────────────────
 [cluster]  [service]       [x/x/x] ACTIVE   [time ago]
 ...

VERCEL DEPLOYMENTS
 PROJECT     ENV        STATUS    COMMIT    DEPLOYED
 ─────────────────────────────────────────────────────
 [project]   production  READY    [sha]     [time ago]
 ...

CI/CD PIPELINE
 REPO              BRANCH   WORKFLOW        STATUS    AGE
 ─────────────────────────────────────────────────────
 example-api       main     Deploy API      ✓ success  2h
 example-web       dev      Build            ✗ failure  1h
 ...

PENDING DEPLOYS (branch ready, not yet deployed)
 [repo] [branch] [PR#] [CI status] → needs merge to trigger

──────────────────────────────────────────────────────

呈现后,使用批量 AskUserQuestion 调用(每次最多 4 个选项)。仅显示与当前状态相关的操作(例如,没有失败项时,跳过“查看失败服务的日志”)。如果相关操作不超过 4 个,则使用单次调用。如果超过 4 个,则分批调用:

AskUserQuestion 调用 1:

  [View logs for [failing service]]
  [Trigger manual deploy for [project]]
  [View build logs for [failing CI run]]
  [More actions...]

AskUserQuestion 调用 2(仅当选择“更多操作...”时):

  [Check Vercel [project] runtime logs]
  [Open GitHub Actions for [repo]]
  [Back to dashboard]

按项目深入查看

如果 $ARGUMENTS 中有项目别名,则仅显示该项目的部署信息、最近 10 次 CI 运行记录,以及查看日志的选项。

对于失败的部署:提供通过 mcp__claude_ai_Vercel__get_deployment_build_logs 或 ECS CloudWatch 日志查看日志的选项。

如果用户选择手动部署(选项 b),触发前使用 AskUserQuestion 确认:

Trigger deploy for [project]:
  Environment: [production/staging]
  Branch: [branch]
  Last commit: [sha] — [message]

  [Deploy now]  [View diff since last deploy first]  [Cancel]

如果用户选择查看日志,显示日志并使用 AskUserQuestion:

  [Dispatch fix agent for this failure]  [Redeploy]  [Back to dashboard]

原生工具用法

Monitor — 实时部署流

监控进行中的部署时,使用 Monitor 流式查看日志:

Monitor(command: "gh run watch <run-id> --repo <repo>")

对于 ECS 部署:Monitor(command: "aws ecs wait services-stable --cluster <cluster> --services <service>")

Tasks — 部署跟踪

为每个正在部署的项目使用 TaskCreate。部署成功或失败时,使用 TaskUpdate 更新任务。

WebFetch — Vercel 回退方案

当 Vercel MCP 工具不可用时,使用 WebFetch 直接调用 Vercel API:

WebFetch(url: "https://api.vercel.com/v6/deployments?projectId=<id>&limit=5", headers: {"Authorization": "Bearer $VERCEL_TOKEN"})

评论

支持 Markdown