MCP HubMCP Hub
alexei-led

aws-mcp-server

by: alexei-led

A lightweight service that enables AI assistants to execute AWS CLI commands (in safe containerized environment) through the Model Context Protocol (MCP). Bridges Claude, Cursor, and other MCP-aware AI tools with AWS CLI for enhanced cloud infrastructure management.

73created 19/03/2025
Visit
AWS
MCP

📌Overview

Purpose: The AWS Model Context Protocol (MCP) Server is designed to facilitate the execution of AWS CLI commands by AI assistants through the Model Context Protocol, enhancing their functionality and accessibility.

Overview: The AWS MCP Server acts as an intermediary between MCP-aware AI assistants (e.g., Claude Desktop, Cursor, Windsurf) and the AWS CLI. It allows these AI tools to efficiently access AWS resources and services by retrieving documentation and executing commands, which are then returned in a format that is easily understood by users.

Key Features:

  • Command Documentation: Provides detailed help on AWS CLI commands to assist users in understanding available options and usage effectively.

  • Command Execution: Enables the running of AWS CLI commands and returns the results in a human-readable format, streamlining the interaction with AWS services.

  • Unix Pipe Support: Allows filtering and transformation of AWS CLI output using standard Unix utilities, enhancing data processing capabilities.

  • Prompt Templates: Offers predefined templates for common AWS tasks that help users follow best practices without needing deep technical knowledge.

  • Docker Integration: Simplifies deployment with containerization, supporting multiple architectures (AMD64/x86_64 and ARM64) for broad compatibility.

  • AWS Authentication: Utilizes existing AWS credentials from the host machine, ensuring secure and seamless access to AWS services.


AWS Model Context Protocol (MCP) Server

A lightweight service that enables AI assistants to execute AWS CLI commands through the Model Context Protocol (MCP).

Overview

The AWS MCP Server provides a bridge between MCP-aware AI assistants (like Claude Desktop, Cursor, Windsurf) and the AWS CLI. It enables these assistants to:

  1. Retrieve AWS CLI documentation (aws_cli_help) - Get detailed help on AWS services and commands
  2. Execute AWS CLI commands (aws_cli_pipeline) - Run commands with Unix pipes and receive formatted results optimized for AI consumption
flowchart LR
    AI[AI Assistant] <-->|MCP Protocol| Server[AWS MCP Server]
    Server <-->|Subprocess| AWS[AWS CLI]
    AWS <-->|API| Cloud[AWS Cloud]

Features

  • Command Documentation - Detailed help information for AWS CLI commands
  • Command Execution - Execute AWS CLI commands and return human-readable results
  • Unix Pipe Support - Filter and transform AWS CLI output using standard Unix pipes and utilities
  • AWS Resources Context - Access to AWS profiles, regions, account information, and environment details via MCP Resources
  • Prompt Templates - Pre-defined prompt templates for common AWS tasks following best practices
  • Docker Integration - Simple deployment through containerization with multi-architecture support (AMD64/x86_64 and ARM64)
  • AWS Authentication - Leverages existing AWS credentials on the host machine

Requirements

  • Docker (recommended) or Python 3.13+ (and AWS CLI installed locally)
  • AWS credentials configured

Getting Started

Note: For security and reliability, running the server inside a Docker container is the strongly recommended method. Please review the Security Considerations section for important considerations.

Run Server Option 1: Using Docker (Recommended)

# Clone repository
git clone https://github.com/alexei-led/aws-mcp-server.git
cd aws-mcp-server

# Build and run Docker container
docker compose -f deploy/docker/docker-compose.yml up -d

The Docker image supports both AMD64/x86_64 (Intel/AMD) and ARM64 (Apple Silicon M1-M4, AWS Graviton) architectures.

You can pull the official image:

# Use the latest stable version
docker pull ghcr.io/alexei-led/aws-mcp-server:latest

# Or pin to a specific version (recommended for production)
docker pull ghcr.io/alexei-led/aws-mcp-server:1.0.0

Run Server Option 2: Using Python

Use with Caution: Running natively requires careful environment setup and carries higher security risks compared to Docker deployment.

# Clone repository
git clone https://github.com/alexei-led/aws-mcp-server.git
cd aws-mcp-server

# Set up virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e .

# Run the server
python -m aws_mcp_server

Configuration

Configure AWS MCP Server with environment variables:

Environment VariableDescriptionDefault
AWS_MCP_TIMEOUTCommand execution timeout in seconds300
AWS_MCP_MAX_OUTPUTMaximum output size in characters100000
AWS_MCP_TRANSPORTTransport protocol ("stdio" or "sse")stdio
AWS_PROFILEAWS profile to usedefault
AWS_REGIONAWS region to useus-east-1
AWS_MCP_SECURITY_MODESecurity mode ("strict" or "permissive")strict
AWS_MCP_SECURITY_CONFIGPath to custom security configuration file""

Important: Securely manage AWS credentials provided to the server, whether via mounted ~/.aws files or environment variables. Ensure credentials follow least privilege principle (see Security Considerations). When using Docker, pass variables correctly to container environment.

Security Considerations

Security is paramount when executing commands against AWS. You are responsible for configuring and running the server securely.

1. Recommended Deployment: Docker Container

  • Isolation: Running inside Docker container is strongly recommended. It provides filesystem and process isolation. Potentially destructive Unix commands executed via pipes are contained and do not affect the host.
  • Controlled Environment: Docker ensures consistent environment and dependencies.

2. AWS Credentials and IAM Least Privilege

  • User Responsibility: You provide credentials.
  • Least Privilege: Credentials must have only minimal permissions needed. Never use root credentials.
  • Review Permissions Regularly: Audit IAM policies.
  • Impact Limitation: IAM policies limit scope of any command execution.

3. Trusted User Model

The server assumes the end user operating the MCP client is trusted and responsible for security.

4. Execution Risks

  • Commands run using shell=True for pipe support, which carries risks of command injection.
  • Mitigated operationally by trusted user model, Docker isolation, and strict IAM policies.
  • Credential exfiltration remains a risk if commands are manipulated; IAM restrictions reduce impact.

5. Network Exposure (SSE Transport)

  • If using sse transport, bind only to trusted interfaces or use firewalls/authentication proxies.
  • Default stdio transport uses no network ports.

6. Shared Responsibility Summary

  • You are responsible for:
    • Running within Docker environment
    • Providing least-privilege credentials
    • Ensuring only trusted users have access
    • Securing network environment as needed

Strict adherence to Docker deployment and IAM least privilege is essential for secure usage.

Integrating with Claude Desktop

Configuration

To manually integrate AWS MCP Server with Claude Desktop:

  1. Locate Claude Desktop configuration file:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. Edit the configuration to include the AWS MCP Server:

{
  "mcpServers": {
    "aws-mcp-server": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-v",
        "/Users/YOUR_USER_NAME/.aws:/home/appuser/.aws:ro",
        "ghcr.io/alexei-led/aws-mcp-server:latest"
      ]
    }
  }
}
  1. Restart Claude Desktop. A hammer icon 🔨 will appear in the input box indicating AWS MCP Server is active.
flowchart TD
    subgraph "User Device"
        config[Edit claude_desktop_config.json]
        claude[Claude Desktop]
        docker[Docker Container]
        aws_creds[AWS Credentials]
    end
    
    subgraph "AWS Cloud"
        services[AWS Services]
    end
    
    subgraph "MCP Server Components"
        tools[AWS CLI Tools]
        resources[AWS Resources]
        templates[Prompt Templates]
    end
    
    config -->|Add MCP Server Config| claude
    claude -->|Docker Run Command| docker
    docker --- tools
    docker --- resources
    docker --- templates
    aws_creds -->|Mount Read-only| docker
    resources -.->|Read| aws_creds
    tools -->|API Calls| services

Example Interactions

Getting AWS CLI Documentation:

User: What are the available options for the AWS S3 cp command?

Claude: Let me get that information for you.

The AWS S3 cp command has the following options:

NAME
    cp - Copies a local file or S3 object to another location locally or in S3.

SYNOPSIS
    cp <LocalPath> <S3Uri> or <S3Uri> <LocalPath> or <S3Uri> <S3Uri> [--acl <value>] [--cache-control <value>] ...

Executing AWS CLI Commands:

User: List my S3 buckets

Claude: I'll list your S3 buckets for you.

2023-10-15 14:30:45 my-bucket-1
2023-11-20 09:15:32 my-bucket-2
2024-01-05 11:22:18 my-backup-bucket

Using Command Pipes:

User: List my S3 buckets that have "backup" in their name and show them in alphabetical order

Claude: Let me find that for you.

2024-01-05 11:22:18 my-backup-bucket
2024-03-01 09:44:12 weekly-backup-bucket
2024-03-15 13:10:57 database-backup-bucket

Accessing AWS Resources:

User: What AWS regions are available for me to use?

Claude: Let me check what AWS regions are available for you.

Available regions:
- us-east-1 (US East, N. Virginia) - Currently selected
- us-east-2 (US East, Ohio)
- us-west-1 (US West, N. California)
- us-west-2 (US West, Oregon)
- eu-west-1 (EU West, Ireland)
- eu-central-1 (EU Central, Frankfurt)
- ap-northeast-1 (Asia Pacific, Tokyo)
- ap-southeast-1 (Asia Pacific, Singapore)
- ap-southeast-2 (Asia Pacific, Sydney)

You're currently using the us-east-1 region.

Using Prompt Templates:

User: I need to perform a security audit of my S3 buckets

Claude: I'll help you audit the security of your S3 buckets.

Here are AWS CLI commands to perform a comprehensive security audit:

# List all buckets with public access settings
aws s3api list-buckets --query 'Buckets[*].Name' --output text | xargs -I {} aws s3api get-public-access-block --bucket {}

# Check bucket policies for public access
aws s3api list-buckets --query 'Buckets[*].Name' --output text | xargs -I {} aws s3api get-bucket-policy --bucket {} 2>/dev/null

# Identify buckets without encryption
aws s3api list-buckets --query 'Buckets[*].Name' --output text | xargs -I {} aws s3api get-bucket-encryption --bucket {} 2>/dev/null

# Check for buckets without logging enabled
aws s3api list-buckets --query 'Buckets[*].Name' --output text | xargs -I {} aws s3api get-bucket-logging --bucket {} 2>/dev/null

# Verify bucket versioning status
aws s3api list-buckets --query 'Buckets[*].Name' --output text | xargs -I {} aws s3api get-bucket-versioning --bucket {}

Available Prompt Templates

Core Operations

PromptDescriptionParameters
create_resourceGenerate commands to create AWS resources with best practicesresource_type, resource_name
resource_inventoryCreate comprehensive inventory of resourcesservice, region (optional)
troubleshoot_serviceGenerate commands to troubleshoot service issuesservice, resource_id
resource_cleanupIdentify and safely clean up resourcesservice, criteria (optional)

Security & Compliance

PromptDescriptionParameters
security_auditAudit security settings for a specific AWS serviceservice
security_posture_assessmentComprehensive security assessment across your AWS environmentNone
iam_policy_generatorCreate least-privilege IAM policiesservice, actions, resource_pattern (optional)
compliance_checkCheck compliance with standardscompliance_standard, service (optional)

Cost & Performance

PromptDescriptionParameters
cost_optimizationFind cost optimization opportunities for a serviceservice
performance_tuningOptimize and tune performance of AWS resourcesservice, resource_id

Infrastructure & Architecture

PromptDescriptionParameters
serverless_deploymentDeploy serverless applications with best practicesapplication_name, runtime (optional)
container_orchestrationSet up container environments (ECS/EKS)cluster_name, service_type (optional)
vpc_network_designDesign and implement secure VPC networkingvpc_name, cidr_block (optional)
infrastructure_automationAutomate infrastructure managementresource_type, automation_scope (optional)
multi_account_governanceImplement secure multi-account strategiesaccount_type (optional)

Reliability & Monitoring

PromptDescriptionParameters
service_monitoringSet up comprehensive monitoringservice, metric_type (optional)
disaster_recoveryImplement enterprise-grade disaster recovery solutionsservice, recovery_point_objective (optional)

Security

Command Validation System

Commands are validated through three layers:

  1. Basic Command Structure
    • Must start with 'aws' and contain a valid service
  2. Security-Focused Command Filtering
    • Blocks dangerous commands
    • Allows safe, read-only patterns
    • Uses regex matching for complex rules
  3. Pipe Command Security
    • Restricts Unix pipe commands to a safe allowlist
    • Prevents filesystem manipulation and arbitrary execution

Default Security Configuration

IAM Risks (Blocked Commands Examples)

  • aws iam create-user
  • aws iam create-access-key
  • aws iam attach-*-policy
  • aws iam put-user-policy
  • aws iam create-policy
  • aws iam create-login-profile
  • aws iam deactivate-mfa-device
  • aws iam update-assume-role-policy

Audit and Logging Tampering

  • aws cloudtrail delete-trail
  • aws cloudtrail stop-logging
  • aws cloudtrail update-trail
  • aws config delete-configuration-recorder
  • aws guardduty delete-detector

Sensitive Data Protection

  • aws secretsmanager put-secret-value
  • aws secretsmanager delete-secret
  • aws kms schedule-key-deletion
  • aws kms disable-key
  • aws s3api put-bucket-policy
  • aws s3api delete-bucket-policy

Network Security Risks

  • aws ec2 authorize-security-group-ingress
  • aws ec2 authorize-security-group-egress
  • aws ec2 modify-instance-attribute
Allowed read-only operations include:
  • Commands starting with get-, list-, describe-
  • Help commands (--help, help)
  • Simulation and testing commands

Configuration Options

  • Security modes: strict (default), permissive (logs warnings but allows)
  • Custom YAML security configuration file (AWS_MCP_SECURITY_CONFIG)
  • Timeout and output limits via environment variables

Custom Security Rules Example

dangerous_commands:
  iam:
    - "aws iam create-user"
    - "aws iam attach-user-policy"
  lambda:
    - "aws lambda delete-function"
    - "aws lambda remove-permission"
  dynamodb:
    - "aws dynamodb delete-table"

safe_patterns:
  general:
    - "--help"
    - "--dry-run"
  iam:
    - "aws iam get-"
    - "aws iam list-"
  lambda:
    - "aws lambda list-functions"
    - "aws lambda get-function"

regex_rules:
  general:
    - pattern: "aws .* --profile\\s+root"
      description: "Prevent use of root profile"
      error_message: "Using the root profile is not allowed for security reasons"
  iam:
    - pattern: "aws iam create-user.*--user-name\\s+.*admin.*"
      description: "Prevent creation of admin users"
      error_message: "Creating users with 'admin' in the name is restricted"
    - pattern: "aws iam create-policy.*\"Effect\":\\s*\"Allow\".*\"Action\":\\s*\"\\*\".*\"Resource\":\\s*\"\\*\""
      description: "Prevent wildcards in policies"
      error_message: "Creating policies with '*' wildcards for both Action and Resource is not allowed"
  s3:
    - pattern: "aws s3api put-bucket-policy.*\"Effect\":\\s*\"Allow\".*\"Principal\":\\s*\"\\*\""
      description: "Prevent public bucket policies"
      error_message: "Creating bucket policies with public access is restricted"

Security Examples

Blocked commands:

aws iam create-user --user-name new-user
# Error: This command is restricted for security reasons.

aws iam attach-user-policy --user-name any-user --policy-arn arn:aws:iam::aws:policy/AdministratorAccess
# Error: Attaching Administrator policies is restricted.

aws ec2 authorize-security-group-ingress --group-id sg-12345 --protocol tcp --port 22 --cidr 0.0.0.0/0
# Error: Opening non-web ports to the entire internet (0.0.0.0/0) is restricted.

Allowed read-only operations:

aws iam list-users
aws s3 ls
aws ec2 describe-instances

Security Best Practices

  • Use strict mode in production
  • Deploy via Docker as recommended
  • Run with least-privilege AWS credentials
  • Customize security rules as needed

Development

Setting Up the Development Environment

pip install -e .
pip install -e ".[dev]"
make uv-install       # Install runtime dependencies
make uv-dev-install   # Install development dependencies

Makefile Commands

Common commands:

make test             # Run tests excluding integration
make test-unit        # Run only unit tests
make test-integration # Run only integration tests (needs AWS credentials)
make test-all         # Run all tests

make test-coverage    # Tests with coverage report (excluding integration)
make test-coverage-all # Tests with coverage report (including integration)

make lint             # Run linters
make lint-fix         # Lint and auto-fix issues
make format           # Format code

Run make help for the full list.

Code Coverage

Configured to track coverage via Codecov with threshold of 80%. Reports exclude test, setup, documentation files.

Integration Testing

  1. Create an S3 bucket for tests and set environment variable:
export AWS_TEST_BUCKET=your-test-bucket-name
  1. Run integration tests:
make test-all
make test-integration

# Or directly with pytest
pytest --run-integration
pytest --run-integration -m integration

Troubleshooting

  • Authentication: Verify AWS credentials configured properly
  • Connection: Ensure server is running and AI assistant configured correctly
  • Permissions: Check AWS credential permissions
  • Timeout: Increase AWS_MCP_TIMEOUT if needed

Why Deploy with Docker

Docker deployment is recommended for:

Security Benefits

  • Isolation: Container filesystem/process isolation protects host from accidental destructive commands
  • Read-only Credentials Mounts: Limits container changes
  • No Local AWS CLI Installation Needed
  • Clean Environment: Known, clean state every run

Reliability Advantages

  • Consistent configuration and dependencies
  • Avoid conflicts and maintain cross-platform consistency
  • Includes all necessary tools for command execution and piping

Other Benefits

  • Multi-architecture support (x86_64 and ARM64)
  • Easy updates by pulling new container images
  • Avoids Python environment conflicts
  • Version pinning for production stability

Versioning

Uses setuptools_scm for automatic version determination:

  • Release versions correspond to Git tags (e.g., 1.2.3)
  • Development versions include post-release and commit info (e.g., 1.2.3.post10+gb697684.d20250406)

Version info is included in package, Docker image labels, and CI builds.

Creating Releases

git tag -a 1.2.3 -m "Release version 1.2.3"
git push origin 1.2.3

CI/CD pipeline builds and publishes tagged Docker images automatically.

For details, see VERSION.md.

License

This project is licensed under the MIT License – see the LICENSE file for details.