|
1
|
--- |
|
2
|
generate_toc: true |
|
3
|
--- |
|
4
|
|
|
5
|
import { Prerequisites, ChildDocs, Note } from "docs-ui" |
|
6
|
|
|
7
|
export const metadata = { |
|
8
|
title: `Medusa Cloud CLI`, |
|
9
|
} |
|
10
|
|
|
11
|
# {metadata.title} |
|
12
|
|
|
13
|
In this guide, you'll learn about the Cloud CLI, how to install it, and how to use it to manage your Cloud resources from the terminal. |
|
14
|
|
|
15
|
<Note title="AI Agents"> |
|
16
|
|
|
17
|
If you're an AI agent, or you want to manage Cloud resources through an AI agent, see [Cloud CLI for AI Agents](./agents/page.mdx) instead. |
|
18
|
|
|
19
|
</Note> |
|
20
|
|
|
21
|
## What is the Cloud CLI? |
|
22
|
|
|
23
|
The Cloud CLI (`mcloud`) is a command-line tool for managing your Cloud resources (organizations, projects, environments, logs, and more) directly from your terminal. It provides the same capabilities as the Cloud dashboard but in a scriptable, AI-friendly form. |
|
24
|
|
|
25
|
Use the CLI when you want to: |
|
26
|
|
|
27
|
- Debug and manage your Cloud resources with AI-agents like Claude Code. |
|
28
|
- Automate tasks in CI/CD pipelines, such as fetching logs or managing environments. |
|
29
|
- Integrate Cloud management into your existing terminal workflows. |
|
30
|
|
|
31
|
--- |
|
32
|
|
|
33
|
## Install the Cloud CLI |
|
34
|
|
|
35
|
<Prerequisites items={[ |
|
36
|
{ |
|
37
|
text: "Node.js v22+", |
|
38
|
link: "https://nodejs.org/en/download" |
|
39
|
} |
|
40
|
]} /> |
|
41
|
|
|
42
|
Install the CLI globally using npm or your preferred package manager: |
|
43
|
|
|
44
|
```bash npm2yarn |
|
45
|
npm install @medusajs/mcloud -g |
|
46
|
``` |
|
47
|
|
|
48
|
After installation, verify it is available by checking its version: |
|
49
|
|
|
50
|
```bash |
|
51
|
mcloud --version |
|
52
|
``` |
|
53
|
|
|
54
|
--- |
|
55
|
|
|
56
|
## Authenticate |
|
57
|
|
|
58
|
Before running any command that accesses Cloud resources, authenticate with your Cloud account: |
|
59
|
|
|
60
|
```bash |
|
61
|
mcloud login |
|
62
|
``` |
|
63
|
|
|
64
|
This opens a browser window where you complete the login flow. Your credentials are stored locally and reused on subsequent commands. |
|
65
|
|
|
66
|
### Non-Interactive Authentication |
|
67
|
|
|
68
|
For CI/CD pipelines and automated environments where a browser is not available, either set the `MCLOUD_TOKEN` environment variable to your access key or pass the key directly to `mcloud login`: |
|
69
|
|
|
70
|
```bash |
|
71
|
# Method 1: Set environment variable |
|
72
|
export MCLOUD_TOKEN=sk_123ABC |
|
73
|
|
|
74
|
# Method 2: pass directly to login command |
|
75
|
mcloud login --token sk_123ABC |
|
76
|
``` |
|
77
|
|
|
78
|
See the [login command](./commands/login/page.mdx) for more details on access keys and non-interactive authentication. |
|
79
|
|
|
80
|
### Sign Up |
|
81
|
|
|
82
|
If you don't have a Cloud account yet, sign up directly from the CLI: |
|
83
|
|
|
84
|
```bash |
|
85
|
mcloud signup |
|
86
|
``` |
|
87
|
|
|
88
|
This will open a browser window where you can create your account. After signing up, return to the terminal and run `mcloud login` to authenticate. |
|
89
|
|
|
90
|
--- |
|
91
|
|
|
92
|
## Set the Active Context |
|
93
|
|
|
94
|
Most commands operate on a specific organization, project, and environment. |
|
95
|
|
|
96
|
Instead of passing `--organization`, `--project`, and `--environment` on every command, use [`mcloud use`](./commands/use/page.mdx) to persist your selection in a context configuration file. The CLI reads this context for every command that accepts these flags. |
|
97
|
|
|
98
|
```bash |
|
99
|
# Interactive: select organization, project, and environment from prompts |
|
100
|
mcloud use |
|
101
|
|
|
102
|
# Non-interactive: pass values directly |
|
103
|
mcloud use --organization org_123 --project my-store --environment production |
|
104
|
``` |
|
105
|
|
|
106
|
Once set, you can omit these flags from subsequent commands: |
|
107
|
|
|
108
|
```bash |
|
109
|
mcloud environments list |
|
110
|
mcloud logs --follow |
|
111
|
mcloud variables list |
|
112
|
``` |
|
113
|
|
|
114
|
To check the current active context, run `mcloud whoami`: |
|
115
|
|
|
116
|
```bash |
|
117
|
mcloud whoami |
|
118
|
``` |
|
119
|
|
|
120
|
See [`mcloud whoami`](./commands/whoami/page.mdx) and [`mcloud use`](./commands/use/page.mdx) for more details. |
|
121
|
|
|
122
|
--- |
|
123
|
|
|
124
|
## JSON Output |
|
125
|
|
|
126
|
Most commands accept a `--json` flag that prints the result as machine-readable |
|
127
|
JSON instead of formatted text. Use this when piping output to other tools: |
|
128
|
|
|
129
|
```bash |
|
130
|
mcloud organizations list --json |
|
131
|
``` |
|
132
|
|
|
133
|
--- |
|
134
|
|
|
135
|
## Commands |
|
136
|
|
|
137
|
<ChildDocs showItems={["CLI"]} hideTitle itemsPerRow={2} /> |