Back to MCP directory
publicPublicdnsLocal runtime

s3-mcp

一个基于Docker的S3管理服务器,提供桶和对象管理、生命周期配置、标签管理、策略设置及CORS配置等功能。

article

README

🚀 S3 MCP服务器

此服务器可助力您高效管理S3桶和对象,处理生命周期配置,设置与检索对象标签,管理存储桶策略以及配置CORS设置,为您的S3资源管理提供全方位支持。

🚀 快速开始

此服务器允许您执行以下操作:

  • 管理S3桶和对象
  • 处理生命周期配置
  • 设置和检索对象标签
  • 管理存储桶策略
  • 配置CORS设置

📦 安装指南

根据您的设置,有多种方式可以使用此服务器。

使用Cursor(推荐)

将以下内容添加到您的Cursor MCP配置中:

{
  "mcpServers": {
    "s3-mcp": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "AWS_SECRET_ACCESS_KEY=your_access_key",
        "-e",
        "AWS_ACCESS_KEY_ID=your_access_key",
        "-e",
        "AWS_REGION=your_region",
        "ashgw/s3-mcp:latest"
      ]
    }
  }
}

⚠️ 重要提示

如果您希望固定到特定的Docker镜像构建(例如,20250413-165732),请使用该标签而不是latest。查看 Docker Hub 上的可用版本。

Cursor会自动将请求路由到MCP服务器。确保所有工具都正常运行且状态为绿色。 图片

Docker(手动)

您可以通过Docker手动运行S3 MCP服务器:

docker run --rm -it \
  -e AWS_ACCESS_KEY_ID=your_access_key \
  -e AWS_SECRET_ACCESS_KEY=your_secret_key \
  -e AWS_REGION=your_region \
  ashgw/s3-mcp

此命令使用预构建的镜像,发布在 ashgw/s3-mcp

源代码仓库

克隆仓库并cd进入它,然后使用以下命令构建:

docker build -t s3-mcp .

然后运行:

docker run --rm -e AWS_ACCESS_KEY_ID=your_access_key -e AWS_SECRET_ACCESS_KEY=your_secret_key -e AWS_REGION=your_region s3-mcp

环境变量

设置以下环境变量以配置AWS凭证:

export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_REGION=your_region

✨ 主要特性

  • 列出桶:获取所有S3桶的列表。
  • 创建桶:创建一个新的S3桶,可选配置。
  • 列出对象:列出指定桶中的所有对象。
  • 获取对象:检索指定对象的内容。
  • 上传对象:将对象上传到指定桶。
  • 删除对象:从指定桶中删除对象。
  • 生成预签名URL:创建一个预签名URL以访问或上传对象。
  • 设置存储桶策略:更新或设置指定桶的策略。
  • 获取存储桶策略:检索指定桶的当前策略。
  • 删除存储桶策略:移除指定桶的当前策略。
  • 生命周期配置:管理S3桶的生命周期规则。
  • 对象标记:设置和检索S3对象的标签。
  • CORS配置:获取并设置桶的CORS规则。
  • 配置示例:查看如何在实际场景中使用此服务器。

💻 使用示例

基础用法

# 示例Python代码
def list_buckets():
    # 连接到S3服务
    s3 = boto3.client('s3')
    # 获取所有存储桶
    buckets = s3.list_buckets()
    # 打印存储桶名称
    for bucket in buckets['Buckets']:
        print(bucket['Name'])

list_buckets()

高级用法

# 示例Python代码
def create_bucket():
    # 创建S3客户端
    s3 = boto3.client('s3')
    # 定义存储桶配置
    bucket_config = {
        'LocationConstraint': 'us-west-2'
    }
    # 创建存储桶
    response = s3.create_bucket(
        Bucket='my-new-bucket',
        CreateBucketConfiguration=bucket_config
    )
    # 打印创建结果
    print(response)

create_bucket()

📄 许可证

此项目使用 MIT License 进行许可。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client