Token导航 LogoToken导航TokenDH.com
Devops AI Agent logo
运维云端stdio官方级别未说明来源级核验

Devops AI Agent

MCP Server

基于AWS Bedrock AgentCore的智能DevOps代理,使用Model Context Protocol (MCP)管理AWS基础设施、监控资源健康状况并通过Microsoft Teams报告事件。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
DevopsPythonClaudeClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

HK-9

提供方

HK-9

最后核验

2026/5/17 20:22

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python -m venv .venv

详细介绍

DevOps人工智能代理

构建在以下基础上的智能DevOps代理 AWS基岩代理核心 使用 模型上下文协议(MCP) 通过Microsoft Teams管理AWS基础架构、监控资源运行状况和报告事件。

建筑

flowchart LR
    subgraph Triggers
        CW[CloudWatch Alarm] --> EB[EventBridge Rule]
        EB --> LH[Lambda Handler]
    end

    subgraph Agent
        LH --> AC[AgentCore\nReasoning Loop]
        AC --> MC[MCP Client]
    end

    subgraph MCP Servers
        MC --> AWS[AWS Infra Server\nEC2 tools]
        MC --> MON[Monitoring Server\nCloudWatch tools]
        MC --> TMS[Teams Server\nWebhook tools]
    end

    AWS --> EC2[(EC2)]
    MON --> CWM[(CloudWatch\nMetrics)]
    TMS --> TEA[(Teams\nWebhook)]

快速开始

# 1. Create & activate virtual environment
python -m venv .venv
.venv\Scripts\activate          # Windows PowerShell
source .venv/bin/activate       # Linux / macOS

# 2. Install dependencies (dev + infra extras)
make install
# or manually:
pip install -e ".[dev,infra]"

# 3. Run linter & type checker
make lint
make typecheck

# 4. Run tests
make test

# 5. Start an MCP server locally (stdio transport)
make run-mcp-aws

CDK部署

先决条件

# Install the CDK CLI (one-time)
npm install -g aws-cdk

# Bootstrap CDK in your account/region (one-time)
cdk bootstrap aws://650251690796/ap-southeast-2

部署所有堆栈

# Activate venv first
.venv\Scripts\activate

# Deploy everything (Networking → Monitoring → Runner)
cdk deploy --all --require-approval never

部署单个堆栈

# Monitoring stack (CloudWatch alarm + EventBridge rule)
cdk deploy DevOpsAgent-Monitoring --require-approval never

# Agent Runner stack (Lambda function)
cdk deploy DevOpsAgent-Runner --require-approval never

其他CDK命令

# Synthesize CloudFormation templates (no deploy)
cdk synth

# Show diff between deployed and local
cdk diff

# Destroy all stacks
cdk destroy --all

CDK上下文(cdk.json)

以下上下文值配置部署:

关键字描述示例
regionAWS区域ap-southeast-2
monitored_instance_id要监视的EC2实例i-0bf11b006e8f12844

测试Lambda

使用测试事件调用

CloudWatch警报事件示例见 test_event.json:

aws lambda invoke \
  --function-name devops-ai-agent-handler \
  --payload fileb://test_event.json \
  --cli-binary-format raw-in-base64-out \
  response.json \
  --region ap-southeast-2

查看响应

# Linux / macOS
cat response.json | python -m json.tool

# Windows PowerShell
Get-Content response.json | python -m json.tool

预期成功响应

{
  "statusCode": 200,
  "body": {
    "alarm_name": "devops-agent-high-cpu",
    "instance_id": "i-0bf11b006e8f12844",
    "agent_response": "...",
    "tool_calls_count": 3,
    "session_id": "..."
  }
}

运行测试

# All tests
make test
# or: pytest -v

# Unit tests only
make test-unit
# or: pytest tests/unit/ -v

# Integration tests only
make test-integration
# or: pytest tests/integration/ -v

装订和格式化

# Lint (check only)
make lint

# Auto-format + fix
make format

# Type check with mypy
make typecheck

在本地运行MCP服务器

make run-mcp-aws          # AWS Infra server (EC2 tools)
make run-mcp-monitoring   # Monitoring server (CloudWatch tools)
make run-mcp-teams        # Teams server (webhook tools)

基岩模型验证

# List available models
aws bedrock list-foundation-models \
  --region ap-southeast-2 \
  --by-provider Anthropic \
  --query "modelSummaries[].modelId" \
  --output json

# Test direct model invocation
aws bedrock-runtime invoke-model \
  --model-id "amazon.nova-lite-v1:0" \
  --region ap-southeast-2 \
  --body '{"inputText":"hello"}' \
  --content-type application/json \
  response_model.json

# Test inline agent from Python
python -c "
import boto3
c = boto3.client('bedrock-agent-runtime', region_name='ap-southeast-2')
r = c.invoke_inline_agent(
    foundationModel='amazon.nova-lite-v1:0',
    instruction='You are a helpful DevOps assistant that diagnoses infrastructure issues.',
    sessionId='test-123',
    inputText='Say hello',
)
print([e for e in r['completion']])
"

清理

# Remove Python caches and build artifacts
make clean

# Destroy all deployed AWS resources
cdk destroy --all

目录结构

devops-ai-agent/
├── infra/                        # IaC (CDK stacks)
│   ├── stacks/
│   │   ├── monitoring_stack.py   # CloudWatch alarms, EventBridge rules
│   │   ├── agent_runner_stack.py # Lambda for agent invocation
│   │   └── networking_stack.py   # VPC, subnets, security groups
│   └── app.py
├── src/
│   ├── agent/
│   │   ├── agent_core.py         # AgentCore client & reasoning bridge
│   │   ├── system_prompt.py      # Agent persona & instructions
│   │   └── config.py             # Env-based settings (Pydantic)
│   ├── mcp_servers/
│   │   ├── aws_infra/            # MCP server: EC2 tools
│   │   ├── monitoring/           # MCP server: CloudWatch metrics
│   │   └── teams/                # MCP server: Teams webhook
│   ├── mcp_client/
│   │   └── client.py             # Unified MCP client adapter
│   ├── handlers/
│   │   ├── lambda_handler.py     # EventBridge → Agent entry point
│   │   └── event_parser.py       # Alarm event → typed dataclass
│   └── utils/
│       ├── aws_helpers.py        # Shared boto3 helpers
│       └── teams_webhook.py      # Low-level webhook HTTP helper
├── tests/
├── demo.py                       # 🚀 Interactive demo — see below
├── pyproject.toml
├── Makefile
└── README.md

演示/帮助脚本

跑吧 demo.py 每个模块的指导性演练脚本:

python demo.py

它将:

  1. 展示如何加载配置
  2. 演示MCP工具发现和调用(模拟)
  3. 模拟EventBridge报警事件解析
  4. 模拟团队通知
  5. 展示完整的代理端到端推理流程

先决条件

要求注意事项
Python 3.12+必填
已配置AWS CLI用于boto3凭据
AWS基岩代理核心访问请求Claude模型访问
Microsoft Teams webhook URL创建传入的webhook连接器
CDK-CLI(npm i -g aws-cdk)用于部署基础设施

环境变量

变量描述默认值
AWS_REGIONAWS区域us-east-1
BEDROCK_MODEL_ID基岩模型标识符anthropic.claude-3-5-sonnet-20241022-v2:0
AGENT_ID基岩药剂ID(内联模式省略)--
AGENT_ALIAS_ID基岩药剂别名(内联模式省略)--
TEAMS_WEBHOOK_URL团队传入Webhook URL--
TOOL_TIMEOUT_SECONDS每次工具调用超时30
LAMBDA_TIMEOUT_SECONDSLambda函数超时300
MAX_REASONING_TURNS最大代理推理迭代次数10
LOG_LEVEL日志记录级别INFO
LOG_FORMAT日志格式(jsontext)json
内联模式与注册模式:AGENT_IDAGENT_ALIAS_ID 两者都已设置,代理将使用 invoke_agent (预先注册)。如果省略,则使用 invoke_inline_agent (在每个请求中内联发送系统提示和工具)。

许可证

麻省理工学院

目录标签

目录标签

DevopsPythonClaude本地部署AWS基础设施管理资源监控事件报告

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP