mem0-cli 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. mem0_cli-0.2.2/PKG-INFO +377 -0
  2. mem0_cli-0.2.2/README.md +349 -0
  3. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/pyproject.toml +1 -1
  4. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/__init__.py +1 -1
  5. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/app.py +78 -4
  6. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/backend/platform.py +22 -1
  7. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/branding.py +2 -2
  8. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/commands/init_cmd.py +16 -0
  9. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/config.py +4 -0
  10. mem0_cli-0.2.2/src/mem0_cli/telemetry.py +105 -0
  11. mem0_cli-0.2.2/src/mem0_cli/telemetry_sender.py +86 -0
  12. mem0_cli-0.2.0/PKG-INFO +0 -74
  13. mem0_cli-0.2.0/README.md +0 -46
  14. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/.gitignore +0 -0
  15. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/__main__.py +0 -0
  16. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/backend/__init__.py +0 -0
  17. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/backend/base.py +0 -0
  18. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/commands/__init__.py +0 -0
  19. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/commands/config_cmd.py +0 -0
  20. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/commands/entities.py +0 -0
  21. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/commands/events_cmd.py +0 -0
  22. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/commands/memory.py +0 -0
  23. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/commands/utils.py +0 -0
  24. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/output.py +0 -0
  25. {mem0_cli-0.2.0 → mem0_cli-0.2.2}/src/mem0_cli/state.py +0 -0
@@ -0,0 +1,377 @@
1
+ Metadata-Version: 2.4
2
+ Name: mem0-cli
3
+ Version: 0.2.2
4
+ Summary: The official CLI for mem0 — the memory layer for AI agents
5
+ Author-email: "mem0.ai" <founders@mem0.ai>
6
+ License-Expression: Apache-2.0
7
+ Keywords: agents,ai,cli,mem0,memory
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Libraries
17
+ Requires-Python: >=3.10
18
+ Requires-Dist: httpx>=0.24.0
19
+ Requires-Dist: rich>=13.0.0
20
+ Requires-Dist: typer>=0.9.0
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
23
+ Requires-Dist: pytest>=7.0; extra == 'dev'
24
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
25
+ Provides-Extra: oss
26
+ Requires-Dist: mem0ai>=0.1.0; extra == 'oss'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # mem0 CLI (Python)
30
+
31
+ The official command-line interface for [mem0](https://mem0.ai) — the memory layer for AI agents. Python implementation.
32
+
33
+ > **Built for AI agents.** Pass `--agent` (or `--json`) as a global flag on any command to get structured JSON output optimized for programmatic consumption — sanitized fields, no colors or spinners, and errors as JSON too.
34
+
35
+ ## Prerequisites
36
+
37
+ - Python **3.10+**
38
+
39
+ ## Installation
40
+
41
+ ### Using pipx (recommended)
42
+
43
+ ```bash
44
+ pipx install mem0-cli
45
+ ```
46
+
47
+ ### Using pip
48
+
49
+ ```bash
50
+ pip install mem0-cli
51
+ ```
52
+
53
+ > **Note:** On macOS with Homebrew Python, `pip install` outside a virtual environment will fail with an `externally-managed-environment` error ([PEP 668](https://peps.python.org/pep-0668/)). Use `pipx` instead, or install inside a virtual environment.
54
+
55
+ ## Quick start
56
+
57
+ ```bash
58
+ # Interactive setup wizard
59
+ mem0 init
60
+
61
+ # Or login via email
62
+ mem0 init --email alice@company.com
63
+
64
+ # Or authenticate with an existing API key
65
+ mem0 init --api-key m0-xxx
66
+
67
+ # Add a memory
68
+ mem0 add "I prefer dark mode and use vim keybindings" --user-id alice
69
+
70
+ # Search memories
71
+ mem0 search "What are Alice's preferences?" --user-id alice
72
+
73
+ # List all memories for a user
74
+ mem0 list --user-id alice
75
+
76
+ # Get a specific memory
77
+ mem0 get <memory-id>
78
+
79
+ # Update a memory
80
+ mem0 update <memory-id> "I switched to light mode"
81
+
82
+ # Delete a memory
83
+ mem0 delete <memory-id>
84
+ ```
85
+
86
+ ## Commands
87
+
88
+ ### `mem0 init`
89
+
90
+ Interactive setup wizard. Prompts for your API key and default user ID.
91
+
92
+ ```bash
93
+ mem0 init
94
+ mem0 init --api-key m0-xxx --user-id alice
95
+ mem0 init --email alice@company.com
96
+ ```
97
+
98
+ If an existing configuration is detected, the CLI asks for confirmation before overwriting. Use `--force` to skip the prompt (useful in CI/CD).
99
+
100
+ ```bash
101
+ mem0 init --api-key m0-xxx --user-id alice --force
102
+ ```
103
+
104
+ | Flag | Description |
105
+ |------|-------------|
106
+ | `--api-key` | API key (skip prompt) |
107
+ | `-u, --user-id` | Default user ID (skip prompt) |
108
+ | `--email` | Login via email verification code |
109
+ | `--code` | Verification code (use with `--email` for non-interactive login) |
110
+ | `--force` | Overwrite existing config without confirmation |
111
+
112
+ ### `mem0 add`
113
+
114
+ Add a memory from text, a JSON messages array, a file, or stdin.
115
+
116
+ ```bash
117
+ mem0 add "I prefer dark mode" --user-id alice
118
+ mem0 add --file conversation.json --user-id alice
119
+ echo "Loves hiking on weekends" | mem0 add --user-id alice
120
+ ```
121
+
122
+ | Flag | Description |
123
+ |------|-------------|
124
+ | `-u, --user-id` | Scope to a user |
125
+ | `--agent-id` | Scope to an agent |
126
+ | `--messages` | Conversation messages as JSON |
127
+ | `-f, --file` | Read messages from a JSON file |
128
+ | `-m, --metadata` | Custom metadata as JSON |
129
+ | `--categories` | Categories (JSON array or comma-separated) |
130
+ | `--graph / --no-graph` | Enable or disable graph memory extraction |
131
+ | `-o, --output` | Output format: `text`, `json`, `quiet` |
132
+
133
+ ### `mem0 search`
134
+
135
+ Search memories using natural language.
136
+
137
+ ```bash
138
+ mem0 search "dietary restrictions" --user-id alice
139
+ mem0 search "preferred tools" --user-id alice --output json --top-k 5
140
+ ```
141
+
142
+ | Flag | Description |
143
+ |------|-------------|
144
+ | `-u, --user-id` | Filter by user |
145
+ | `-k, --top-k` | Number of results (default: 10) |
146
+ | `--threshold` | Minimum similarity score (default: 0.3) |
147
+ | `--rerank` | Enable reranking |
148
+ | `--keyword` | Use keyword search instead of semantic |
149
+ | `--filter` | Advanced filter expression (JSON) |
150
+ | `--graph / --no-graph` | Enable or disable graph in search |
151
+ | `-o, --output` | Output format: `text`, `json`, `table` |
152
+
153
+ ### `mem0 list`
154
+
155
+ List memories with optional filters and pagination.
156
+
157
+ ```bash
158
+ mem0 list --user-id alice
159
+ mem0 list --user-id alice --category preferences --output json
160
+ mem0 list --user-id alice --after 2024-01-01 --page-size 50
161
+ ```
162
+
163
+ | Flag | Description |
164
+ |------|-------------|
165
+ | `-u, --user-id` | Filter by user |
166
+ | `--page` | Page number (default: 1) |
167
+ | `--page-size` | Results per page (default: 100) |
168
+ | `--category` | Filter by category |
169
+ | `--after` | Created after date (YYYY-MM-DD) |
170
+ | `--before` | Created before date (YYYY-MM-DD) |
171
+ | `-o, --output` | Output format: `text`, `json`, `table` |
172
+
173
+ ### `mem0 get`
174
+
175
+ Retrieve a specific memory by ID.
176
+
177
+ ```bash
178
+ mem0 get 7b3c1a2e-4d5f-6789-abcd-ef0123456789
179
+ mem0 get 7b3c1a2e-4d5f-6789-abcd-ef0123456789 --output json
180
+ ```
181
+
182
+ ### `mem0 update`
183
+
184
+ Update the text or metadata of an existing memory.
185
+
186
+ ```bash
187
+ mem0 update <memory-id> "Updated preference text"
188
+ mem0 update <memory-id> --metadata '{"priority": "high"}'
189
+ echo "new text" | mem0 update <memory-id>
190
+ ```
191
+
192
+ ### `mem0 delete`
193
+
194
+ Delete a single memory, all memories for a scope, or an entire entity.
195
+
196
+ ```bash
197
+ # Delete a single memory
198
+ mem0 delete <memory-id>
199
+
200
+ # Delete all memories for a user
201
+ mem0 delete --all --user-id alice --force
202
+
203
+ # Delete all memories project-wide
204
+ mem0 delete --all --project --force
205
+
206
+ # Preview what would be deleted
207
+ mem0 delete --all --user-id alice --dry-run
208
+ ```
209
+
210
+ | Flag | Description |
211
+ |------|-------------|
212
+ | `--all` | Delete all memories matching scope filters |
213
+ | `--entity` | Delete the entity and all its memories |
214
+ | `--project` | With `--all`: delete all memories project-wide |
215
+ | `--dry-run` | Preview without deleting |
216
+ | `--force` | Skip confirmation prompt |
217
+
218
+ ### `mem0 import`
219
+
220
+ Bulk import memories from a JSON file.
221
+
222
+ ```bash
223
+ mem0 import data.json --user-id alice
224
+ ```
225
+
226
+ The file should be a JSON array where each item has a `memory` (or `text` or `content`) field and optional `user_id`, `agent_id`, and `metadata` fields.
227
+
228
+ ### `mem0 config`
229
+
230
+ View or modify the local CLI configuration.
231
+
232
+ ```bash
233
+ mem0 config show # Display current config (secrets redacted)
234
+ mem0 config get api_key # Get a specific value
235
+ mem0 config set user_id bob # Set a value
236
+ ```
237
+
238
+ ### `mem0 entity`
239
+
240
+ List or delete entities (users, agents, apps, runs).
241
+
242
+ ```bash
243
+ mem0 entity list users
244
+ mem0 entity list agents --output json
245
+ mem0 entity delete --user-id alice --force
246
+ ```
247
+
248
+ ### `mem0 event`
249
+
250
+ Inspect background processing events created by async operations (e.g. bulk deletes, large add jobs).
251
+
252
+ ```bash
253
+ # List recent events
254
+ mem0 event list
255
+
256
+ # Check the status of a specific event
257
+ mem0 event status <event-id>
258
+ ```
259
+
260
+ | Flag | Description |
261
+ |------|-------------|
262
+ | `-o, --output` | Output format: `text`, `json` |
263
+
264
+ ### `mem0 status`
265
+
266
+ Verify your API connection and display the current project.
267
+
268
+ ```bash
269
+ mem0 status
270
+ ```
271
+
272
+ ### `mem0 version`
273
+
274
+ Print the CLI version.
275
+
276
+ ```bash
277
+ mem0 version
278
+ ```
279
+
280
+ ## Agent mode
281
+
282
+ Pass `--agent` (or its alias `--json`) as a **global flag** on any command to get output designed for AI agent tool loops:
283
+
284
+ ```bash
285
+ mem0 --agent search "user preferences" --user-id alice
286
+ mem0 --agent add "User prefers dark mode" --user-id alice
287
+ mem0 --agent list --user-id alice
288
+ mem0 --agent delete --all --user-id alice --force
289
+ ```
290
+
291
+ Every command returns the same envelope shape:
292
+
293
+ ```json
294
+ {
295
+ "status": "success",
296
+ "command": "search",
297
+ "duration_ms": 134,
298
+ "scope": { "user_id": "alice" },
299
+ "count": 2,
300
+ "data": [
301
+ { "id": "abc-123", "memory": "User prefers dark mode", "score": 0.97, "created_at": "2026-01-15", "categories": ["preferences"] }
302
+ ]
303
+ }
304
+ ```
305
+
306
+ What agent mode does differently from `--output json`:
307
+
308
+ - **Sanitized `data`**: only the fields an agent needs (id, memory, score, etc.) — no internal API noise
309
+ - **No human output**: spinners, colors, and banners are suppressed entirely
310
+ - **Errors as JSON**: errors go to stdout as `{"status": "error", "command": "...", "error": "..."}` with a non-zero exit code
311
+
312
+ Use `mem0 help --json` to get the full command tree as JSON — useful for agents that need to self-discover available commands.
313
+
314
+ ## Output formats
315
+
316
+ Control how results are displayed with `--output`:
317
+
318
+ | Format | Description |
319
+ |--------|-------------|
320
+ | `text` | Human-readable with colors and formatting (default) |
321
+ | `json` | Structured JSON for piping to `jq` (raw API response) |
322
+ | `table` | Tabular format (default for `list`) |
323
+ | `quiet` | Minimal — just IDs or status codes |
324
+ | `agent` | Structured JSON envelope with sanitized fields (set by `--agent`/`--json`) |
325
+
326
+ ## Global flags
327
+
328
+ These flags are available on all commands:
329
+
330
+ | Flag | Description |
331
+ |------|-------------|
332
+ | `--json` | Enable agent mode: structured JSON envelope output, no colors or spinners |
333
+ | `--agent` | Alias for `--json` |
334
+ | `--api-key` | Override the configured API key for this request |
335
+ | `--base-url` | Override the configured API base URL for this request |
336
+ | `-o, --output` | Set the output format |
337
+
338
+ ## Environment variables
339
+
340
+ | Variable | Description |
341
+ |----------|-------------|
342
+ | `MEM0_API_KEY` | API key (overrides config file) |
343
+ | `MEM0_BASE_URL` | API base URL |
344
+ | `MEM0_USER_ID` | Default user ID |
345
+ | `MEM0_AGENT_ID` | Default agent ID |
346
+ | `MEM0_APP_ID` | Default app ID |
347
+ | `MEM0_RUN_ID` | Default run ID |
348
+ | `MEM0_ENABLE_GRAPH` | Enable graph memory (`true` / `false`) |
349
+
350
+ Environment variables take precedence over values in the config file, which take precedence over defaults.
351
+
352
+ ## Development
353
+
354
+ ```bash
355
+ cd cli/python
356
+ python -m venv .venv && source .venv/bin/activate
357
+ pip install -e ".[dev]"
358
+
359
+ # Run during development
360
+ python -m mem0_cli --help
361
+ mem0 add "test memory" --user-id alice
362
+ ```
363
+
364
+ ## Releasing
365
+
366
+ 1. Update `version` in `pyproject.toml`
367
+ 2. Create a GitHub Release with tag `cli-v<version>` (e.g. `cli-v0.2.1`)
368
+
369
+ For a pre-release, use a beta version like `0.2.1b1` and check the **pre-release** checkbox.
370
+
371
+ ## Documentation
372
+
373
+ Full documentation is available at [docs.mem0.ai/platform/cli](https://docs.mem0.ai/platform/cli).
374
+
375
+ ## License
376
+
377
+ Apache-2.0
@@ -0,0 +1,349 @@
1
+ # mem0 CLI (Python)
2
+
3
+ The official command-line interface for [mem0](https://mem0.ai) — the memory layer for AI agents. Python implementation.
4
+
5
+ > **Built for AI agents.** Pass `--agent` (or `--json`) as a global flag on any command to get structured JSON output optimized for programmatic consumption — sanitized fields, no colors or spinners, and errors as JSON too.
6
+
7
+ ## Prerequisites
8
+
9
+ - Python **3.10+**
10
+
11
+ ## Installation
12
+
13
+ ### Using pipx (recommended)
14
+
15
+ ```bash
16
+ pipx install mem0-cli
17
+ ```
18
+
19
+ ### Using pip
20
+
21
+ ```bash
22
+ pip install mem0-cli
23
+ ```
24
+
25
+ > **Note:** On macOS with Homebrew Python, `pip install` outside a virtual environment will fail with an `externally-managed-environment` error ([PEP 668](https://peps.python.org/pep-0668/)). Use `pipx` instead, or install inside a virtual environment.
26
+
27
+ ## Quick start
28
+
29
+ ```bash
30
+ # Interactive setup wizard
31
+ mem0 init
32
+
33
+ # Or login via email
34
+ mem0 init --email alice@company.com
35
+
36
+ # Or authenticate with an existing API key
37
+ mem0 init --api-key m0-xxx
38
+
39
+ # Add a memory
40
+ mem0 add "I prefer dark mode and use vim keybindings" --user-id alice
41
+
42
+ # Search memories
43
+ mem0 search "What are Alice's preferences?" --user-id alice
44
+
45
+ # List all memories for a user
46
+ mem0 list --user-id alice
47
+
48
+ # Get a specific memory
49
+ mem0 get <memory-id>
50
+
51
+ # Update a memory
52
+ mem0 update <memory-id> "I switched to light mode"
53
+
54
+ # Delete a memory
55
+ mem0 delete <memory-id>
56
+ ```
57
+
58
+ ## Commands
59
+
60
+ ### `mem0 init`
61
+
62
+ Interactive setup wizard. Prompts for your API key and default user ID.
63
+
64
+ ```bash
65
+ mem0 init
66
+ mem0 init --api-key m0-xxx --user-id alice
67
+ mem0 init --email alice@company.com
68
+ ```
69
+
70
+ If an existing configuration is detected, the CLI asks for confirmation before overwriting. Use `--force` to skip the prompt (useful in CI/CD).
71
+
72
+ ```bash
73
+ mem0 init --api-key m0-xxx --user-id alice --force
74
+ ```
75
+
76
+ | Flag | Description |
77
+ |------|-------------|
78
+ | `--api-key` | API key (skip prompt) |
79
+ | `-u, --user-id` | Default user ID (skip prompt) |
80
+ | `--email` | Login via email verification code |
81
+ | `--code` | Verification code (use with `--email` for non-interactive login) |
82
+ | `--force` | Overwrite existing config without confirmation |
83
+
84
+ ### `mem0 add`
85
+
86
+ Add a memory from text, a JSON messages array, a file, or stdin.
87
+
88
+ ```bash
89
+ mem0 add "I prefer dark mode" --user-id alice
90
+ mem0 add --file conversation.json --user-id alice
91
+ echo "Loves hiking on weekends" | mem0 add --user-id alice
92
+ ```
93
+
94
+ | Flag | Description |
95
+ |------|-------------|
96
+ | `-u, --user-id` | Scope to a user |
97
+ | `--agent-id` | Scope to an agent |
98
+ | `--messages` | Conversation messages as JSON |
99
+ | `-f, --file` | Read messages from a JSON file |
100
+ | `-m, --metadata` | Custom metadata as JSON |
101
+ | `--categories` | Categories (JSON array or comma-separated) |
102
+ | `--graph / --no-graph` | Enable or disable graph memory extraction |
103
+ | `-o, --output` | Output format: `text`, `json`, `quiet` |
104
+
105
+ ### `mem0 search`
106
+
107
+ Search memories using natural language.
108
+
109
+ ```bash
110
+ mem0 search "dietary restrictions" --user-id alice
111
+ mem0 search "preferred tools" --user-id alice --output json --top-k 5
112
+ ```
113
+
114
+ | Flag | Description |
115
+ |------|-------------|
116
+ | `-u, --user-id` | Filter by user |
117
+ | `-k, --top-k` | Number of results (default: 10) |
118
+ | `--threshold` | Minimum similarity score (default: 0.3) |
119
+ | `--rerank` | Enable reranking |
120
+ | `--keyword` | Use keyword search instead of semantic |
121
+ | `--filter` | Advanced filter expression (JSON) |
122
+ | `--graph / --no-graph` | Enable or disable graph in search |
123
+ | `-o, --output` | Output format: `text`, `json`, `table` |
124
+
125
+ ### `mem0 list`
126
+
127
+ List memories with optional filters and pagination.
128
+
129
+ ```bash
130
+ mem0 list --user-id alice
131
+ mem0 list --user-id alice --category preferences --output json
132
+ mem0 list --user-id alice --after 2024-01-01 --page-size 50
133
+ ```
134
+
135
+ | Flag | Description |
136
+ |------|-------------|
137
+ | `-u, --user-id` | Filter by user |
138
+ | `--page` | Page number (default: 1) |
139
+ | `--page-size` | Results per page (default: 100) |
140
+ | `--category` | Filter by category |
141
+ | `--after` | Created after date (YYYY-MM-DD) |
142
+ | `--before` | Created before date (YYYY-MM-DD) |
143
+ | `-o, --output` | Output format: `text`, `json`, `table` |
144
+
145
+ ### `mem0 get`
146
+
147
+ Retrieve a specific memory by ID.
148
+
149
+ ```bash
150
+ mem0 get 7b3c1a2e-4d5f-6789-abcd-ef0123456789
151
+ mem0 get 7b3c1a2e-4d5f-6789-abcd-ef0123456789 --output json
152
+ ```
153
+
154
+ ### `mem0 update`
155
+
156
+ Update the text or metadata of an existing memory.
157
+
158
+ ```bash
159
+ mem0 update <memory-id> "Updated preference text"
160
+ mem0 update <memory-id> --metadata '{"priority": "high"}'
161
+ echo "new text" | mem0 update <memory-id>
162
+ ```
163
+
164
+ ### `mem0 delete`
165
+
166
+ Delete a single memory, all memories for a scope, or an entire entity.
167
+
168
+ ```bash
169
+ # Delete a single memory
170
+ mem0 delete <memory-id>
171
+
172
+ # Delete all memories for a user
173
+ mem0 delete --all --user-id alice --force
174
+
175
+ # Delete all memories project-wide
176
+ mem0 delete --all --project --force
177
+
178
+ # Preview what would be deleted
179
+ mem0 delete --all --user-id alice --dry-run
180
+ ```
181
+
182
+ | Flag | Description |
183
+ |------|-------------|
184
+ | `--all` | Delete all memories matching scope filters |
185
+ | `--entity` | Delete the entity and all its memories |
186
+ | `--project` | With `--all`: delete all memories project-wide |
187
+ | `--dry-run` | Preview without deleting |
188
+ | `--force` | Skip confirmation prompt |
189
+
190
+ ### `mem0 import`
191
+
192
+ Bulk import memories from a JSON file.
193
+
194
+ ```bash
195
+ mem0 import data.json --user-id alice
196
+ ```
197
+
198
+ The file should be a JSON array where each item has a `memory` (or `text` or `content`) field and optional `user_id`, `agent_id`, and `metadata` fields.
199
+
200
+ ### `mem0 config`
201
+
202
+ View or modify the local CLI configuration.
203
+
204
+ ```bash
205
+ mem0 config show # Display current config (secrets redacted)
206
+ mem0 config get api_key # Get a specific value
207
+ mem0 config set user_id bob # Set a value
208
+ ```
209
+
210
+ ### `mem0 entity`
211
+
212
+ List or delete entities (users, agents, apps, runs).
213
+
214
+ ```bash
215
+ mem0 entity list users
216
+ mem0 entity list agents --output json
217
+ mem0 entity delete --user-id alice --force
218
+ ```
219
+
220
+ ### `mem0 event`
221
+
222
+ Inspect background processing events created by async operations (e.g. bulk deletes, large add jobs).
223
+
224
+ ```bash
225
+ # List recent events
226
+ mem0 event list
227
+
228
+ # Check the status of a specific event
229
+ mem0 event status <event-id>
230
+ ```
231
+
232
+ | Flag | Description |
233
+ |------|-------------|
234
+ | `-o, --output` | Output format: `text`, `json` |
235
+
236
+ ### `mem0 status`
237
+
238
+ Verify your API connection and display the current project.
239
+
240
+ ```bash
241
+ mem0 status
242
+ ```
243
+
244
+ ### `mem0 version`
245
+
246
+ Print the CLI version.
247
+
248
+ ```bash
249
+ mem0 version
250
+ ```
251
+
252
+ ## Agent mode
253
+
254
+ Pass `--agent` (or its alias `--json`) as a **global flag** on any command to get output designed for AI agent tool loops:
255
+
256
+ ```bash
257
+ mem0 --agent search "user preferences" --user-id alice
258
+ mem0 --agent add "User prefers dark mode" --user-id alice
259
+ mem0 --agent list --user-id alice
260
+ mem0 --agent delete --all --user-id alice --force
261
+ ```
262
+
263
+ Every command returns the same envelope shape:
264
+
265
+ ```json
266
+ {
267
+ "status": "success",
268
+ "command": "search",
269
+ "duration_ms": 134,
270
+ "scope": { "user_id": "alice" },
271
+ "count": 2,
272
+ "data": [
273
+ { "id": "abc-123", "memory": "User prefers dark mode", "score": 0.97, "created_at": "2026-01-15", "categories": ["preferences"] }
274
+ ]
275
+ }
276
+ ```
277
+
278
+ What agent mode does differently from `--output json`:
279
+
280
+ - **Sanitized `data`**: only the fields an agent needs (id, memory, score, etc.) — no internal API noise
281
+ - **No human output**: spinners, colors, and banners are suppressed entirely
282
+ - **Errors as JSON**: errors go to stdout as `{"status": "error", "command": "...", "error": "..."}` with a non-zero exit code
283
+
284
+ Use `mem0 help --json` to get the full command tree as JSON — useful for agents that need to self-discover available commands.
285
+
286
+ ## Output formats
287
+
288
+ Control how results are displayed with `--output`:
289
+
290
+ | Format | Description |
291
+ |--------|-------------|
292
+ | `text` | Human-readable with colors and formatting (default) |
293
+ | `json` | Structured JSON for piping to `jq` (raw API response) |
294
+ | `table` | Tabular format (default for `list`) |
295
+ | `quiet` | Minimal — just IDs or status codes |
296
+ | `agent` | Structured JSON envelope with sanitized fields (set by `--agent`/`--json`) |
297
+
298
+ ## Global flags
299
+
300
+ These flags are available on all commands:
301
+
302
+ | Flag | Description |
303
+ |------|-------------|
304
+ | `--json` | Enable agent mode: structured JSON envelope output, no colors or spinners |
305
+ | `--agent` | Alias for `--json` |
306
+ | `--api-key` | Override the configured API key for this request |
307
+ | `--base-url` | Override the configured API base URL for this request |
308
+ | `-o, --output` | Set the output format |
309
+
310
+ ## Environment variables
311
+
312
+ | Variable | Description |
313
+ |----------|-------------|
314
+ | `MEM0_API_KEY` | API key (overrides config file) |
315
+ | `MEM0_BASE_URL` | API base URL |
316
+ | `MEM0_USER_ID` | Default user ID |
317
+ | `MEM0_AGENT_ID` | Default agent ID |
318
+ | `MEM0_APP_ID` | Default app ID |
319
+ | `MEM0_RUN_ID` | Default run ID |
320
+ | `MEM0_ENABLE_GRAPH` | Enable graph memory (`true` / `false`) |
321
+
322
+ Environment variables take precedence over values in the config file, which take precedence over defaults.
323
+
324
+ ## Development
325
+
326
+ ```bash
327
+ cd cli/python
328
+ python -m venv .venv && source .venv/bin/activate
329
+ pip install -e ".[dev]"
330
+
331
+ # Run during development
332
+ python -m mem0_cli --help
333
+ mem0 add "test memory" --user-id alice
334
+ ```
335
+
336
+ ## Releasing
337
+
338
+ 1. Update `version` in `pyproject.toml`
339
+ 2. Create a GitHub Release with tag `cli-v<version>` (e.g. `cli-v0.2.1`)
340
+
341
+ For a pre-release, use a beta version like `0.2.1b1` and check the **pre-release** checkbox.
342
+
343
+ ## Documentation
344
+
345
+ Full documentation is available at [docs.mem0.ai/platform/cli](https://docs.mem0.ai/platform/cli).
346
+
347
+ ## License
348
+
349
+ Apache-2.0