|
| 1 | +# AWS CI/CD MCP Server |
| 2 | + |
| 3 | +A comprehensive Model Context Protocol (MCP) server for AWS CI/CD services (CodePipeline, CodeBuild, CodeDeploy) with 22 specialized tools, automatic IAM management, and production-ready security features. |
| 4 | + |
| 5 | + |
| 6 | +## Features |
| 7 | + |
| 8 | +- **22 Comprehensive CI/CD Tools**: 7+ tools each for CodePipeline, CodeBuild, and CodeDeploy |
| 9 | +- **Security First**: Read-only mode by default with comprehensive validation |
| 10 | +- **Automatic IAM Management**: Creates and manages service roles with AWS managed policies |
| 11 | +- **Rich Data Retrieval**: CloudWatch logs, deployment details, and execution history |
| 12 | +- **Pagination Support**: Efficient handling of large result sets |
| 13 | +- **Advanced Features**: Source overrides, environment variables, multi-platform support |
| 14 | +- **Robust Error Handling**: Detailed error messages with actionable guidance |
| 15 | + |
| 16 | +## Prerequisites |
| 17 | + |
| 18 | +- **Python 3.10+** installed |
| 19 | +- **AWS CLI configured** with appropriate credentials |
| 20 | +- **Required AWS permissions** for CI/CD services |
| 21 | + |
| 22 | +## Quick Setup |
| 23 | + |
| 24 | +### Option 1: Automated Installation (Recommended) |
| 25 | + |
| 26 | +```bash |
| 27 | +# Clone and install with automatic MCP configuration |
| 28 | +git clone <repository-url> |
| 29 | +cd aws-cicd-mcp-server |
| 30 | +./install.sh |
| 31 | +``` |
| 32 | + |
| 33 | +The install script will: |
| 34 | +- Install the package and dependencies |
| 35 | +- Verify installation works |
| 36 | +- Check AWS credentials |
| 37 | +- Automatically add MCP configuration to `~/.aws/amazonq/mcp.json` |
| 38 | + |
| 39 | +### Option 2: Manual MCP Configuration |
| 40 | + |
| 41 | +If you prefer to manually add the MCP server configuration, add this to your `~/.aws/amazonq/mcp.json`: |
| 42 | + |
| 43 | +```json |
| 44 | +{ |
| 45 | + "mcpServers": { |
| 46 | + "aws-cicd-mcp-server": { |
| 47 | + "command": "python3", |
| 48 | + "args": [ |
| 49 | + "-m", |
| 50 | + "awslabs.aws_cicd_mcp_server.server_fixed" |
| 51 | + ], |
| 52 | + "cwd": "/absolute/path/to/aws-cicd-mcp-server", |
| 53 | + "env": { |
| 54 | + "AWS_PROFILE": "default", |
| 55 | + "AWS_REGION": "us-west-2", # change to your region |
| 56 | + "CICD_READ_ONLY_MODE": "false", # keep false for write operations |
| 57 | + "FASTMCP_LOG_LEVEL": "DEBUG", # can be ERROR, INFO, DEBUG |
| 58 | + "PYTHONPATH": "/absolute/path/to/aws-cicd-mcp-server" |
| 59 | + }, |
| 60 | + "autoApprove": [], |
| 61 | + "disabled": false |
| 62 | + } |
| 63 | + } |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +**Note**: Replace `/absolute/path/to/aws-cicd-mcp-server` with your actual path. |
| 68 | + |
| 69 | +## Environment Variables |
| 70 | + |
| 71 | +| Variable | Description | Default | |
| 72 | +|----------|-------------|---------| |
| 73 | +| `AWS_PROFILE` | AWS credentials profile | default | |
| 74 | +| `AWS_REGION` | AWS region | us-west-2 | |
| 75 | +| `CICD_READ_ONLY_MODE` | Enable read-only mode | false | |
| 76 | +| `FASTMCP_LOG_LEVEL` | Logging level (ERROR/INFO/DEBUG) | DEBUG | |
| 77 | + |
| 78 | +## Available Tools |
| 79 | + |
| 80 | +### CodeBuild (7 tools) |
| 81 | +- `list_projects` - List all projects with pagination |
| 82 | +- `get_project_details` - Get detailed project info with build history |
| 83 | +- `start_build` - Start builds with environment overrides |
| 84 | +- `get_build_logs` - Retrieve CloudWatch logs with error analysis |
| 85 | +- `create_project` - Create projects with auto IAM role |
| 86 | +- `update_project` - Update configuration with change tracking |
| 87 | +- `delete_project` - Safe deletion with running build checks |
| 88 | + |
| 89 | +### CodePipeline (7 tools) |
| 90 | +- `list_pipelines` - List pipelines with execution status |
| 91 | +- `get_pipeline_details` - Get configuration with stage details |
| 92 | +- `start_pipeline_execution` - Start with source overrides |
| 93 | +- `get_pipeline_execution_history` - Detailed execution history |
| 94 | +- `create_pipeline` - Create multi-stage pipelines |
| 95 | +- `update_pipeline` - Update configuration |
| 96 | +- `delete_pipeline` - Safe deletion with execution checks |
| 97 | + |
| 98 | +### CodeDeploy (8 tools) |
| 99 | +- `list_applications` - List applications with platform details |
| 100 | +- `get_application_details` - Get info with deployment groups |
| 101 | +- `create_deployment` - Multi-revision deployments with rollback |
| 102 | +- `get_deployment_status` - Detailed progress with instance details |
| 103 | +- `list_deployment_groups` - Groups with configuration |
| 104 | +- `create_application` - Multi-platform creation (EC2/Lambda/ECS) |
| 105 | +- `create_deployment_group` - Advanced targeting with ASG/ALB |
| 106 | +- `delete_application` - Safe deletion with dependency checks |
| 107 | + |
| 108 | +## Verification |
| 109 | + |
| 110 | +Test the server responds to MCP protocol: |
| 111 | + |
| 112 | +```bash |
| 113 | +python3 -m awslabs.aws_cicd_mcp_server.server_fixed |
| 114 | +``` |
| 115 | + |
| 116 | +## Troubleshooting |
| 117 | + |
| 118 | +### Installation Issues |
| 119 | +```bash |
| 120 | +# Reinstall dependencies |
| 121 | +cd /path/to/aws-cicd-mcp-server |
| 122 | +pip install -e . |
| 123 | +``` |
| 124 | + |
| 125 | +### Server Won't Start |
| 126 | +```bash |
| 127 | +# Check logs with debug mode |
| 128 | +FASTMCP_LOG_LEVEL=DEBUG python3 -m awslabs.aws_cicd_mcp_server.server_fixed |
| 129 | +``` |
| 130 | + |
| 131 | +### AWS Credentials Issues |
| 132 | +```bash |
| 133 | +# Verify credentials |
| 134 | +aws sts get-caller-identity |
| 135 | + |
| 136 | +# Check region |
| 137 | +aws configure get region |
| 138 | +``` |
| 139 | + |
| 140 | +## Sample Usage Examples |
| 141 | + |
| 142 | + |
| 143 | +### CodeBuild |
| 144 | + |
| 145 | +- Use aws-cicd-mcp-server and List all CodeBuild projects in my AWS account |
| 146 | +- Show me detailed information about the CodeBuild project named "SampleProject” |
| 147 | +- Create a new CodeBuild project called "test-project” with GitHub source from https://github.com/aws-samples/automated-devops-ai-toolkit |
| 148 | +- Update the CodeBuild project "test-project" to use BUILD_GENERAL1_MEDIUM compute type |
| 149 | +- Delete the CodeBuild project named "test-project" |
| 150 | +- Start a build for the CodeBuild project "test-project" using the main branch |
| 151 | +- Get the build logs for build "test-project" |
| 152 | + |
| 153 | +### CodePipeline |
| 154 | + |
| 155 | +- List all CodePipeline pipelines in my account |
| 156 | +- Show me detailed configuration of the pipeline named "test-pipeline" |
| 157 | +- Create a new CodePipeline called "test-pipeline" with CodeCommit source from "test-sample-project-repo" |
| 158 | +- Update the pipeline "test-pipeline" to use a different S3 bucket for artifacts |
| 159 | +- Delete the CodePipeline named "test-pipeline" |
| 160 | +- Start execution of the pipeline "test-pipeline" |
| 161 | +- Show me the execution history for pipeline "my-pipeline" |
| 162 | + |
| 163 | +### CodeDeploy |
| 164 | + |
| 165 | +- List all CodeDeploy applications in my account |
| 166 | +- Show me details of the CodeDeploy application "DevAppDeployment" |
| 167 | +- Create a new CodeDeploy application called "DevAppDeployment” for EC2/On-premises |
| 168 | +- Delete the CodeDeploy application "DevAppDeployment” |
| 169 | +- List all deployment groups for the application "DevAppDeployment" |
| 170 | +- Create a deployment group "production" for application "DevAppDeployment” targeting EC2 instances with tag Environment=prod |
| 171 | +- Create a deployment for application "DevAppDeployment” using deployment group "production" with S3 revision from bucket (create bucket first) and then assign the key "app.zip" |
| 172 | +- Check the status of deployment ID "d-KHXYMIF2F" |
| 173 | + |
| 174 | +## Security Best Practices |
| 175 | + |
| 176 | +1. **Use Read-Only Mode** for exploration and testing |
| 177 | +2. **Create Minimal IAM Roles** with only required permissions |
| 178 | +3. **Use AWS Managed Policies** when possible |
| 179 | +4. **Regularly Rotate** AWS access keys |
| 180 | +5. **Monitor CloudTrail** for CI/CD API activity |
| 181 | + |
| 182 | +## Contributing |
| 183 | + |
| 184 | +See the main repository [CONTRIBUTING.md](../../CONTRIBUTING.md) for contribution guidelines. |
| 185 | + |
| 186 | +## License |
| 187 | + |
| 188 | +This library is licensed under the MIT-0 License. See the LICENSE file. |
0 commit comments