Claude Skills + MCP Server:在几分钟内创建一致的 AWS 成本报告
Source: Dev.to
引言
本文对希望自动化月度成本报告工作流的 FinOps 工程师非常有用。FinOps 关注高效管理云成本,但每月创建一致的高管报告既耗时又容易出错。大多数公司在云基础设施上的支出巨大,CTO 需要清晰、标准化的报告来跟踪支出趋势。一个每月生成结构相同的专业成本报告的系统可以消除质量参差不齐的临时提示。
在本指南中,你将学习如何构建一个将 MCP Server 与 AWS Cost Explorer 结合的 Claude Skill,以在几分钟内创建确定性的、可直接交付给高管的成本报告。配置完成后,你再也不需要手动编写复杂提示。
什么是 MCP Server?
MCP(Model Context Protocol)Server 是一种技术,允许 Claude 等 AI 助手直接连接外部工具和数据源。它充当 Claude 与你的云基础设施之间的桥梁。
在此情境下,AWS Cost Explorer MCP Server 使 Claude 能够:
- 调用 AWS Cost Explorer API
- 实时获取实际支出数据
- 分析使用模式
- 检索详细的成本细分
如果没有 MCP,你必须手动从 AWS 导出成本数据、格式化并粘贴到 Claude 中。有了 MCP,Claude 能自动访问这些数据。
什么是 Claude Skills?
Claude Skills 是可重用的专家模板。你不必每次都解释需求,而是创建一个包含所有指令、偏好和指南的 skill 文件。每当调用 Claude 时,它都会完美遵循这份“剧本”。
对于 FinOps 报告,这意味着:
- 每月拥有相同的专业结构
- 一致的分析框架
- 不会遗漏任何需求
- 确保交付高管就绪的格式
创建 Claude Skill 的前置条件
在创建 skill 之前,先准备好必要的工具和权限:
- 安装 Claude Desktop – 从 claude.ai/download 下载
- 添加 AWS Cost Explorer MCP Server – 在 Claude Desktop 设置中通过配置文件添加 MCP 服务器
- 配置 AWS IAM 权限 – 创建具备 Cost Explorer 读取权限的 IAM 用户并配置凭证
有关 MCP 服务器和 IAM 配置的详细设置说明,请参阅 AWS Cost Explorer MCP Server 文档。
创建 AWS 成本报告 Skill
步骤式工作流
- 向 Claude 询问:“帮助我创建一个用于生成月度 AWS 成本报告的 skill。”
- Claude 会就以下内容提出澄清问题:
- 你使用的数据源和工具
- 基础设施组织方式(标签、环境)
- 高管期望的报告结构
- 所需的细节层级和可视化形式
- 必要的分析和建议
- 根据你的回答,Claude 自动生成一个包含详细、结构化指令的 skill 文件。该文件定义了 Claude 如何获取数据、进行分析、生成可视化并格式化最终报告。
- 将生成的 skill 文件保存到 Claude Desktop。
- 使用该 skill 时,只需输入触发短语,例如:
Use the AWS Cost CEO Report skill to compare November and December 2025 costs.
Claude 将遵循 skill 文件中的指令,始终交付一致、专业的报告。
示例 Claude Skill 参考文件
# AWS Cost CEO Report Skill - Quick Reference
## 🚀 Quick Start
AWS cost report for the CEO - September vs October 2025
## ✅ Prerequisites Checklist
- [ ] All Cost Explorer MCP servers are started
- [ ] You have cost data for the months you want to compare
## 🎯 Trigger Phrases
| What to Say | What It Does |
|-------------------------------------|--------------------------------------|
| "AWS cost report for the CEO" | Generates full report for all accounts |
| "Compare September vs October 2025"| Month‑to‑month comparison |
| "Production account only" | Limits to single account |
| "We implemented VPC endpoints..." | Includes savings actions analysis |
## 📊 Report Includes
- Executive summary with key metrics
- Visual charts and graphs
- Per‑account breakdowns
- Cost driver analysis
- Optimization recommendations
- PDF export capability
## 🎨 Report Filters
- Shows only services with > $50/month spend
- Analyzes services with > 10 % change **or** > $100 change
- Focuses on top cost drivers
## 💡 Pro Tips
1. **Monthly Cadence** – Generate reports at month‑end.
2. **Include Context** – Mention infrastructure changes or savings actions.
3. **Review Trends** – Look for unexpected cost increases.
4. **Act on Recommendations** – Follow the optimization section.
5. **Export PDF** – Use browser print function to save as PDF.
## 🚨 Common Issues
| Issue | Solution |
|---------------------------|--------------------------------------------|
| MCP servers not accessible| Start Docker Desktop and MCP containers |
| Invalid month format | Use "September 2025" not "9/2025" |
| No data returned | Check dates aren't in the future |
## 📈 Cost Optimization Areas Analyzed
- EC2 instance rightsizing
- NAT Gateway optimization (VPC endpoints)
- Data transfer costs
- Idle resources
- Over‑provisioned infrastructure
- Development environment scheduling
- Storage lifecycle policies
- Reserved Instance opportunities
## 🎓 Example Requests
**Basic Report:**
`Generate AWS cost report for the CEO comparing September vs October 2025`
**With Savings Context:**
`AWS cost report for September vs October 2025. Actions taken: Implemented VPC endpoints, migrated to Graviton instances, enabled S3 Intelligent Tiering.`
## 📦 Skill Components
- Main workflow instructions (`SKILL.md`)
- MCP usage patterns (`references/mcp-usage.md`)
- Report structure guide (`references/report-structure.md`)
- HTML template reference (`scripts/generate_report.py`)
## 🔍 Analysis Depth
- **Level 1:** Service‑level cost comparison
- **Level 2:** Usage‑type breakdown (instance types, hours)
- **Level 3:** Root cause identification
- **Level 4:** Contextual analysis with recommendations
## 💰 Cost Leak Detection
The skill automatically flags:
- Unexpected spikes > 20 %
- High data transfer costs
- NAT Gateway optimization opportunities
- Idle resources
- Over‑provisioned instances
- 24/7 dev/test environments
- Legacy unused resources
## 📄 Export to PDF
1. Open artifact in a new window
2. Press **Ctrl+P** (or **Cmd+P** on Mac)
3. Select “Save as PDF”
4. Adjust settings if needed
5. Save and share!
对 FinOps 团队的收益
- 可复现性: 每月报告质量保持一致
- 可扩展性: 轻松为多个账户/地区生成报告
- 合规性: 标准化格式满足审计要求
- 上手快: 新成员无需大量培训即可生成报告
- 持续演进: 只需一次更新 skill,即可提升所有后续报告
结论
MCP Server 与 Claude Skills 的结合,将 FinOps 报告从需要数天手工完成的过程,转变为几分钟即可自动化的工作流。你将获得 AI 驱动的快速分析,同时保持高管所需的专业度和一致性。