云成本分析代理

一个基于A2A协议和MCP工具层的代理服务器,专为分析AWS云支出而设计,提供投资级云经济报告和优化建议。

  • by mrichman
  • Go
  • 本地部署
  • 更新于
在 GitHub 查看 mrichman/cloud-economics-agent

使用说明

云经济代理

一 A2A 由内部支持的(代理到代理)协议服务器 主控程序 (模型上下文协议)工具层,专为分析PE投资组合公司的AWS云支出而构建。该代理接受自然语言分析请求,调用结构化成本工具,并生成具有优先优化建议的投资级云经济报告。

建筑

┌───────────────────────────────────────────────────────────────────────┐
│                         External Clients                              │
│               (other agents, dashboards, CLIs)                        │
└─────────────────────────────┬─────────────────────────────────────────┘
                              │  HTTP (JSON-RPC 2.0 / SSE)
┌─────────────────────────────▼─────────────────────────────────────────┐
│                      A2A Agent Server (:8080)                         │
│                                                                       │
│  Agent Card Discovery    JSON-RPC Dispatch    SSE Streaming           │
│  GET /.well-known/       POST /               task.status             │
│    agent.json                                 task.artifact           │
│                                                                       │
│                    ┌───────────────────┐                              │
│                    │    Agent Core     │                              │
│                    │  classify → fetch │                              │
│                    │  → analyze → emit │                              │
│                    └─────────┬─────────┘                              │
└──────────────────────────────┼────────────────────────────────────────┘
                               │  HTTP (internal)
┌──────────────────────────────▼────────────────────────────────────────┐
│                      MCP Tool Server (:8081)                          │
│                                                                       │
│  get_ec2_costs          get_rds_costs       get_savings_plan_coverage │
│  get_s3_costs           get_data_transfer   get_idle_resources        │
│  get_portfolio_companies                    get_commitment_plan       │
│                                                                       │
│  GET  /tools/list    POST /tools/call                                 │
└───────────────────────────────────────────────────────────────────────┘

这 A2A服务器 处理代理发现、JSON-RPC调度和SSE流。这 MCP服务器 展示了8个成本分析工具。代理对自然语言请求进行分类,调用适当的工具,并生成带有PE受众框架(EBITDA影响、投资组合级别建议)的降价报告。

快速开始

# Start both servers
make run

# Or manually:
go run ./cmd/mcp-server &   # Terminal 1
go run ./cmd/a2a-server     # Terminal 2

示例

# Discover the agent
curl -s http://localhost:8080/.well-known/agent.json | jq .name
# "Cloud Economics Agent"

# Run a portfolio roll-up (synchronous)
curl -s -X POST http://localhost:8080/ \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "message/send",
    "params": {
      "message": {
        "role": "user",
        "parts": [{"type": "text", "text": "Run a full portfolio roll-up analysis"}]
      }
    }
  }' | jq '.result.artifacts[0].parts[0].text' -r

# Stream with real-time progress
curl -N -X POST http://localhost:8080/ \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "message/stream",
    "params": {
      "message": {
        "role": "user",
        "parts": [{"type": "text", "text": "Analyze EC2 spend for account 111222333444"}]
      }
    }
  }'

# Call an MCP tool directly
curl -s -X POST http://localhost:8081/tools/call \
  -H "Content-Type: application/json" \
  -d '{"name": "get_ec2_costs", "parameters": {"account_id": "111222333444", "period_days": 30}}' | jq .

文档

文档 描述
建筑 系统设计、请求流、包结构、设计决策
API 参考 为两台服务器提供完整的HTTP API,并提供示例
工具目录 所有8个带参数、模式和示例的MCP工具
开发指南 本地运行、测试、添加新工具、代码约定
部署指导 Docker、Compose、TLS、健康检查、可观察性、生产考虑因素

分析类型

该代理支持9种分析模式,按自然语言分类:

请求 示例 使用的工具
EC2分析 “分析EC2支出” EC2成本+节省覆盖率
RDS分析 “数据库成本明细” RDS成本+节约覆盖率
S3分析 “S3存储成本” S3成本
数据传输 “出口成本分析” 数据传输成本
空闲资源 “查找未使用的资源” 空闲资源检测
储蓄覆盖率 “RI覆盖率分析” 储蓄计划覆盖率+EC2
承诺计划 “承诺优化器” 承诺计划器
全面分析 “全面成本分析” 一个账户的所有工具
投资组合汇总 “投资组合汇总” 所有工具,所有账户(并行)

测试

make test              # Run all tests
go test -race ./...    # With race detector