shantgup/enhanced-cfn-mcp-server
If you are the rightful owner of enhanced-cfn-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Enhanced CloudFormation MCP Server is a sophisticated tool designed to improve AWS CloudFormation management through intelligent prompting, autonomous fixing, and comprehensive resource management.
get_resource_schema_information
Get schema information for AWS resource types
list_resources
List AWS resources of a specified type
get_resource
Get detailed information about a specific resource
create_resource
Create new AWS resources
update_resource
Update existing AWS resources using JSON Patch
delete_resource
Delete AWS resources
get_resource_request_status
Check status of long-running operations
deploy_cloudformation_stack
Deploy stacks with comprehensive configuration
get_stack_status
Get detailed stack status with operational analysis
delete_cloudformation_stack
Safely delete stacks with resource retention options
detect_stack_drift
Detect and analyze configuration drift
generate_cloudformation_template
Generate templates from natural language with intelligent conversation flow
create_template
Generate templates from existing AWS resources
analyze_template_structure
Comprehensive template analysis with security and compliance checks
detect_template_capabilities
Analyze templates for required IAM capabilities
troubleshoot_cloudformation_stack
Expert troubleshooting with systematic investigation
fix_and_retry_cloudformation_stack
Intelligent fix-and-retry with detailed guidance
autonomous_fix_and_deploy_stack
Fully autonomous deployment with iterative fixing
generate_template_fixes
Generate and optionally apply template fixes
cloudformation_best_practices_guide
Expert best practices guidance for infrastructure issues
prevent_out_of_band_changes
Prevent manual changes to CloudFormation-managed resources
Enhanced CloudFormation MCP Server
An enhanced AWS CloudFormation Model Context Protocol (MCP) server that provides intelligent prompting, autonomous fixing, and comprehensive AWS resource management capabilities for AI assistants like Amazon Q.
Table of Contents
- π What is this?
- β¨ Key Features & Differentiators
- π οΈ Available Tools
- π Prerequisites
- π Installation & Setup
- π‘ Usage Examples
- ποΈ Architecture
- π§ Configuration
- π§ͺ Development
- π Examples
- π€ Contributing
- π License
- π Support
- π Acknowledgments
- πΊοΈ Roadmap
π What is this?
This is an enhanced version of the AWS CloudFormation MCP server that extends the original functionality with:
- Intelligent Prompt Generation: Creates expert-level prompts that guide AI assistants to provide comprehensive CloudFormation analysis and solutions
- Autonomous Template Fixing: Automatically detects and fixes common CloudFormation template issues
- Enhanced Troubleshooting: Provides detailed error analysis with step-by-step resolution guidance
- Best Practices Integration: Built-in AWS best practices and security recommendations
- Comprehensive Resource Management: Full CRUD operations for AWS resources via CloudFormation types
β¨ Key Features & Differentiators
π§ Intelligent AI Guidance
- Expert Prompt Engineering: Transforms simple requests into comprehensive, expert-level prompts
- Context-Aware Analysis: Provides detailed investigation workflows with specific CLI commands
- Multi-Stage Conversations: Guides through discovery, refinement, validation, and generation phases
π§ Autonomous Problem Solving
- Auto-Fix Templates: Automatically identifies and fixes common CloudFormation issues
- Iterative Deployment: Continues fixing and redeploying until successful
- Smart Error Recovery: Analyzes failures and applies appropriate fixes
π Enhanced Troubleshooting
- Root Cause Analysis: Deep investigation of CloudFormation failures
- CloudWatch Integration: Automatic log analysis and error correlation
- CloudTrail Analysis: API call investigation for comprehensive debugging
π‘οΈ Security & Best Practices
- Security Vulnerability Detection: Identifies potential security issues in templates
- Compliance Framework Alignment: Supports HIPAA, PCI, SOX, GDPR compliance checks
- Cost Optimization: Provides cost-aware recommendations
π οΈ Available Tools
Core Resource Management
Tool | Description |
---|---|
get_resource_schema_information | Get schema information for AWS resource types |
list_resources | List AWS resources of a specified type |
get_resource | Get detailed information about a specific resource |
create_resource | Create new AWS resources |
update_resource | Update existing AWS resources using JSON Patch |
delete_resource | Delete AWS resources |
get_resource_request_status | Check status of long-running operations |
CloudFormation Stack Management
Tool | Description |
---|---|
deploy_cloudformation_stack | Deploy stacks with comprehensive configuration |
get_stack_status | Get detailed stack status with operational analysis |
delete_cloudformation_stack | Safely delete stacks with resource retention options |
detect_stack_drift | Detect and analyze configuration drift |
Template Generation & Analysis
Tool | Description |
---|---|
generate_cloudformation_template | Generate templates from natural language with intelligent conversation flow |
create_template | Generate templates from existing AWS resources |
analyze_template_structure | Comprehensive template analysis with security and compliance checks |
detect_template_capabilities | Analyze templates for required IAM capabilities |
Enhanced Troubleshooting & Fixing
Tool | Description |
---|---|
troubleshoot_cloudformation_stack | Expert troubleshooting with systematic investigation |
fix_and_retry_cloudformation_stack | Intelligent fix-and-retry with detailed guidance |
autonomous_fix_and_deploy_stack | Fully autonomous deployment with iterative fixing |
generate_template_fixes | Generate and optionally apply template fixes |
Best Practices & Guidance
Tool | Description |
---|---|
cloudformation_best_practices_guide | Expert best practices guidance for infrastructure issues |
prevent_out_of_band_changes | Prevent manual changes to CloudFormation-managed resources |
π Prerequisites
- Python 3.10+
- AWS CLI configured with appropriate credentials
- Amazon Q CLI (for integration)
- AWS Account with necessary permissions
Required AWS Permissions
Your AWS credentials need permissions for:
- CloudFormation operations (
cloudformation:*
) - CloudControl API operations (
cloudcontrol:*
) - Resource-specific permissions (e.g.,
s3:*
,ec2:*
) - CloudWatch Logs access (
logs:*
) - CloudTrail access (
cloudtrail:LookupEvents
)
π Installation & Setup
1. Install the Package
# Clone the repository
git clone https://github.com/shantgup/enhanced-cfn-mcp-server.git
cd enhanced-cfn-mcp-server
# Install the package
pip install -e .
2. Configure AWS Credentials
# Configure AWS CLI
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-1
3. Integration with Amazon Q CLI
If you run q in the root directory of this project, the enhanced_cfn_mcp_server should be loaded automatically, it's configured in the .amazonq directory.
Optionally, you can add the MCP server to your Q CLI configuration like below:
{
"mcpServers": {
"enhanced-cfn": {
"command": "enhanced-cfn-mcp-server",
"args": [],
"env": {}
}
}
}
4. Verify Installation
# Test through Q CLI
q chat
# Then ask: "Use the enhanced cfn mcp server to create a robust web server architecture cloudformation template. Then deploy it, and if it fails, troubleshoot it, fix the template and redeploy until successful."
π‘ Usage Examples
π₯ One-shot Prompt
π Generate template, deploy, troubleshoot, fix and redeploy until successful π
# Generate template, deploy, troubleshoot, fix and redeploy until successful
"Use the enhanced cfn mcp server to create a <INSERT USE CASE HERE>. Then deploy it, and if it fails, troubleshoot it, fix the template and redeploy until successful."
# Use case examples:
- robust web server architecture
- secure VPC with public and private subnets
- serverless API with Lambda and API Gateway
- multi-AZ RDS database setup
- static website hosting with S3 and CloudFront
- auto-scaling application with ALB
- containerized application using ECS
- serverless data processing pipeline
- high-availability WordPress site
- CI/CD pipeline with CodePipeline
- cross-region backup solution
- ElasticSearch cluster
- EKS cluster with worker nodes
- real-time data streaming architecture
- multi-region active-active setup
Basic Resource Management
# In Q CLI chat
q chat
# List all S3 buckets
"List all my S3 buckets"
# Get details of a specific bucket
"Show me details of my bucket named 'my-app-bucket'"
# Create a new S3 bucket
"Create an S3 bucket named 'my-new-bucket' with versioning enabled"
CloudFormation Operations
# Generate a template from description
"Create a CloudFormation template for a web application with ALB, ECS, and RDS"
# Deploy a stack
"Deploy a CloudFormation stack named 'my-web-app' using the template in ./template.yaml"
# Troubleshoot a failed deployment
"My CloudFormation stack 'my-app-stack' failed to deploy. Help me troubleshoot it."
# Autonomous fixing and deployment
"Automatically fix and deploy my CloudFormation stack 'problematic-stack'"
Advanced Analysis
# Analyze template for issues
"Analyze my CloudFormation template for security vulnerabilities and best practices"
# Detect stack drift
"Check if my production stack has any configuration drift"
# Get best practices guidance
"I need to implement a HIPAA-compliant data processing pipeline. What are the best practices?"
ποΈ Architecture
Enhanced CFN MCP Server
βββ Core MCP Server (FastMCP)
βββ AWS Client Management
βββ CloudFormation Stack Manager
βββ Resource Schema Manager
βββ Intelligent Prompt Generator
βββ Template Analysis Engine
βββ Autonomous Fixing Engine
βββ Best Practices Database
Key Components
- FastMCP Framework: Provides the MCP server foundation
- AWS Integration: Boto3-based AWS service clients
- CloudControl API: Unified resource management interface
- Template Generator: Natural language to CloudFormation conversion
- Error Analysis: Comprehensive failure analysis and resolution
- Prompt Engineering: Expert-level prompt generation for AI guidance
π§ Configuration
Environment Variables
# AWS Configuration
AWS_REGION=us-east-1
AWS_PROFILE=default
# Server Configuration
MCP_SERVER_PORT=3000
LOG_LEVEL=INFO
# Feature Flags
ENABLE_AUTO_FIX=true
ENABLE_SECURITY_ANALYSIS=true
MAX_FIX_ITERATIONS=5
π§ͺ Development
Setup Development Environment
# Clone and setup
git clone https://github.com/shantgup/enhanced-cfn-mcp-server.git
cd enhanced-cfn-mcp-server
# Install development dependencies
pip install -e ".[dev]"
# Setup pre-commit hooks
pre-commit install
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=awslabs
# Run only unit tests (skip live AWS tests)
pytest -m "not live"
Code Quality
# Format code
ruff format .
# Lint code
ruff check .
# Type checking
pyright
π Examples
See the directory for comprehensive usage examples:
- - Simple resource management
- - Complex deployment scenarios
- - Amazon Q specific examples
- - Natural language to CloudFormation
- - Error resolution workflows
π€ Contributing
We welcome contributions! Please see for guidelines.
Development Workflow
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Run the test suite
- Submit a pull request
π License
This project is licensed under the Apache License 2.0 - see the file for details.
π Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Project Wiki
π Acknowledgments
- Built on the foundation of AWS Labs MCP
- Powered by the Model Context Protocol
- Enhanced for Amazon Q Developer
πΊοΈ Roadmap
- Enhanced Template Generation: More sophisticated natural language processing
- Multi-Account Support: Cross-account resource management
- Advanced Security Analysis: Integration with AWS Security Hub
- Cost Optimization: Real-time cost analysis and recommendations
- Infrastructure Visualization: Automatic architecture diagram generation
- Compliance Automation: Automated compliance checking and reporting
Made with β€οΈ for the AWS community