CI/CD管道自动化工具

Pipeline Assistant MCP是一款基于AI的CI/CD管道自动化工具,利用模型上下文协议(MCP)提供上下文感知的管道生成、分析和改进建议,内置安全合规和DevSecOps最佳实践。

  • by soydachi
  • TypeScript
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 soydachi/pipeline-assistant-mcp

使用说明

管道助理MCP

使用模型上下文协议(MCP)的AI驱动的CI/CD流水线自动化

通过有保证的安全合规性和内置的DevSecOps最佳实践,将管道创建从数小时缩短到数秒。


什么是管道助理MCP?

Pipeline Assistant MCP是一个智能系统,它使用AI自动化了完整的CI/CD管道生命周期。它利用了 模型上下文协议(MCP) 提供上下文感知的管道生成、分析和改进建议。

它不仅仅是一个验证工具 -它是一个完整的DevSecOps助手,可以:

  • 从模板生成生产就绪的管道
  • 自动执行公司安全策略
  • 分析现有管道的漏洞
  • 提供可操作的改进建议
  • 跟踪整个组织的合规性指标

为什么选择管道助理MCP?

问题

Developer: "I need to create a pipeline for my .NET microservice"

2-4 hours later...
- Forgot security scanning stage
- Hardcoded database credentials
- Didn't configure dependency caching
- Tests don't generate coverage reports
- Deploys directly to production without approval

Result: Insecure, slow, non-compliant pipeline

解决方案

Developer: "Generate a .NET pipeline for production"

5 seconds later...
- Complete 6-stage pipeline generated
- All 10 security policies applied (SEC-001 to SEC-010)
- Optimized caching configured
- Tests with coverage reporting
- Production deployment with approval gates
- SBOM generation included
- Compliance Score: 98%

Result: Production-ready, secure, compliant pipeline

商业价值

度量 之前 之后 改进
管道创建时间 2-4小时 5秒 速度提高99.9%
安全合规性 ~40% 95%+ +55%
漏洞检测 手动审查 自动 实时
标准采用 不一致 强制执行 100%覆盖率

建筑

系统概述

graph TB
    subgraph "Developer Interfaces"
        CLI[CLI Tools]
        VSC[VS Code Extension]
        CD[Claude Desktop]
        GHA[GitHub Actions]
        ADO[Azure DevOps]
    end

    subgraph "Core Services"
        MCP[MCP Server]
        PG[Pipeline Generator]
        PA[Pipeline Analyzer]
        PE[Policy Enforcer]
        WM[Wiki Manager]
    end

    subgraph "Data Sources"
        WIKI[Corporate Wiki v2.0]
        POL[Security Policies]
        TPL[Platform Templates]
        MET[Adoption Metrics]
    end

    CLI --> MCP
    VSC --> MCP
    CD --> MCP
    GHA --> MCP
    ADO --> MCP

    MCP --> PG
    MCP --> PA
    MCP --> PE
    MCP --> WM

    PG --> WIKI
    PA --> POL
    PE --> POL
    WM --> MET
    PG --> TPL

    style MCP fill:#e1f5fe
    style WIKI fill:#f3e5f5
    style POL fill:#ffebee

组件交互

sequenceDiagram
    participant D as Developer
    participant M as MCP Server
    participant G as Generator
    participant E as Enforcer
    participant W as Wiki

    D->>M: Generate pipeline (dotnet, prod)
    M->>W: Load standards v2.0
    W-->>M: Stages, Policies, SLAs
    M->>G: Create pipeline
    G->>E: Apply security policies
    E-->>G: SEC-001 to SEC-010
    G-->>M: Complete pipeline
    M-->>D: Pipeline + Compliance Score

技术栈

graph LR
    subgraph "Runtime"
        NODE[Node.js 20+]
        TS[TypeScript 5.3]
    end

    subgraph "Protocol"
        MCP[Model Context Protocol]
        STDIO[STDIO Transport]
    end

    subgraph "Testing"
        VIT[Vitest]
        ZOD[Zod Validation]
    end

    subgraph "Integrations"
        AZDO[Azure DevOps API]
        GH[GitHub API]
        VSCE[VS Code API]
    end

    NODE --> TS
    TS --> MCP
    MCP --> STDIO
    TS --> VIT
    TS --> ZOD
    TS --> AZDO
    TS --> GH
    TS --> VSCE

特性

核心能力

  • 多平台支持 -为Azure DevOps和GitHub操作生成管道
  • 管道生成 -从模板(.NET、Node.js、Python、Java、Go)创建完整的管道
  • 证券分析 -检测硬编码的秘密、缺失的安全阶段、15种以上的漏洞类型
  • 政策执行 -自动将SEC-001应用于SEC-010安全策略
  • 合规性评分 -计算0-100分,并进行详细细分
  • SBOM生成 -供应链安全软件物料清单

集成

  • VS代码扩展 -实时分析,快速修复,35+片段
  • 克劳德桌面 -通过MCP生成自然语言管道
  • GitHub 操作 -自动PR分析工作流程
  • Azure DevOps -支持webhook的PR Bot

安全特性

  • Webhook签名验证 -具有定时安全比较功能的HMAC-SHA256
  • 秘密面具 -令牌、密码、API密钥的自动编校
  • 速率限制 -防止滥用的滑动窗口算法
  • 输入验证 -所有用户输入的Zod模式

快速开始

先决条件

  • Node.js 20+和npm 9+
  • Git

安装

git clone https://github.com/soydachi/pipeline-assistant-mcp.git
cd pipeline-assistant-mcp
npm install
npm run build
npm test

基本用法

# Generate a pipeline for Azure DevOps
node dist/cli/pipeline-assistant.js generate \
  --platform azure-devops \
  --type dotnet \
  --env production

# Generate a pipeline for GitHub Actions
node dist/cli/pipeline-assistant.js generate \
  --platform github-actions \
  --type node \
  --env staging

# Analyze a pipeline
node dist/cli/pipeline-assistant.js analyze \
  examples/pipelines/pipeline-con-problemas.yml

# List available platforms
node dist/cli/pipeline-assistant.js platforms

# List available templates
node dist/cli/pipeline-assistant.js templates --platform azure-devops

项目结构

pipeline-assistant-mcp/
├── src/                          # Core MCP server
│   ├── server.ts                 # MCP server entry point
│   ├── pipeline-generator.ts     # Pipeline generation
│   ├── pipeline-analyzer.ts      # Security analysis
│   ├── policy-enforcer.ts        # Policy enforcement
│   ├── wiki-parser.ts            # Standards parser
│   ├── wiki-manager.ts           # Wiki management
│   ├── container.ts              # Dependency injection
│   ├── platforms/                # Multi-platform support
│   │   ├── azure-devops.ts
│   │   └── github-actions.ts
│   ├── azure-devops/             # Azure DevOps integration
│   │   ├── client.ts
│   │   ├── pr-bot.ts
│   │   └── webhook-handler.ts
│   └── utils/                    # Shared utilities
│       ├── logger.ts
│       ├── validation.ts
│       └── rate-limiter.ts
├── cli/                          # Command-line tools
│   ├── pipeline-assistant.ts
│   ├── wiki-cli.ts
│   └── pr-bot-cli.ts
├── vscode-extension/             # VS Code extension
├── wiki/standards/               # Corporate standards v2.0
│   ├── core/                     # Stage definitions
│   ├── security/                 # Security policies
│   ├── quality/                  # Quality gates
│   ├── platforms/                # Platform templates
│   │   ├── azure/templates/
│   │   └── github/templates/
│   ├── migration/                # Migration guides
│   └── governance/               # Governance docs
├── tests/                        # Test suite (341+ tests)
└── examples/                     # Example pipelines

文档

文档 描述
工作坊指南 深入了解架构的完整教程
使用指南 所有平台和配置的参考
贡献 如何为项目做出贡献
更新日志 版本历史和发行说明

集成

MCP服务器(克劳德桌面)

{
  "mcpServers": {
    "pipeline-assistant": {
      "command": "node",
      "args": ["dist/src/server.js"],
      "cwd": "/path/to/pipeline-assistant-mcp"
    }
  }
}

VS代码扩展

cd vscode-extension
npm install && npm run compile
# Press F5 to launch in development mode

Azure DevOps

export AZDO_ORG_URL="https://dev.azure.com/your-org"
export AZDO_PAT="your-personal-access-token"
export AZDO_PROJECT="your-project"

GitHub 操作

添加 .github/workflows/pipeline-review.yml 以自动分析PR。

看 使用指南 详细配置。


标准v2.0

Pipeline Assistant使用结构化标准系统:

安全策略(SEC-001至SEC-010)

策略 名称 级别
SEC-001 秘密扫描 强制要求
SEC-002 SAST分析 强制要求
SEC-003 依赖性扫描 强制要求
SEC-004 集装箱扫描 有条件
SEC-007 DAST 有条件
SEC-008 许可证合规性 强制要求
SEC-010 SBOM生成 强制要求

强制性管道阶段

  1. 验证 -装订、格式化、类型检查
  2. 安全 -所有安全扫描(并行)
  3. 构建 -应用程序构建+SBOM
  4. 测试 -单元+集成测试
  5. 扫描 -集装箱安全
  6. 部署 -环境部署

发展

npm run dev          # Watch mode
npm test             # Run tests (341+ tests)
npm run lint         # Check code style
npm run build        # Build project

测试

# Run all tests
npm test

# Run specific test
npx vitest run tests/policy-enforcer.test.ts

# Run with coverage
npx vitest run --coverage

贡献

我们欢迎捐款!请看 贡献.md 作为指导方针。


许可证

Apache许可证2.0


作者

达奇·果戈楚里 (@ 索达奇)