Integrates with various AWS services including Cost Explorer, Cost Optimization Hub, Compute Optimizer, Trusted Advisor, and Performance Insights to analyze AWS costs and provide optimization recommendations
Supports integration with Git for version control of the MCP server code and configuration
Hosts the MCP server code repository, allowing users to clone and contribute to the project
Supports Markdown format for report generation, enabling detailed cost optimization reports to be produced in a human-readable format
Uses Python to integrate with AWS services and implement cost optimization analysis capabilities
CFM Tips - Cost Optimization MCP Server
A comprehensive Model Context Protocol (MCP) server for AWS cost analysis and optimization recommendations, designed to work seamlessly with Amazon Q CLI and other MCP-compatible clients.
β Features
Core AWS Services Integration
Cost Explorer - Retrieve cost data and usage metrics
Cost Optimization Hub - Get AWS cost optimization recommendations
Compute Optimizer - Right-sizing recommendations for compute resources
Trusted Advisor - Cost optimization checks and recommendations
Performance Insights - RDS performance metrics and analysis
Cost Optimization Playbooks
π§ EC2 Right Sizing - Identify underutilized EC2 instances
πΎ EBS Optimization - Find unused and underutilized volumes
ποΈ RDS Optimization - Identify idle and underutilized databases
β‘ Lambda Optimization - Find overprovisioned and unused functions
οΏ½ *CloudTrail Optimization - Analyze and optimize CloudTrail configurations
π Comprehensive Analysis - Multi-service cost analysis
Advanced Features
Real CloudWatch Metrics - Uses actual AWS metrics for analysis
Multiple Output Formats - JSON and Markdown report generation
Cost Calculations - Estimated savings and cost breakdowns
Actionable Recommendations - Priority-based optimization suggestions
π Project Structure
π Security and Permissions - Least Privileges
The MCP tools require specific AWS permissions to function.
Create a read-only IAM role - Restricts LLM agents from modifying AWS resources. This prevents unintended create, update, or delete actions.
Enable CloudTrail - Tracks API activity across your AWS account for security monitoring.
Follow least-privilege principles - Grant only essential read permissions (Describe*, List*, Get*) for required services.
The below creates an IAM policy with for list, read and describe actions only:
π οΈ Installation
Prerequisites
Python 3.11 or higher
AWS CLI configured with appropriate credentials
Amazon Q CLI (for MCP integration) - https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html
Setup Steps
Clone the Repository
git clone https://github.com/aws-samples/sample-cfm-tips-mcp.git cd sample-cfm-tips-mcpInstall Dependencies
pip install -r requirements.txtConfigure AWS Credentials
aws configure # Or set environment variables: # export AWS_ACCESS_KEY_ID=your_access_key # export AWS_SECRET_ACCESS_KEY=your_secret_key # export AWS_DEFAULT_REGION=us-east-1Apply IAM Permissions
Create an IAM policy with the permissions listed above
Attach the policy to your IAM user or role
Install the MCP Configurations
python3 setup.pyUsage Option 1: Using the Q CLI Chat
q chat Show me cost optimization recommendationsUsage Option 2: Integrate with Amazon Q Developer Plugin or Kiro
Open Amazon Q Developer Plugin on your IDE
Click on Chat -> π οΈ Configure MCP Servers -> β Add new MCP
Use the following configuration
- Scope: Global - Name: cfm-tips - Transport: stdio - Command: python3 - Arguments: <replace-with-path-to-folder>/mcp_server_with_runbooks.py - Timeout: 60
π§ Available Tools
Cost Analysis Tools
get_cost_explorer_data
- Retrieve AWS cost and usage datalist_coh_enrollment
- Check Cost Optimization Hub enrollmentget_coh_recommendations
- Get cost optimization recommendationsget_coh_summaries
- Get recommendation summariesget_compute_optimizer_recommendations
- Get compute optimization recommendations
EC2 Optimization
ec2_rightsizing
- Analyze EC2 instances for right-sizing opportunitiesec2_report
- Generate detailed EC2 optimization reports
EBS Optimization
ebs_optimization
- Analyze EBS volumes for optimizationebs_unused
- Identify unused EBS volumesebs_report
- Generate EBS optimization reports
RDS Optimization
rds_optimization
- Analyze RDS instances for optimizationrds_idle
- Identify idle RDS instancesrds_report
- Generate RDS optimization reports
Lambda Optimization
lambda_optimization
- Analyze Lambda functions for optimizationlambda_unused
- Identify unused Lambda functionslambda_report
- Generate Lambda optimization reports
Comprehensive Analysis
comprehensive_analysis
- Multi-service cost analysis
Additional Tools
get_trusted_advisor_checks
- Get Trusted Advisor recommendationsget_performance_insights_metrics
- Get RDS Performance Insights data
π Example Usage
Basic Cost Analysis
Resource Optimization
Report Generation
Multi-Service Analysis
π Troubleshooting
Common Issues
Cost Optimization Hub Not Working
python3 diagnose_cost_optimization_hub_v2.pyNo Metrics Found
Ensure resources have been running for at least 14 days
Verify CloudWatch metrics are enabled
Check that you're analyzing the correct region
Permission Errors
Verify IAM permissions are correctly applied
Check AWS credentials configuration
Ensure Cost Optimization Hub is enabled in AWS Console
Import Errors
# Check Python path and dependencies python3 -c "import boto3, mcp; print('Dependencies OK')"
Getting Help
Check the RUNBOOKS_GUIDE.md for detailed usage instructions
Run the diagnostic script:
python3 diagnose_cost_optimization_hub_v2.py
Run integration tests:
python3 test_runbooks.py
π§© Add-on MCPs
Add-on AWS Pricing MCP Server MCP server for accessing real-time AWS pricing information and providing cost analysis capabilities https://github.com/awslabs/mcp/tree/main/src/aws-pricing-mcp-server
π― Key Benefits
Immediate Cost Savings - Identify unused resources for deletion
Right-Sizing Opportunities - Optimize overprovisioned resources
Real Metrics Analysis - Uses actual CloudWatch data
Actionable Reports - Clear recommendations with cost estimates
Comprehensive Coverage - Analyze EC2, EBS, RDS, Lambda, and more
Easy Integration - Works seamlessly with Amazon Q CLI
π Expected Results
The CFM Tips cost optimization server can help you:
Identify cost savings on average
Find unused resources costing hundreds of dollars monthly
Right-size overprovisioned instances for optimal performance/cost ratio
Optimize storage costs through volume type recommendations
Eliminate idle resources that provide no business value
π€ Contributing
We welcome contributions! Please see our contributing guidelines:
Fork the repository
Create a feature branch
Make your changes
Add tests for new functionality
Submit a pull request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
This server cannot be installed
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.
A comprehensive Model Context Protocol server that analyzes AWS costs and provides optimization recommendations by integrating with services like Cost Explorer, Cost Optimization Hub, and Trusted Advisor.
Related MCP Servers
- AsecurityFlicenseAqualityA Model Context Protocol server that integrates with AWS CodePipeline, allowing users to manage pipelines through Windsurf and Cascade using natural language commands.Last updated -124
- AsecurityFlicenseAqualityA comprehensive Model Context Protocol server for advanced code analysis that provides tools for syntax analysis, dependency visualization, and AI-assisted development workflow support.Last updated -284
Log Analyzer with MCPofficial
-securityAlicense-qualityA Model Context Protocol server that provides AI assistants access to AWS CloudWatch Logs, enabling browsing, searching, summarizing, and correlating logs across multiple AWS services.Last updated -129Apache 2.0- AsecurityFlicenseAqualityA Model Context Protocol server that provides tools for accessing and managing AWS VPC Lattice information, allowing users to list sources and retrieve sample prompts related to AWS networking documentation.Last updated -51