Skip to main content
Glama
baryhuang

AWS Resources MCP Server

by baryhuang

AWS 资源 MCP 服务器

Docker 中心 Docker 中心

概述

模型上下文协议 (MCP) 服务器实现,提供运行生成的 python 代码以通过 boto3 查询任何 AWS 资源。

风险自负:我没有将操作限制为 ReadyOnly,以便谨慎的运维人员能够使用此工具进行管理操作。您的 AWS 用户角色将决定您可以执行的操作权限。

演示:修复 Dynamodb 权限错误

https://github.com/user-attachments/assets/de88688d-d7a0-45e1-94eb-3f5d71e9a7c7

Related MCP server: MCP Development Server

为什么要使用另一个 AWS MCP 服务器?

我尝试了 AWS Chatbot 的开发者访问权限。免费套餐每月资源查询次数限制为 25 次。下一个套餐是每月 19 美元,包含 90% 我不常用的功能。结果以 JSON 格式呈现,并且有很多限制。

我尝试使用aws-mcp ,但遇到了一些问题:

  1. 设置麻烦:必须克隆 git repo 并处理本地设置

  2. 稳定性问题:在我的 Mac 上不够稳定

  3. Node.js Stack :作为一名 Python 开发人员,我无法有效地为 Node.js 代码库做出贡献

因此我创建了这个新方法:

  • 直接从 Docker 镜像运行 - 无需 git clone

  • 使用 Python 和 boto3 来获得更好的稳定性

  • 让 Python 开发者更容易做出贡献

  • 包含适当的代码执行沙盒

  • 保持所有物品容器化并保持清洁

有关模型上下文协议及其工作原理的更多信息,请参阅Anthropic 的 MCP 文档。

成分

资源

服务器公开以下资源:

  • aws://query_resources :通过 boto3 查询提供对 AWS 资源的访问的动态资源

示例查询

以下是您可以执行的一些示例查询:

  1. 列出 S3 存储桶:

s3 = session.client('s3')
result = s3.list_buckets()
  1. 获取最新的 CodePipeline 部署:

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")

注意:所有代码片段都必须设置一个将返回给客户端的result变量。该result变量将自动转换为 JSON 格式,并正确处理 AWS 特定的对象和日期时间值。

工具

该服务器提供了执行 AWS 查询的工具:

  • aws_resources_query_or_modify

    • 执行 boto3 代码片段来查询或修改 AWS 资源

    • 输入:

      • code_snippet (字符串):使用 boto3 查询 AWS 资源的 Python 代码

      • 代码必须设置查询输出的result变量

    • 允许进口:

      • 博托3

      • 操作员

      • json

      • 日期时间

      • 皮茨

      • 日期实用程序

      • 关于

      • 时间

    • 可用的内置函数:

      • 基本类型:dict、list、tuple、set、str、int、float、bool

      • 操作:len、max、min、sorted、filter、map、sum、any、all

      • 对象处理:hasattr、getattr、isinstance

      • 其他:打印、导入

实现细节

该服务器包含几个安全功能:

  • 基于 AST 的代码分析来验证导入和代码结构

  • 受限的执行环境,内置函数有限

  • 对结果进行 JSON 序列化,并正确处理特定于 AWS 的对象

  • 正确的错误处理和报告

设置

先决条件

您需要拥有具有适当权限的 AWS 凭证才能查询 AWS 资源。您可以通过以下方式获取这些凭证:

  1. 在您的 AWS 账户中创建 IAM 用户

  2. 生成用于编程访问的访问密钥

  3. 确保 IAM 用户具有要查询的 AWS 服务的必要权限

需要以下环境变量:

  • AWS_ACCESS_KEY_ID :您的 AWS 访问密钥

  • AWS_SECRET_ACCESS_KEY :您的 AWS 密钥

  • AWS_SESSION_TOKEN :(可选)如果使用临时凭证,则使用 AWS 会话令牌

  • AWS_DEFAULT_REGION :AWS 区域(如果未设置,则默认为“us-east-1”)

您还可以使用存储在~/.aws/credentials文件中的配置文件。为此,请将AWS_PROFILE环境变量设置为配置文件名称。

注意:请确保您的 AWS 凭证安全,切勿将其提交到版本控制中。

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 AWS Resources MCP Server:

npx -y @smithery/cli install mcp-server-aws-resources-python --client claude

Docker 安装

您可以在本地构建镜像,也可以从 Docker Hub 拉取。该镜像是为 Linux 平台构建的。

支持的平台

  • Linux/amd64

  • Linux/arm64

  • Linux/arm/v7

选项 1:从 Docker Hub 拉取

docker pull buryhuang/mcp-server-aws-resources:latest

选项 2:本地构建

docker build -t mcp-server-aws-resources .

运行容器:

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

或者使用存储的凭证和配置文件:

docker run \
  -e AWS_PROFILE=[AWS_PROFILE_NAME] \
  -v ~/.aws:/root/.aws \
  buryhuang/mcp-server-aws-resources:latest

跨平台发布

要为多个平台发布 Docker 镜像,可以使用docker buildx命令。请按以下步骤操作:

  1. 创建一个新的构建器实例(如果还没有):

    docker buildx create --use
  2. 为多个平台构建并推送图像:

    docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t buryhuang/mcp-server-aws-resources:latest --push .
  3. 验证该图像是否适用于指定的平台:

    docker buildx imagetools inspect buryhuang/mcp-server-aws-resources:latest

与 Claude Desktop 一起使用

使用 Docker 运行

使用 ACCESS_KEY_ID 和 SECRET_ACCESS_KEY 的示例

{
  "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"
      ]
    }
  }
}

使用 PROFILE 并安装本地 AWS 凭证的示例

{
  "mcpServers": {
    "aws-resources": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "AWS_PROFILE=default",
        "-v",
        "~/.aws:/root/.aws",
        "buryhuang/mcp-server-aws-resources:latest"
      ]
    }
  }
}

使用 Git clone 运行

使用 git clone 和 profile 运行的示例

{
  "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"
      ]
    }
  }
}

Available Tools

1 tool
aws_resources_query_or_modifyC

Execute a boto3 code snippet to query or modify AWS resources

ParametersJSON Schema
NameRequiredDescriptionDefault
code_snippetYesPython code using boto3 to query or modify AWS resources. The code should have default execution setting variable named 'result'. Example code: 'result = boto3.client('s3').list_buckets()'

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool can 'query or modify' AWS resources, implying both read and write operations, but fails to detail critical aspects like authentication requirements, error handling, rate limits, or safety considerations. This leaves significant gaps in understanding the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded in a single sentence: 'Execute a boto3 code snippet to query or modify AWS resources.' It efficiently conveys the core purpose without unnecessary details, though it could be slightly improved by structuring usage hints separately.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (executing arbitrary code for AWS operations) and the absence of annotations and output schema, the description is incomplete. It lacks information on return values, error cases, security implications, and operational constraints, which are crucial for safe and effective use by an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'code_snippet' parameter well-documented in the schema. The description adds no additional meaning beyond what the schema provides, as it only repeats the boto3 and AWS context. According to the rules, with high schema coverage, the baseline is 3 even without param info in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Execute a boto3 code snippet to query or modify AWS resources.' It specifies the action (execute), technology (boto3), and target (AWS resources). However, it doesn't distinguish from siblings since there are none, so it cannot achieve the full differentiation required for a score of 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions querying or modifying AWS resources but offers no context about specific scenarios, prerequisites, or exclusions. This lack of usage direction limits its effectiveness for an AI agent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev1.0.0
    • First observedaws_resources_query_or_modify

TDQS

B3.1/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of ambiguity or overlap between tools. The tool's purpose is clearly defined as executing boto3 code snippets for AWS operations.

Naming Consistency5/5

Since there is only one tool, naming consistency is inherently perfect. The tool name 'aws_resources_query_or_modify' follows a clear verb_noun pattern and is descriptive.

Tool Count2/5

A single tool for an AWS resources server is too few for the apparent scope, as AWS involves many distinct services and operations. This forces all functionality through one generic interface, which is insufficient for comprehensive coverage.

Completeness2/5

The tool surface is severely incomplete for an AWS resources domain. While the tool allows generic boto3 execution, it lacks specific operations for common AWS resources (e.g., EC2 instances, S3 buckets, IAM roles), leaving significant gaps that will likely cause agent failures.

Maintenance

ActivityInactive
ResponsivenessUnresponsive

Related MCP Connectors

Related MCP Servers

  • F
    license
    C
    quality
    D
    maintenance
    A Model Context Protocol (MCP) server that enables AI assistants like Claude to interact with your AWS environment. This allows for natural language querying and management of your AWS resources during conversations. Think of better Amazon Q alternative.
    1
    3
    296
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    A Model Context Protocol server that enables AI assistants like Claude to perform Python development tasks through file operations, code analysis, project management, and safe code execution.
    9
    MIT