What is A Model Context Protocol (MCP) server implementation for querying AWS resources using Python and boto3.?
This MCP server allows users to run generated Python code to query AWS resources through boto3. It provides a Docker image for easy setup and execution, ensuring stability and sandboxing for code execution. Users can execute various AWS queries and manage resources with their AWS credentials.
Documentation
AWS Resources MCP Server
\n\n## Overview
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.
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.
aws://query_resources: A dynamic resource that provides access to AWS resources through boto3 queries
Example Queries
Here are some example queries you can execute:
List S3 buckets:
s3 = session.client('s3')
result = s3.list_buckets()
Get latest CodePipeline deployment:
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.
Tools
The server offers a tool for executing AWS queries:
aws_resources_query_or_modify
Execute a boto3 code snippet to query or modify AWS resources
Input:
code_snippet (string): Python code using boto3 to query AWS resources
The code must set a result variable with the query output
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
Cross-Platform Publishing
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):