by baryhuang
mcp-server-aws-resources-python is a Python-based Model Context Protocol (MCP) server that enables AI models to securely interact with and manage AWS resources. It provides a containerized environment for executing boto3 code, facilitating automated AWS operations and resource management.
mcp-server-aws-resources-python is a Python-based Model Context Protocol (MCP) server that enables AI models like Claude to interact with and manage AWS resources directly by executing boto3 code. It provides a secure and containerized environment for performing powerful AWS operations.
To use mcp-server-aws-resources-python, you need to provide your AWS credentials (access key, secret key, and optionally session token and region) as environment variables. The server can be installed via Smithery or by pulling the Docker image from Docker Hub. Once set up, you can send Python boto3 code snippets to the server, which will execute them against your AWS account. The results are returned in JSON format.
aws-mcp
) might have setup hassles, stability issues, or be based on different technology stacks (e.g., Node.js).AWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
, AWS_DEFAULT_REGION
(optional, defaults to 'us-east-1'), and AWS_SESSION_TOKEN
(optional, for temporary credentials).AWS_PROFILE
with credentials stored in ~/.aws/credentials
.boto3
, operator
, json
, datetime
, pytz
, dateutil
, re
, time
.result
variable, which will be automatically converted to JSON format, handling AWS-specific objects and datetime values.A Model Context Protocol (MCP) server implementation that provides running generated python code to query any AWS resources through boto3.
At your own risk: I didn't limit the operations to ReadyOnly, so that cautious Ops people can be helped using this tool doing management operations. Your AWS user role will dictate the permissions for what you can do.
Demo: Fix Dynamodb Permission Error
https://github.com/user-attachments/assets/de88688d-d7a0-45e1-94eb-3f5d71e9a7c7
I tried AWS Chatbot with Developer Access. Free Tier has a limit of 25 query/month for resources. Next tier is $19/month include 90% of the features I don't use. And the results are in a fashion of JSON and a lot of restrictions.
I tried using aws-mcp but ran into a few issues:
So I created this new approach that:
For more information about the Model Context Protocol and how it works, see Anthropic's MCP documentation.
The server exposes the following resource:
aws://query_resources
: A dynamic resource that provides access to AWS resources through boto3 queriesHere are some example queries you can execute:
s3 = session.client('s3')
result = s3.list_buckets()
def get_latest_deployment(pipeline_name):
codepipeline = session.client('codepipeline')
result = codepipeline.list_pipeline_executions(
pipelineName=pipeline_name,
maxResults=5
)
if result['pipelineExecutionSummaries']:
latest_execution = max(
[e for e in result['pipelineExecutionSummaries']
if e['status'] == 'Succeeded'],
key=itemgetter('startTime'),
default=None
)
if latest_execution:
result = codepipeline.get_pipeline_execution(
pipelineName=pipeline_name,
pipelineExecutionId=latest_execution['pipelineExecutionId']
)
else:
result = None
else:
result = None
return result
result = get_latest_deployment("your-pipeline-name")
Note: All code snippets must set a result
variable that will be returned to the client. The result
variable will be automatically converted to JSON format, with proper handling of AWS-specific objects and datetime values.
The server offers a tool for executing AWS queries:
aws_resources_query_or_modify
code_snippet
(string): Python code using boto3 to query AWS resourcesresult
variable with the query outputThe server includes several safety features:
You'll need AWS credentials with appropriate permissions to query AWS resources. You can obtain these by:
The following environment variables are required:
AWS_ACCESS_KEY_ID
: Your AWS access keyAWS_SECRET_ACCESS_KEY
: Your AWS secret keyAWS_SESSION_TOKEN
: (Optional) AWS session token if using temporary credentialsAWS_DEFAULT_REGION
: AWS region (defaults to 'us-east-1' if not set)You can also use a profile stored in the ~/.aws/credentials
file. To do this, set the AWS_PROFILE
environment variable to the profile name.
Note: Keep your AWS credentials secure and never commit them to version control.
To install AWS Resources MCP Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install mcp-server-aws-resources-python --client claude
You can either build the image locally or pull it from Docker Hub. The image is built for the Linux platform.
docker pull buryhuang/mcp-server-aws-resources:latest
docker build -t mcp-server-aws-resources .
Run the container:
docker run \
-e AWS_ACCESS_KEY_ID=your_access_key_id_here \
-e AWS_SECRET_ACCESS_KEY=your_secret_access_key_here \
-e AWS_DEFAULT_REGION=your_AWS_DEFAULT_REGION \
buryhuang/mcp-server-aws-resources:latest
Or using stored credentials and a profile:
docker run \
-e AWS_PROFILE=[AWS_PROFILE_NAME] \
-v ~/.aws:/root/.aws \
buryhuang/mcp-server-aws-resources:latest
To publish the Docker image for multiple platforms, you can use the docker buildx
command. Follow these steps:
Create a new builder instance (if you haven't already):
docker buildx create --use
Build and push the image for multiple platforms:
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t buryhuang/mcp-server-aws-resources:latest --push .
Verify the image is available for the specified platforms:
docker buildx imagetools inspect buryhuang/mcp-server-aws-resources:latest
{
"mcpServers": {
"aws-resources": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"AWS_ACCESS_KEY_ID=your_access_key_id_here",
"-e",
"AWS_SECRET_ACCESS_KEY=your_secret_access_key_here",
"-e",
"AWS_DEFAULT_REGION=us-east-1",
"buryhuang/mcp-server-aws-resources:latest"
]
}
}
}
{
"mcpServers": {
"aws-resources": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"AWS_PROFILE=default",
"-v",
"~/.aws:/root/.aws",
"buryhuang/mcp-server-aws-resources:latest"
]
}
}
}
{
"mcpServers": {
"aws": {
"command": "/Users/gmr/.local/bin/uv",
"args": [
"--directory",
"/<your-path>/mcp-server-aws-resources-python",
"run",
"src/mcp_server_aws_resources/server.py",
"--profile",
"testing"
]
}
}
}
Reviews feature coming soon
Stay tuned for community discussions and feedback