AWS MCP Server
Enables interaction with AWS services (EC2, S3, Lambda, DynamoDB, etc.) through the Model Context Protocol, allowing natural language management of cloud resources.
README
AWS MCP Server
<div align="center">
Aws Mcp Server
</div>
A comprehensive Model Context Protocol (MCP) server for integrating Amazon Web Services (AWS) APIs with GenAI applications.
Features
-
Comprehensive AWS Service Coverage:
- EC2: Instance management, security groups, AMIs
- S3: Bucket operations, object management, presigned URLs
- Lambda: Function deployment, invocation, configuration
- DynamoDB: Table operations, queries, batch operations
- RDS: Database instances, snapshots, parameter groups
- CloudFormation: Stack management, template validation
- IAM: User, role, and policy management
- CloudWatch: Metrics, logs, alarms
- SQS/SNS: Message queuing and notifications
- ECS/EKS: Container and Kubernetes management
-
Authentication Methods:
- IAM Access Keys
- IAM Roles
- AWS SSO
- Temporary credentials via STS
- MFA support
-
Enterprise Features:
- Multi-account support
- Cross-region operations
- Rate limiting and retry logic
- Cost tracking and optimization
- Compliance and security scanning
Installation
pip install aws-mcp-server
Or install from source:
git clone https://github.com/asklokesh/aws-mcp-server.git
cd aws-mcp-server
pip install -e .
Configuration
Create a .env file or set environment variables:
# AWS Credentials
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_DEFAULT_REGION=us-east-1
# OR use IAM Role
AWS_ROLE_ARN=arn:aws:iam::123456789012:role/YourRole
AWS_ROLE_SESSION_NAME=mcp-session
# Optional Settings
AWS_SESSION_TOKEN=your_session_token
AWS_MFA_SERIAL=arn:aws:iam::123456789012:mfa/user
AWS_PROFILE=default
AWS_MAX_RETRIES=3
AWS_TIMEOUT=30
Quick Start
Basic Usage
from aws_mcp import AWSMCPServer
# Initialize the server
server = AWSMCPServer()
# Start the server
server.start()
Claude Desktop Configuration
Add to your Claude Desktop config:
{
"mcpServers": {
"aws": {
"command": "python",
"args": ["-m", "aws_mcp.server"],
"env": {
"AWS_ACCESS_KEY_ID": "your_access_key",
"AWS_SECRET_ACCESS_KEY": "your_secret_key",
"AWS_DEFAULT_REGION": "us-east-1"
}
}
}
}
Available Tools
EC2 Operations
List Instances
{
"tool": "aws_ec2_list_instances",
"arguments": {
"filters": [
{"Name": "instance-state-name", "Values": ["running"]}
],
"region": "us-east-1"
}
}
Create Instance
{
"tool": "aws_ec2_create_instance",
"arguments": {
"ami_id": "ami-0abcdef1234567890",
"instance_type": "t3.micro",
"key_name": "my-key-pair",
"security_group_ids": ["sg-123456"],
"subnet_id": "subnet-123456",
"tags": {"Name": "MyInstance", "Environment": "Dev"}
}
}
S3 Operations
List Buckets
{
"tool": "aws_s3_list_buckets",
"arguments": {}
}
Upload Object
{
"tool": "aws_s3_upload_object",
"arguments": {
"bucket": "my-bucket",
"key": "path/to/object.txt",
"content": "File content here",
"content_type": "text/plain"
}
}
Generate Presigned URL
{
"tool": "aws_s3_presigned_url",
"arguments": {
"bucket": "my-bucket",
"key": "path/to/object.txt",
"expiration": 3600,
"operation": "get_object"
}
}
Lambda Operations
Invoke Function
{
"tool": "aws_lambda_invoke",
"arguments": {
"function_name": "myFunction",
"payload": {"key": "value"},
"invocation_type": "RequestResponse"
}
}
Deploy Function
{
"tool": "aws_lambda_deploy",
"arguments": {
"function_name": "myFunction",
"runtime": "python3.9",
"handler": "index.handler",
"code_zip_path": "/path/to/code.zip",
"role_arn": "arn:aws:iam::123456789012:role/lambda-role"
}
}
DynamoDB Operations
Query Table
{
"tool": "aws_dynamodb_query",
"arguments": {
"table_name": "MyTable",
"key_condition_expression": "PK = :pk",
"expression_attribute_values": {":pk": "USER#123"}
}
}
CloudFormation Operations
Create Stack
{
"tool": "aws_cloudformation_create_stack",
"arguments": {
"stack_name": "my-stack",
"template_body": "...",
"parameters": [
{"ParameterKey": "KeyName", "ParameterValue": "my-key"}
]
}
}
Advanced Configuration
Multi-Account Support
from aws_mcp import AWSMCPServer, AccountConfig
# Configure multiple accounts
accounts = {
"production": AccountConfig(
access_key_id="prod_key",
secret_access_key="prod_secret",
region="us-east-1"
),
"development": AccountConfig(
access_key_id="dev_key",
secret_access_key="dev_secret",
region="us-west-2"
),
"staging": AccountConfig(
role_arn="arn:aws:iam::987654321098:role/StagingRole",
region="eu-west-1"
)
}
server = AWSMCPServer(accounts=accounts, default_account="production")
Cross-Region Operations
from aws_mcp import AWSMCPServer, RegionConfig
# Enable specific regions
regions = ["us-east-1", "us-west-2", "eu-west-1", "ap-southeast-1"]
server = AWSMCPServer(enabled_regions=regions)
Cost Optimization
from aws_mcp import AWSMCPServer, CostConfig
cost_config = CostConfig(
track_costs=True,
cost_alert_threshold=100.0, # Alert if estimated cost > $100
require_cost_approval=True, # Require approval for expensive operations
cost_allocation_tags=["Project", "Environment", "Owner"]
)
server = AWSMCPServer(cost_config=cost_config)
Integration Examples
See the examples/ directory for complete integration examples:
basic_usage.py- Common AWS operationsmulti_account.py- Managing multiple AWS accountsinfrastructure_as_code.py- CloudFormation and CDK integrationcost_optimization.py- Cost tracking and optimizationsecurity_scanning.py- Security and compliance checksgenai_integration.py- Integration with GenAI APIs
Security Best Practices
- Never commit credentials - Use environment variables or AWS credential files
- Use IAM roles when possible - More secure than access keys
- Enable MFA - For sensitive operations
- Implement least privilege - Grant minimal required permissions
- Enable CloudTrail - Audit all API operations
- Use VPC endpoints - For private connectivity
- Encrypt data - Use KMS for encryption keys
Error Handling
The server provides detailed error information:
try:
result = server.execute_tool("aws_ec2_create_instance", {
"ami_id": "invalid-ami"
})
except AWSError as e:
print(f"AWS error: {e.error_code} - {e.message}")
print(f"Request ID: {e.request_id}")
Performance Optimization
- Use batch operations - For multiple similar requests
- Enable caching - For frequently accessed data
- Implement pagination - For large result sets
- Use regional endpoints - Reduce latency
- Connection pooling - Reuse HTTP connections
Contributing
Contributions are welcome! Please read our contributing guidelines and submit pull requests.
License
MIT License - see LICENSE file for details
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。