using-medusa-cloud
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseManaging Medusa Cloud Resources
管理Medusa Cloud资源
Operational guide for AI agents managing Medusa Cloud infrastructure through the CLI. Covers setup, deployments, debugging, environments, and variables.
mcloud本指南为AI Agent提供通过 CLI管理Medusa Cloud基础设施的操作说明,涵盖配置、部署、调试、环境及变量管理等内容。
mcloudConstraints
约束条件
- Always pass when parsing CLI output. Plaintext output is for humans and may change without warning.
--json - Confirm context before mutating. Run before any state change.
mcloud whoami --json - Read before you write. Run a or
getbefore anylist,delete, orredeploy.trigger-build - Use for destructive operations.
--yescommands requiredeletein non-interactive mode.--yes - Production environments cannot be deleted. errors on production by design.
mcloud environments delete - Never pass unless the user explicitly asks. Secret values appear in terminal scrollback and logs.
--reveal - and
--jsonare incompatible. Use bounded time windows (--follow/--from) with--tofor programmatic log ingestion.--json
- 解析CLI输出时务必添加参数:纯文本输出面向人类用户,可能会无预警变更。
--json - 执行变更操作前确认上下文:在任何状态变更前运行。
mcloud whoami --json - 先读取再写入:执行、
delete或redeploy命令前,先运行trigger-build或get命令。list - 破坏性操作需添加参数:非交互模式下,
--yes命令必须携带delete才能执行。--yes - 生产环境无法删除:命令在生产环境下会触发错误,这是设计使然。
mcloud environments delete - 除非用户明确要求,否则绝不使用参数:敏感值会出现在终端回滚记录和日志中。
--reveal - 与
--json参数互斥:如需以编程方式采集日志,可结合--follow和时间范围参数(--json/--from)。--to
CRITICAL: Load Reference Files When Needed
重要提示:按需加载参考文件
Load these references based on what you're doing:
- Setting up the CLI? → MUST load first
setup.md - Debugging a failed deployment? → MUST load first
debugging-deployments.md - Managing environments or variables? → MUST load first
environments-and-variables.md
Minimum requirement: Load at least one reference file before executing multi-step workflows.
根据当前操作加载对应参考文件:
- 配置CLI? → 必须先加载
setup.md - 排查部署故障? → 必须先加载
debugging-deployments.md - 管理环境或变量? → 必须先加载
environments-and-variables.md
最低要求:执行多步骤工作流前,至少加载一个参考文件。
Quick Reference
快速参考
Authentication Check
身份验证检查
Always verify auth and scope before mutating state:
bash
mcloud whoami --json | jq -e '.auth.kind != "none" and .organization.id != null'Exit code = authenticated and scoped. Non-zero = stop and ask the user.
0执行状态变更操作前,务必验证身份验证状态和权限范围:
bash
mcloud whoami --json | jq -e '.auth.kind != "none" and .organization.id != null'退出码 = 已通过身份验证且权限范围正确。非零退出码 = 停止操作并询问用户。
0Set Context Once
一次性设置上下文
bash
mcloud use \
--organization org_123 \
--project proj_123 \
--environment productionCRITICAL:without flags is interactive and fails in CI/Docker/piped input. Always pass flags.mcloud use
bash
mcloud use \
--organization org_123 \
--project proj_123 \
--environment production重要提示: 不带参数的为交互式命令,在CI、Docker或管道输入环境下会执行失败。务必携带参数运行。mcloud use
Deployment Status Routing
部署状态路由
Route on (or ):
backend_statusstorefront_status| Status | Meaning | Logs to check |
|---|---|---|
| Build step failed | |
| Runtime crashed after build | |
| Exceeded time budget | Both: build-logs first, then runtime logs |
根据(或)进行路由处理:
backend_statusstorefront_status| 状态 | 含义 | 需检查的日志 |
|---|---|---|
| 构建步骤失败 | |
| 构建完成后运行时崩溃 | |
| 超出时间预算 | 需检查两者:先查看构建日志,再查看运行时日志 |
Redeployment Decision
重新部署决策
| Command | When to use |
|---|---|
| Fix is environment-side (variable change, infra) — reruns existing build |
| Fix is in source code on the tracked branch — starts new build |
| 命令 | 使用场景 |
|---|---|
| 修复操作针对环境侧(如变量变更、基础设施调整)——重新运行现有构建 |
| 修复操作针对跟踪分支中的源代码——启动新的构建 |
Common Pitfalls
常见陷阱
- TTY-only commands. ,
mcloud login(without flags), andmcloud usewithoutdeleterequire a TTY. They fail in CI, Docker, or piped input.--yes - precedence. When set, file-based credentials are ignored and
MCLOUD_TOKENis rejected. Unset it to switch accounts.mcloud login - Personal vs org access keys. Personal keys require ; org keys are pre-scoped.
--organization - requires personal auth. Org access keys return 401 on this command.
organizations list - Build IDs vs deployment IDs. = deployment ID; anything else = build ID (resolved to latest deployment).
depl_*accepts both; other commands take build IDs only.mcloud logs --deployment
- 仅支持TTY的命令:、不带参数的
mcloud login以及未携带mcloud use的--yes命令需要TTY环境。在CI、Docker或管道输入环境下会执行失败。delete - 的优先级:当该环境变量被设置时,基于文件的凭据会被忽略,且
MCLOUD_TOKEN命令会被拒绝。如需切换账户,请取消设置该变量。mcloud login - 个人访问密钥 vs 组织访问密钥:个人访问密钥需要携带参数;组织访问密钥已预先设置权限范围。
--organization - 命令需要个人身份验证:使用组织访问密钥执行该命令会返回401错误。
organizations list - 构建ID vs 部署ID:= 部署ID;其他格式 = 构建ID(会解析为最新部署)。
depl_*命令两者都接受;其他命令仅支持构建ID。mcloud logs --deployment
Reference Files
参考文件
setup.md - CLI installation, authentication, context setup
debugging-deployments.md - Build/deployment failure recipes and log analysis
environments-and-variables.md - Environment lifecycle and variable managementsetup.md - CLI安装、身份验证、上下文配置
debugging-deployments.md - 构建/部署故障排查方案及日志分析
environments-and-variables.md - 环境生命周期及变量管理