bucket-helper-mcp
Bucket Helper
Bucket Helper 属于一个名为 AI Helpers 的库集合,该集合专为构建人工智能而开发,每个库都发布在 PyPI 上,并带有自己的绿色 CI 门禁(pytest 和 ruff,两者均为阻塞式)以及语义化版本发布。
用于 AWS S3 及任何 兼容 S3 的对象存储 的工具函数:MinIO、Backblaze B2 S3 API、DigitalOcean Spaces、Cloudflare R2、Wasabi 等。基于 boto3 构建。与 sftp-helper 形状相同:一个 credentials() 加载器、常规的 CRUD 操作(upload / download / delete / exists / list_prefix),以及一个用于“暂存并共享”流程的 remote_tempfile 上下文管理器。
对象存储将文件保存为扁平的、可寻址的二进制对象,即一个存储桶加上一个键,例如 my-bucket/folder/file.txt,而不是硬盘上的嵌套文件夹树:无需预先创建任何内容,一个位置可堆积的文件数量没有限制,并且每个对象都可以直接通过 URL 访问。Amazon Web Services 构建了第一个流行的版本 S3(简单存储服务),其线协议已成为事实标准:MinIO、Backblaze B2、DigitalOcean Spaces、Cloudflare R2 和 Wasabi 都使用相同的 S3 API,因此 bucket-helper 无需修改即可针对其中任何一个运行;只需更改端点 URL。

承诺
远程优先设计。 bucket-helper 的存在是为了在您选择的对象存储之间移动数据:AWS,或您指向的任何兼容 S3 的端点(包括您自己网络上的 MinIO 实例)。它刻意不是本地优先,并且不提供 GUI。如需通过 SFTP 而非 S3 访问远程,请使用 sftp-helper;如需从 URL 下载媒体,请使用 youtube-helper。
这种远程能力也正是“经过实战检验”必须可验证而非口号的地方。每次推送都会运行一个阻塞式 CI 门禁:测试套件针对 moto 模拟的后端运行 S3 客户端,然后 ruff 检查代码风格;任何红色运行都不会合并到 main。该包已通过 PyPI 上的九个语义化版本发布,从 v0.2.2 到当前的 v1.1.2(标签历史可通过 git tag 查看)。它依赖于 os-helper,这是整个 AI Helpers 套件共享的用于日志记录和文件处理的基础小包;这里没有重新发明该层。
Related MCP server: MinIO MCP Server
文档
功能
CRUD 操作,针对 AWS S3 或任何兼容 S3 的端点:
upload、download、delete、exists、list_prefix。适用于任何兼容 S3 的提供商,如 MinIO、Backblaze B2 S3 API、DigitalOcean Spaces、Cloudflare R2、Wasabi,只需将
endpoint_url凭据指向它即可;无需为每个提供商修改代码。凭据加载器(
credentials)按回退顺序解析 JSON / YAML / 环境变量 /.env。remote_tempfile上下文管理器,用于“暂存并共享”流程:上传、返回对象、在块退出时自动删除,无需手动清理。三种界面,一种行为:Python 库、argparse CLI、click CLI 孪生(
[cli]额外依赖)以及 FastAPI HTTP 界面([api]额外依赖)。请参阅多界面部分。Docker 镜像 附带可直接运行的 HTTP 服务器。
安装
先决条件:Python 3.10–3.13 和 git,跨平台:
🍎 macOS(Homebrew):
brew install python git🐧 Ubuntu/Debian:
sudo apt update && sudo apt install -y python3 python3-pip git🪟 Windows(PowerShell):
winget install Python.Python.3.12 Git.Git
我们建议使用 Python 环境。如果您不熟悉如何设置,请查看此链接:🥸 技术提示。
从 PyPI 安装(推荐)
# Core library (credentials loader + CRUD + remote_tempfile)
pip install bucket-helper
# Optional surfaces
pip install "bucket-helper[cli]" # click-based CLI twin
pip install "bucket-helper[api]" # FastAPI HTTP surface从源码安装(无 PyPI)
git clone https://github.com/warith-harchaoui/bucket-helper.git
cd bucket-helper
pip install -e .
# Optional surfaces
pip install -e ".[cli]"
pip install -e ".[api]"argparse CLI 始终可用。[cli] 额外依赖添加了 click 孪生。
配置
一个可直接填写的模板已提交在 settings.yaml.example。将其复制为 settings.yaml 并就地编辑:settings.yaml 已被 gitignore,因此您不会意外提交机密。
cp settings.yaml.example settings.yaml
# then edit settings.yaml with your AWS / MinIO / R2 / B2 credentials您也可以编写 JSON 而不是 YAML,使用 .env,或设置环境变量;bucket-helper 通过 os_helper.get_config 按该顺序回退。必需键:
{
"s3_access_key": "AKIA...",
"s3_secret_key": "...",
"s3_bucket": "my-bucket",
"s3_https": "https://my-bucket.s3.eu-west-3.amazonaws.com"
}可选键:
键 | 默认值 | 说明 |
|
| AWS 区域;对于 MinIO / R2 来说主要是装饰性的 |
| 空(= AWS S3) | 为兼容 S3 的后端设置此项:见下表 |
| 空 | 当未指定目标时, |
|
| 强制使用路径样式寻址( |
|
| 仅对使用自签名证书的开发 MinIO 禁用 |
常见兼容 S3 存储的端点 URL
将 s3_endpoint_url 设置为:
提供商 | 端点 |
AWS S3 | 留空 / 不设置 |
MinIO |
|
DigitalOcean Spaces |
|
Cloudflare R2 |
|
Backblaze B2(S3 API) |
|
Wasabi |
|
用法
有关完整配方目录(上传 / 下载 / 列表、兼容 S3 的端点如 MinIO / R2 / B2 / Spaces / Wasabi、带自动清理的临时远程键、与 sftp-helper 的镜像),请参阅 📋 EXAMPLES.md。
import bucket_helper as bh
# Load creds: JSON / YAML / env / .env (auto-fallback in that order)
cred = bh.credentials("path/to/settings.yaml")
# Upload a local file
uri = bh.upload("local.txt", cred, "folder/uploaded.txt")
# uri == "s3://my-bucket/folder/uploaded.txt"
assert bh.exists(uri, cred)
# Download
bh.download(uri, "downloaded.txt", cred)
# List
for key in bh.list_prefix("folder/", cred):
print(key)
# Delete
bh.delete(uri, cred)MinIO 示例
cred = {
"s3_access_key": "minioadmin",
"s3_secret_key": "minioadmin",
"s3_bucket": "uploads",
"s3_https": "http://minio.example.com:9000/uploads",
"s3_endpoint_url": "http://minio.example.com:9000",
"s3_use_path_style": "true",
"s3_region": "us-east-1", # MinIO accepts any region string
}
bh.make_bucket("uploads", cred)
bh.upload("file.bin", cred, "file.bin")使用 remote_tempfile 进行暂存并共享
将生成的文件放到一个唯一的随机键,将公共 URL 交给下游工作进程 / webhook,对象在块退出时被删除(即使主体抛出异常):
import bucket_helper as bh
import requests
cred = bh.credentials("path/to/settings.yaml")
with bh.remote_tempfile(cred, ext="json", prefix="runs") as (s3_addr, public_url):
bh.upload("payload.json", cred, s3_addr, content_type="application/json")
# Hand the URL to something that fetches it once.
requests.post("https://hook.example.com/process", json={"input_url": public_url}).raise_for_status()
# Object is gone here, no manual cleanup.多界面暴露
库中的每个公共函数也暴露为:
argparse CLI:
bucket-helper <子命令>(默认安装)。click CLI:
bucket-helper-click <子命令>(安装[cli]额外依赖)。FastAPI HTTP:
uvicorn bucket_helper.api:app --host 0.0.0.0 --port 8000(安装[api]额外依赖)。MCP:
bucket-helper-mcp将相同的 HTTP 界面暴露为 MCP 工具,供任何支持 MCP 的代理主机使用(安装[mcp]额外依赖)。
两个 CLI 共享相同的子命令名称和标志;选择您喜欢的即可。
触发工具包的详尽目录(自然语言表述、命令、函数、地址提示和显式 SKIP 规则)位于 TRIGGERS.md。
CLI 示例
# argparse CLI (always available)
bucket-helper upload --config settings.yaml --input local.txt --key folder/uploaded.txt
bucket-helper exists --config settings.yaml --key folder/uploaded.txt
bucket-helper download --config settings.yaml --key folder/uploaded.txt --output back.txt
bucket-helper list --config settings.yaml --prefix folder/
bucket-helper delete --config settings.yaml --key folder/uploaded.txt
bucket-helper make-bucket --config settings.yaml --bucket new-bucket
bucket-helper tempfile --config settings.yaml --ext json --prefix runs
bucket-helper strip-path --config settings.yaml --address s3://my-bucket/path/to/obj
# click CLI: same verbs, same flags
bucket-helper-click upload --config settings.yaml --input local.txt --key folder/uploaded.txtHTTP 服务器
# Serve HTTP (default credentials picked up from BUCKET_HELPER_CONFIG)
BUCKET_HELPER_CONFIG=$PWD/settings.yaml uvicorn bucket_helper.api:app --host 0.0.0.0 --port 8000
# → Swagger UI at http://localhost:8000/docs每次请求的凭据也可以作为多部分表单字段发送(s3_access_key / s3_secret_key / s3_bucket / s3_https / …)。
Docker
docker build -t bucket-helper .
docker run --rm -p 8000:8000 \
-e BUCKET_HELPER_CONFIG=/config/settings.yaml \
-v $PWD/settings.yaml:/config/settings.yaml:ro \
bucket-helper另请参阅:TRIGGERS.md(什么会调用工具包)和 GUI.md(视觉产品设计计划;不提供 GUI,bucket-helper 是远程对象存储管道)。
作者
致谢
特别感谢 Mohamed Chelali 和 Bachir Zerroug 进行的有益讨论。
许可证
本项目采用 BSD-3-Clause 许可证;详情请参阅 LICENSE 文件。
This server cannot be deployed
Maintenance
Related MCP Connectors
Persistent file storage for AI agents via MCP and curl. Upload, download, and version files.
Create a free sandbox object storage bucket; upload, download, list, inspect, and delete objects.
Browse and manage files in your Moxt AI workspace from any MCP client.
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceEnables interaction with AWS S3 through MCP, supporting bucket and object management, lifecycle configurations, tagging, policies, CORS settings, presigned URLs, and file uploads/downloads.3MIT
- FlicenseAqualityDmaintenanceProvides tools for interacting with MinIO and S3-compatible object storage through MCP clients like Claude. It enables comprehensive bucket and object management, including listing, creating, uploading, and generating presigned URLs.132-
- AlicenseAqualityDmaintenanceEnables browsing S3 buckets and objects, and generating secure presigned URLs for downloads and uploads, through natural language commands in MCP clients like Claude Desktop.373MIT
- AlicenseAqualityCmaintenanceEnables MCP clients to connect to AWS S3 buckets, list, upload, and read objects in various formats, supporting public and private buckets with multiple transport modes.4MIT