Raw
1 import { Table, Note } from "docs-ui"
2
3 export const metadata = {
4 title: `use Command - Medusa Cloud CLI Reference`,
5 }
6
7 # {metadata.title}
8
9 Select the active organization, project, and environment, and persist the selection in a context configuration file. Subsequent CLI commands read this configuration so you don't need to repeat `--organization`, `--project`, and `--environment` on every command.
10
11 ```bash
12 mcloud use
13 ```
14
15 When run without flags, the command launches an interactive picker for each value. Pass any of `--organization`, `--project`, or `--environment` to set them non-interactively.
16
17 ## Options
18
19 <Table>
20 <Table.Header>
21 <Table.Row>
22 <Table.HeaderCell>
23 Option
24 </Table.HeaderCell>
25 <Table.HeaderCell>
26 Description
27 </Table.HeaderCell>
28 <Table.HeaderCell>
29 Required
30 </Table.HeaderCell>
31 </Table.Row>
32 </Table.Header>
33 <Table.Body>
34 <Table.Row>
35 <Table.Cell>
36
37 `-o <id>`, `--organization <id>`
38
39 </Table.Cell>
40 <Table.Cell>
41
42 The [ID of the organization](../organizations/page.mdx#find-organization-id) to set as active. Skips the interactive organization picker.
43
44 </Table.Cell>
45 <Table.Cell>
46
47 No
48
49 </Table.Cell>
50 </Table.Row>
51 <Table.Row>
52 <Table.Cell>
53
54 `-p <id-or-handle>`, `--project <id-or-handle>`
55
56 </Table.Cell>
57 <Table.Cell>
58
59 The [ID or handle of the project](../projects/page.mdx#find-project-ids-and-handles) to set as active. Skips the interactive project picker.
60
61 </Table.Cell>
62 <Table.Cell>
63
64 No
65
66 </Table.Cell>
67 </Table.Row>
68 <Table.Row>
69 <Table.Cell>
70
71 `-e <handle>`, `--environment <handle>`
72
73 </Table.Cell>
74 <Table.Cell>
75
76 The [handle of the environment](../environments/page.mdx#find-environment-handles) to set as active. Skips the interactive environment picker.
77
78 </Table.Cell>
79 <Table.Cell>
80
81 No
82
83 </Table.Cell>
84 </Table.Row>
85 <Table.Row>
86 <Table.Cell>
87
88 `--clear`
89
90 </Table.Cell>
91 <Table.Cell>
92
93 Remove the persisted organization, project, and environment selection. Run before switching accounts or to reset the context.
94
95 </Table.Cell>
96 <Table.Cell>
97
98 No
99
100 </Table.Cell>
101 </Table.Row>
102 <Table.Row>
103 <Table.Cell>
104
105 `--json`
106
107 </Table.Cell>
108 <Table.Cell>
109
110 Print the result as JSON instead of formatted text.
111
112 </Table.Cell>
113 <Table.Cell>
114
115 No
116
117 </Table.Cell>
118 </Table.Row>
119 </Table.Body>
120 </Table>
121
122 ---
123
124 ## Set the Active Context
125
126 ### Interactively
127
128 Run `mcloud use` without flags to pick each value from a list. The CLI prompts you to select an organization (if you're in more than one), a project, and an environment from the active project:
129
130 ```bash
131 mcloud use
132 ```
133
134 After saving, every subsequent command operates on the selected organization, project, and environment by default.
135
136 <Note>
137
138 In non-interactive environments like CI runners, pass `--organization`, `--project`, and `--environment` directly. See [Set the Active Context Non-Interactively](#non-interactively) below.
139
140 </Note>
141
142 ### Non-Interactively
143
144 When working with AI agents, scripts, or CI/CD pipelines, you can set the active context non-interactively by passing any of `--organization`, `--project`, or `--environment` directly. For example:
145
146 ```bash
147 mcloud use \
148 --organization org_123 \
149 --project proj_123 \
150 --environment production
151 ```
152
153 You can also switch the active environment without changing the organization or project:
154
155 ```bash
156 mcloud use --environment staging
157 ```
158
159 ---
160
161 ## Inspect the Active Context
162
163 Use [`mcloud whoami`](../whoami/page.mdx) to see the active organization, project, and environment along with the authenticated user and CLI metadata:
164
165 ```bash
166 mcloud whoami
167 ```
168
169 ---
170
171 ## Clear the Active Context
172
173 To clear the persisted organization, project, and environment, pass `--clear`:
174
175 ```bash
176 mcloud use --clear
177 ```
178
179 After clearing, commands that require these values will prompt for them or fail unless you pass them as flags or run `mcloud use` again.