AWS CodePipeline MCP Server

by cuongdev
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Manages environment variables for the MCP server, including AWS credentials and configuration settings.

  • Used for cloning the MCP server repository during the installation process.

  • Enables creation of webhooks for GitHub integration with AWS CodePipeline, supporting features like triggering pipelines based on GitHub events such as commits to specific branches.

AWS CodePipeline MCP 服务器

这是一个与 AWS CodePipeline 集成的模型上下文协议 (MCP) 服务器,允许您通过 Windsurf 和 Cascade 管理管道。该服务器提供了与 AWS CodePipeline 服务交互的标准化接口。

作者: Cuong T Nguyen

特征

  • 列出所有管道
  • 获取管道状态和详细的管道定义
  • 列出管道执行
  • 批准或拒绝手动批准操作
  • 重试失败的阶段
  • 触发管道执行
  • 查看管道执行日志
  • 停止管道执行
  • 标记管道资源
  • 创建用于自动管道触发的 Webhook
  • 获取管道性能指标

先决条件

  • Node.js(v14 或更高版本)
  • 具有 CodePipeline 访问权限的 AWS 账户
  • 具有 CodePipeline、CloudWatch 和 IAM(用于标记)权限的 AWS 凭证
  • 带有 Cascade AI 助手的 Windsurf IDE

安装

  1. 克隆此存储库:
git clone https://github.com/cuongdev/mcp-codepipeline-server.git cd mcp-codepipeline-server
  1. 安装依赖项:
npm install
  1. 根据.env.example模板创建.env文件:
cp .env.example .env
  1. 使用您的 AWS 凭证和配置更新.env文件:
AWS_REGION=us-east-1 AWS_ACCESS_KEY_ID=your_access_key_id AWS_SECRET_ACCESS_KEY=your_secret_access_key PORT=3000

注意:为了安全起见,切勿将您的.env文件提交到版本控制。

用法

构建项目

npm run build

启动服务器

npm start

对于自动重启的开发:

npm run dev

与 Windsurf 集成

该 MCP 服务器旨在与 Windsurf 配合使用,允许 Cascade 通过自然语言请求与 AWS CodePipeline 进行交互。

设置步骤

  1. 确保服务器正在运行:
npm start
  1. 将服务器配置添加到 Windsurf MCP 配置文件~/.codeium/windsurf/mcp_config.json中:
{ "mcpServers": { "codepipeline": { "command": "npx", "args": [ "-y", "path/to/mcp-codepipeline-server/dist/index.js" ], "env": { "AWS_REGION": "us-east-1", "AWS_ACCESS_KEY_ID": "your_access_key_id", "AWS_SECRET_ACCESS_KEY": "your_secret_access_key" } } } }
  1. 如果目录不存在则创建该目录:
mkdir -p ~/.codeium/windsurf touch ~/.codeium/windsurf/mcp_config.json
  1. 重新启动 Windsurf 以加载新的 MCP 服务器配置

与 Cascade 一起使用

配置完成后,您可以在 Windsurf 中使用自然语言与 AWS CodePipeline 进行交互。例如:

  • “列出我的所有 CodePipeline 管道”
  • “显示我的‘生产部署’管道的当前状态”
  • “触发‘测试构建’管道”
  • “获取我的‘数据处理’管道的指标”
  • “为我的‘前端部署’管道创建一个 webhook”

Cascade 会将这些请求转换为适当的 MCP 工具调用。

MCP 工具

核心管道管理

工具名称描述参数
list_pipelines列出所有 CodePipeline 管道没有任何
get_pipeline_state获取特定管道的状态pipelineName :管道的名称
list_pipeline_executions列出特定管道的执行pipelineName :管道的名称
trigger_pipeline触发管道执行pipelineName :管道的名称
stop_pipeline_execution停止管道执行pipelineName :管道的名称executionId :执行 ID reason :可选的停止原因

管道详细信息和指标

工具名称描述参数
get_pipeline_details获取管道的完整定义pipelineName :管道的名称
get_pipeline_execution_logs获取管道执行的日志pipelineName :管道的名称executionId :执行 ID
get_pipeline_metrics获取管道的性能指标pipelineName :管道名称period :可选指标周期(以秒为单位) startTime :可选指标开始时间endTime :可选指标结束时间

管道操作和集成

工具名称描述参数
approve_action批准或拒绝手动批准操作pipelineName :管道的名称stageName :阶段的名称actionName :操作的名称token :批准令牌approved :表示批准或拒绝的布尔值comments :可选注释
retry_stage重试失败的阶段pipelineName :管道的名称stageName :阶段的名称pipelineExecutionId :执行 ID
tag_pipeline_resource添加或更新管道资源的标签pipelineName :管道的名称tags :用于标记的键值对数组
create_pipeline_webhook为管道创建 webhookpipelineName :管道的名称webhookName :webhook 的名称targetAction :webhook 的目标操作authentication :身份验证类型authenticationConfiguration :可选的身份验证配置filters :可选的事件过滤器

故障排除

常见问题

  1. 连接被拒绝错误
    • 确保服务器在指定端口上运行
    • 检查端口是否被防火墙阻止
  2. AWS 凭证错误
    • .env文件中验证您的 AWS 凭证
    • 确保您的 IAM 用户具有必要的权限
  3. Windsurf 未检测到 MCP 服务器
    • 检查mcp_config.json文件格式
    • 确保服务器 URL 正确
    • 更改后重新启动 Windsurf

日志

服务器将信息记录到控制台。检查以下日志以进行故障排除:

# Run with more verbose logging DEBUG=* npm start

示例

为 GitHub 集成创建 Webhook

{ "pipelineName": "my-pipeline", "webhookName": "github-webhook", "targetAction": "Source", "authentication": "GITHUB_HMAC", "authenticationConfiguration": { "SecretToken": "my-secret-token" }, "filters": [ { "jsonPath": "$.ref", "matchEquals": "refs/heads/main" } ] }

获取管道指标

{ "pipelineName": "my-pipeline", "period": 86400, "startTime": "2025-03-10T00:00:00Z", "endTime": "2025-03-17T23:59:59Z" }

执照

国际学习中心

ID: urm7jwtady