@directus/api 30.0.0 → 31.0.0

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 (83) hide show
  1. package/dist/app.js +5 -0
  2. package/dist/auth/drivers/oauth2.js +17 -3
  3. package/dist/auth/drivers/openid.js +17 -3
  4. package/dist/controllers/mcp.d.ts +2 -0
  5. package/dist/controllers/mcp.js +33 -0
  6. package/dist/controllers/users.js +17 -7
  7. package/dist/controllers/versions.js +3 -2
  8. package/dist/database/errors/dialects/mssql.d.ts +1 -1
  9. package/dist/database/errors/dialects/mssql.js +18 -10
  10. package/dist/database/migrations/20250813A-add-mcp.d.ts +3 -0
  11. package/dist/database/migrations/20250813A-add-mcp.js +18 -0
  12. package/dist/database/run-ast/README.md +46 -0
  13. package/dist/mcp/define.d.ts +2 -0
  14. package/dist/mcp/define.js +3 -0
  15. package/dist/mcp/index.d.ts +1 -0
  16. package/dist/mcp/index.js +1 -0
  17. package/dist/mcp/schema.d.ts +485 -0
  18. package/dist/mcp/schema.js +219 -0
  19. package/dist/mcp/server.d.ts +97 -0
  20. package/dist/mcp/server.js +310 -0
  21. package/dist/mcp/tools/assets.d.ts +3 -0
  22. package/dist/mcp/tools/assets.js +54 -0
  23. package/dist/mcp/tools/collections.d.ts +84 -0
  24. package/dist/mcp/tools/collections.js +90 -0
  25. package/dist/mcp/tools/fields.d.ts +101 -0
  26. package/dist/mcp/tools/fields.js +157 -0
  27. package/dist/mcp/tools/files.d.ts +235 -0
  28. package/dist/mcp/tools/files.js +103 -0
  29. package/dist/mcp/tools/flows.d.ts +323 -0
  30. package/dist/mcp/tools/flows.js +85 -0
  31. package/dist/mcp/tools/folders.d.ts +95 -0
  32. package/dist/mcp/tools/folders.js +96 -0
  33. package/dist/mcp/tools/index.d.ts +15 -0
  34. package/dist/mcp/tools/index.js +29 -0
  35. package/dist/mcp/tools/items.d.ts +87 -0
  36. package/dist/mcp/tools/items.js +141 -0
  37. package/dist/mcp/tools/operations.d.ts +171 -0
  38. package/dist/mcp/tools/operations.js +77 -0
  39. package/dist/mcp/tools/prompts/assets.md +8 -0
  40. package/dist/mcp/tools/prompts/collections.md +336 -0
  41. package/dist/mcp/tools/prompts/fields.md +521 -0
  42. package/dist/mcp/tools/prompts/files.md +180 -0
  43. package/dist/mcp/tools/prompts/flows.md +495 -0
  44. package/dist/mcp/tools/prompts/folders.md +34 -0
  45. package/dist/mcp/tools/prompts/index.d.ts +16 -0
  46. package/dist/mcp/tools/prompts/index.js +19 -0
  47. package/dist/mcp/tools/prompts/items.md +317 -0
  48. package/dist/mcp/tools/prompts/operations.md +721 -0
  49. package/dist/mcp/tools/prompts/relations.md +386 -0
  50. package/dist/mcp/tools/prompts/schema.md +130 -0
  51. package/dist/mcp/tools/prompts/system-prompt-description.md +1 -0
  52. package/dist/mcp/tools/prompts/system-prompt.md +44 -0
  53. package/dist/mcp/tools/prompts/trigger-flow.md +214 -0
  54. package/dist/mcp/tools/relations.d.ts +73 -0
  55. package/dist/mcp/tools/relations.js +93 -0
  56. package/dist/mcp/tools/schema.d.ts +54 -0
  57. package/dist/mcp/tools/schema.js +317 -0
  58. package/dist/mcp/tools/system.d.ts +3 -0
  59. package/dist/mcp/tools/system.js +22 -0
  60. package/dist/mcp/tools/trigger-flow.d.ts +8 -0
  61. package/dist/mcp/tools/trigger-flow.js +48 -0
  62. package/dist/mcp/transport.d.ts +13 -0
  63. package/dist/mcp/transport.js +18 -0
  64. package/dist/mcp/types.d.ts +56 -0
  65. package/dist/mcp/types.js +1 -0
  66. package/dist/services/authentication.js +36 -0
  67. package/dist/services/fields.js +4 -4
  68. package/dist/services/items.js +14 -4
  69. package/dist/services/payload.d.ts +7 -3
  70. package/dist/services/payload.js +26 -12
  71. package/dist/services/server.js +1 -0
  72. package/dist/services/tfa.d.ts +1 -1
  73. package/dist/services/tfa.js +20 -5
  74. package/dist/services/versions.d.ts +6 -4
  75. package/dist/services/versions.js +84 -25
  76. package/dist/types/auth.d.ts +2 -1
  77. package/dist/utils/versioning/deep-map-with-schema.d.ts +23 -0
  78. package/dist/utils/versioning/deep-map-with-schema.js +81 -0
  79. package/dist/utils/versioning/handle-version.d.ts +2 -2
  80. package/dist/utils/versioning/handle-version.js +47 -43
  81. package/dist/utils/versioning/split-recursive.d.ts +4 -0
  82. package/dist/utils/versioning/split-recursive.js +27 -0
  83. package/package.json +30 -29
@@ -0,0 +1,386 @@
1
+ Create and manage relationships between Directus Collections.
2
+
3
+ <prerequisites>
4
+ Before creating relations:
5
+ ✓ Collections must exist (use `collections` tool)
6
+ ✓ Fields must be created with correct types (use `fields` tool)
7
+ ✓ Junction collections must exist for M2M/M2A relationships
8
+ ✓ Optional system user fields (`user_created`/`user_updated`) require relations to `directus_users` (see `collections` tool `<system_fields>` section)
9
+ </prerequisites>
10
+
11
+ <actions>
12
+ - `create`: Establish relationship between collections
13
+ - `read`: View existing relationships
14
+ - `update`: Modify relationship settings (only schema.on_delete/on_update and meta can be updated)
15
+ - `delete`: Remove relationships
16
+ </actions>
17
+
18
+ <basic_relation> After creating relational fields, define the relationship:
19
+
20
+ ```json
21
+ {
22
+ "action": "create",
23
+ "data": {
24
+ "collection": "articles",
25
+ "field": "author",
26
+ "related_collection": "directus_users",
27
+ "meta": { "sort_field": null },
28
+ "schema": { "on_delete": "SET NULL" }
29
+ }
30
+ }
31
+ ```
32
+
33
+ </basic_relation>
34
+
35
+ <relationship_types> <m2o_workflow>
36
+
37
+ ### M2O (Many-to-One)
38
+
39
+ Multiple items in one collection relate to one item in another.
40
+
41
+ **Example**: Many articles → one author
42
+
43
+ **Complete M2O Workflow**:
44
+
45
+ 1. **Add M2O field** to the "many" collection → Use `fields` tool with `type: "uuid"` and
46
+ `interface: "select-dropdown-m2o"` (see `fields` tool `<relationship_fields>` M2O example)
47
+
48
+ 2. **Create relation** (use `relations` tool):
49
+
50
+ ```json
51
+ {
52
+ "action": "create",
53
+ "collection": "articles",
54
+ "field": "author",
55
+ "data": {
56
+ "collection": "articles",
57
+ "field": "author",
58
+ "related_collection": "directus_users",
59
+ "schema": { "on_delete": "SET NULL" }
60
+ }
61
+ }
62
+ ```
63
+
64
+ </m2o_workflow>
65
+
66
+ <o2m_workflow>
67
+
68
+ ### O2M (One-to-Many)
69
+
70
+ One item in a collection relates to many items in another collection.
71
+
72
+ **Example**: One author → many articles
73
+
74
+ **Complete O2M Workflow**:
75
+
76
+ 1. **Add O2M field** to the "one" collection → Use `fields` tool with `type: "alias"`, `special: ["o2m"]`, and
77
+ `interface: "list-o2m"`
78
+
79
+ 2. **Create relation** connecting to existing M2O field (use `relations` tool):
80
+
81
+ ```json
82
+ {
83
+ "action": "create",
84
+ "collection": "articles",
85
+ "field": "author",
86
+ "data": {
87
+ "collection": "articles",
88
+ "field": "author",
89
+ "related_collection": "authors",
90
+ "meta": {
91
+ "one_field": "articles",
92
+ "sort_field": null
93
+ },
94
+ "schema": {
95
+ "on_delete": "SET NULL"
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ </o2m_workflow>
102
+
103
+ <m2m_workflow>
104
+
105
+ ### M2M (Many-to-Many)
106
+
107
+ Items in both collections can relate to multiple items in the other.
108
+
109
+ **Example**: Articles ↔ Tags
110
+
111
+ **Complete M2M Workflow**:
112
+
113
+ 1. **Create junction collection** → Use `collections` tool to create `article_tags` with UUID primary key
114
+
115
+ 2. **Add alias fields** to both collections → Use `fields` tool with `type: "alias"`, `special: ["m2m"]`, and
116
+ `interface: "list-m2m"` (see `fields` tool `<relationship_fields>` M2M example)
117
+
118
+ 3. **Add junction fields** → Use `fields` tool to add `article_id` (UUID), `tag_id` (UUID), and optional `sort`
119
+ (integer) fields to junction collection
120
+
121
+ 4. **Create bidirectional relations** (use `relations` tool with CASCADE):
122
+
123
+ ```json
124
+ // First relation
125
+ {
126
+ "action": "create",
127
+ "collection": "article_tags",
128
+ "field": "article_id",
129
+ "data": {
130
+ "collection": "article_tags",
131
+ "field": "article_id",
132
+ "related_collection": "articles",
133
+ "meta": {
134
+ "one_field": "tags",
135
+ "junction_field": "tag_id",
136
+ "sort_field": "sort"
137
+ },
138
+ "schema": {"on_delete": "CASCADE"}
139
+ }
140
+ }
141
+
142
+ // Second relation
143
+ {
144
+ "action": "create",
145
+ "collection": "article_tags",
146
+ "field": "tag_id",
147
+ "data": {
148
+ "collection": "article_tags",
149
+ "field": "tag_id",
150
+ "related_collection": "tags",
151
+ "meta": {
152
+ "one_field": "articles",
153
+ "junction_field": "article_id"
154
+ },
155
+ "schema": {"on_delete": "CASCADE"}
156
+ }
157
+ }
158
+ ```
159
+
160
+ </m2m_workflow>
161
+
162
+ <m2a_workflow>
163
+
164
+ ### M2A (Many-to-Any)
165
+
166
+ Items can relate to items from multiple different collections.
167
+
168
+ **Example**: Page blocks (hero, text, gallery)
169
+
170
+ **Complete M2A Workflow**:
171
+
172
+ 1. **Create block collections** → Use `collections` tool to create each block type (e.g., `block_hero`, `block_text`,
173
+ `block_gallery`) with UUID primary keys and specific fields
174
+
175
+ 2. **Create junction collection** → Use `collections` tool to create `page_blocks` junction (hidden collection with UUID
176
+ primary key)
177
+
178
+ 3. **Add M2A field** → Use `fields` tool with `type: "alias"`, `special: ["m2a"]`, and `interface: "list-m2a"`
179
+
180
+ 4. **Add junction fields** → Use `fields` tool to add `page` (UUID), `item` (string), `collection` (string), and `sort`
181
+ (integer) fields to junction
182
+
183
+ 5. **Create relations** (use `relations` tool):
184
+
185
+ ```json
186
+ // Item relation (polymorphic)
187
+ {
188
+ "action": "create",
189
+ "collection": "page_blocks",
190
+ "field": "item",
191
+ "data": {
192
+ "collection": "page_blocks",
193
+ "field": "item",
194
+ "related_collection": null,
195
+ "meta": {
196
+ "one_allowed_collections": ["block_hero", "block_text", "block_gallery"],
197
+ "one_collection_field": "collection",
198
+ "junction_field": "page_id"
199
+ }
200
+ }
201
+ }
202
+
203
+ // Page relation
204
+ {
205
+ "action": "create",
206
+ "collection": "page_blocks",
207
+ "field": "page_id",
208
+ "data": {
209
+ "collection": "page_blocks",
210
+ "field": "page_id",
211
+ "related_collection": "pages",
212
+ "meta": {
213
+ "one_field": "blocks",
214
+ "junction_field": "item",
215
+ "sort_field": "sort"
216
+ },
217
+ "schema": {"on_delete": "CASCADE"}
218
+ }
219
+ }
220
+ ```
221
+
222
+ </m2a_workflow>
223
+
224
+ <file_relationships>
225
+
226
+ ### File/Files Relationships
227
+
228
+ **Single File (M2O)**:
229
+
230
+ 1. **Add file field** → Use `fields` tool with `type: "uuid"`, `special: ["file"]`, and `interface: "file"`
231
+
232
+ 2. **Create relation** (use `relations` tool):
233
+
234
+ ```json
235
+ {
236
+ "action": "create",
237
+ "collection": "articles",
238
+ "field": "cover_image",
239
+ "data": {
240
+ "collection": "articles",
241
+ "field": "cover_image",
242
+ "related_collection": "directus_files",
243
+ "schema": { "on_delete": "SET NULL" }
244
+ }
245
+ }
246
+ ```
247
+
248
+ **Multiple Files (M2M)**:
249
+
250
+ **Complete Files Workflow**:
251
+
252
+ 1. **Create junction collection** → Use `collections` tool to create junction with UUID primary key
253
+
254
+ 2. **Add files field** to main collection → Use `fields` tool with `type: "alias"`, `special: ["files"]`, and
255
+ `interface: "files"` (see `fields` tool `<relationship_fields>` Files example)
256
+
257
+ 3. **Add junction fields** → Use `fields` tool to add hidden `article_id` and `directus_files_id` (both UUID) fields to
258
+ junction
259
+
260
+ 4. **Create relations** (use `relations` tool):
261
+
262
+ ```json
263
+ // Article relation
264
+ {
265
+ "action": "create",
266
+ "collection": "article_images",
267
+ "field": "article_id",
268
+ "data": {
269
+ "collection": "article_images",
270
+ "field": "article_id",
271
+ "related_collection": "articles",
272
+ "meta": {
273
+ "one_field": "images",
274
+ "junction_field": "directus_files_id"
275
+ },
276
+ "schema": {"on_delete": "CASCADE"}
277
+ }
278
+ }
279
+
280
+ // File relation
281
+ {
282
+ "action": "create",
283
+ "collection": "article_images",
284
+ "field": "directus_files_id",
285
+ "data": {
286
+ "collection": "article_images",
287
+ "field": "directus_files_id",
288
+ "related_collection": "directus_files",
289
+ "meta": {
290
+ "junction_field": "article_id"
291
+ },
292
+ "schema": {"on_delete": "CASCADE"}
293
+ }
294
+ }
295
+ ```
296
+
297
+ </file_relationships>
298
+
299
+ <translations_workflow>
300
+
301
+ ### Translations
302
+
303
+ Special M2M relationship with `languages` collection.
304
+
305
+ **Complete Translations Workflow**:
306
+
307
+ 1. **Ensure languages collection exists** (use `schema` tool to check)
308
+
309
+ 2. **Create translations junction** → Use `collections` tool to create junction with UUID primary key
310
+
311
+ 3. **Add translations field** → Use `fields` tool with `type: "alias"`, `special: ["translations"]`, and
312
+ `interface: "translations"` (see `fields` tool `<relationship_fields>` Translations example)
313
+
314
+ 4. **Configure junction fields and relations** → Follow M2M pattern with languages collection </translations_workflow>
315
+ </relationship_types>
316
+
317
+ <relation_settings>
318
+
319
+ ## Relation Settings
320
+
321
+ ### Schema Options
322
+
323
+ - `on_delete`:
324
+ - `CASCADE` (default for M2M) - Delete related items
325
+ - `SET NULL` (default for M2O) - Set field to null
326
+ - `NO ACTION` - Prevent deletion
327
+ - `RESTRICT` - Prevent if related items exist
328
+ - `SET DEFAULT` - Set to default value
329
+
330
+ - `on_update`:
331
+ - Same options as `on_delete`
332
+
333
+ ### Meta Options
334
+
335
+ - `one_field`: Field name in related collection (for O2M side)
336
+ - `junction_field`: Opposite field in junction table
337
+ - `sort_field`: Enable manual sorting (typically an integer field)
338
+ - `one_deselect_action`: `nullify` or `delete`
339
+ - `one_allowed_collections`: Array of collection names for M2A
340
+ - `one_collection_field`: Field that stores collection name in M2A </relation_settings>
341
+
342
+ <common_patterns>
343
+
344
+ ## Common Patterns
345
+
346
+ ### Blog System
347
+
348
+ 1. `articles` M2O `directus_users` (author)
349
+ 2. `articles` M2M `tags`
350
+ 3. `articles` M2O `directus_files` (cover_image)
351
+ 4. `articles` M2M `directus_files` (gallery)
352
+ 5. `articles` O2M `comments`
353
+ 6. `comments` M2O `directus_users` (author)
354
+
355
+ ### E-commerce
356
+
357
+ 1. `products` M2M `categories`
358
+ 2. `products` M2O `brands`
359
+ 3. `products` O2M `reviews`
360
+ 4. `products` M2M `directus_files` (gallery)
361
+ 5. `orders` O2M `order_items`
362
+ 6. `order_items` M2O `products`
363
+ 7. `orders` M2O `directus_users` (customer)
364
+ 8. `reviews` M2O `directus_users` (reviewer)
365
+
366
+ ### Page Builder
367
+
368
+ - `pages` M2A `blocks` field (`page_blocks` junction collection)
369
+ - Collections: `block_hero`, `block_text`, `block_gallery` </common_patterns>
370
+
371
+ <naming_conventions>
372
+
373
+ ## Naming Conventions
374
+
375
+ - Junction collections: `{singular}_{plural}` (e.g., `product_categories`)
376
+ - Junction fields: Singular form of related collection (e.g., `product_id`, `category_id`)
377
+ - Alias fields: Plural form for many relations (e.g., `tags`, `categories`)
378
+ - M2O fields: Singular form (e.g., `author`, `brand`) </naming_conventions>
379
+
380
+ <related_tools>
381
+
382
+ ## Related Tools
383
+
384
+ - `collections`: Create collections and junctions first
385
+ - `fields`: Add relational fields before creating relations
386
+ - `schema`: View complete relationship structure </related_tools>
@@ -0,0 +1,130 @@
1
+ Retrieve essential Directus schema information to understand the data structure - collections, fields, and
2
+ relationships. This is a **READ-ONLY discovery tool** designed to help you explore and comprehend existing schema. It is
3
+ for schema exploration and understanding only. For schema modifications, use the dedicated `collections`, `fields`, and
4
+ `relations` tools.
5
+
6
+ **Note**: This tool provides an extremly curated response optimized for LLM understanding, not the raw Directus API
7
+ schema response.
8
+
9
+ ## Operation Modes
10
+
11
+ ### Discovery Mode (Default)
12
+
13
+ **Usage**: Call without parameters or with empty `keys` array
14
+
15
+ ```json
16
+ {}
17
+ ```
18
+
19
+ **Returns**: Lightweight schema overview
20
+
21
+ - `collections`: Alphabetically sorted array of real collection names (database tables)
22
+ - `collection_folders`: Alphabetically sorted array of folder names (UI-only, not real tables). Distinct from file
23
+ folders. They are used for grouping different collections together in the UI.
24
+ - `notes`: Descriptions for both collections and folders (where available)
25
+
26
+ **Important**: Folders share the same namespace as collections. Before creating a new collection, check the `folders`
27
+ array to avoid naming conflicts (e.g., can't create a 'website' collection if a 'website' folder exists).
28
+
29
+ **Sample Response**:
30
+
31
+ ```json
32
+ {
33
+ "collections": ["categories", "contacts", "organizations", "pages", "posts", "products"],
34
+ "collection_folders": ["content", "marketing", "website"],
35
+ "notes": {
36
+ "contacts": "People at the organizations you work with",
37
+ "organizations": "Your clients and customers",
38
+ "pages": "Static pages with page builder blocks",
39
+ "posts": "Blog posts and articles",
40
+ "content": "Content management folder"
41
+ }
42
+ }
43
+ ```
44
+
45
+ **Use case**: Initial exploration, getting oriented with available data structures
46
+
47
+ ### Detailed Mode
48
+
49
+ **Usage**: Specify collections to examine
50
+
51
+ ```json
52
+ { "keys": ["products", "categories", "users"] }
53
+ ```
54
+
55
+ **Returns**: Object of collections with field and relation details
56
+
57
+ - Field definitions (type, validation, defaults)
58
+ - Relationship mappings (foreign keys, junction tables)
59
+ - Interface configurations and display options
60
+ - Field metadata and constraints
61
+ - **Nested field structures** for JSON fields with repeaters/lists (includes recursive nesting)
62
+
63
+ **Sample Response**:
64
+
65
+ ```json
66
+ {
67
+ "posts": {
68
+ "id": {
69
+ "type": "uuid",
70
+ "primary_key": true,
71
+ "readonly": true
72
+ },
73
+ "title": {
74
+ "type": "string",
75
+ "required": true
76
+ },
77
+ "status": {
78
+ "type": "string",
79
+ "interface": {
80
+ "type": "select-dropdown",
81
+ "choices": ["draft", "published", "archived"]
82
+ }
83
+ },
84
+ "category": {
85
+ "type": "uuid",
86
+ "relation": {
87
+ "type": "m2o",
88
+ "related_collections": ["categories"]
89
+ }
90
+ }
91
+ },
92
+ "block_faqs": {
93
+ "headline": {
94
+ "type": "text",
95
+ "interface": {
96
+ "type": "input-rich-text-html"
97
+ }
98
+ },
99
+ "faqs": {
100
+ "type": "json",
101
+ "interface": {
102
+ "type": "list"
103
+ },
104
+ "fields": {
105
+ "title": {
106
+ "type": "text",
107
+ "interface": {
108
+ "type": "input-multiline"
109
+ }
110
+ },
111
+ "answer": {
112
+ "type": "text",
113
+ "interface": {
114
+ "type": "input-multiline"
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
120
+ }
121
+ ```
122
+
123
+ **Use case**: Deep-dive analysis of specific collections before working with data or schema.
124
+
125
+ ## Recommended Workflow
126
+
127
+ 1. **Discover**: Call without `keys` to see all available collections
128
+ 2. **Analyze**: Based on user requirements, identify relevant collections
129
+ 3. **Detail**: Call with specific collection names to understand field structures
130
+ 4. **Implement**: Use appropriate CRUD tools with schema knowledge
@@ -0,0 +1 @@
1
+ IMPORTANT! Always call this tool first. It will retrieve important information about your role.
@@ -0,0 +1,44 @@
1
+ You are **Directus Assistant**, an expert in Directus CMS with direct access to a Directus instance through specialized
2
+ tools.
3
+
4
+ ## Core Expertise
5
+
6
+ - **Content Specialist**: Content management, editing, and optimization
7
+ - **Schema Architect**: Database design, relationships, and data modeling
8
+ - **Automation Expert**: Flows, webhooks, and workflow configuration
9
+ - **API Integration**: REST/GraphQL patterns and system integration
10
+
11
+ ## Communication Style
12
+
13
+ - **Be concise**: Users prefer short, direct responses. One-line confirmations: "Created collection 'products'"
14
+ - **Match the audience**: Technical for developers, plain language for content editors
15
+ - **NEVER guess**: If not at least 99% about field values or user intent, ask for clarification
16
+
17
+ ## Critical Operations
18
+
19
+ ### Schema & Data Changes
20
+
21
+ - **Confirm before modifying**: Collections, fields, relations always need approval from the user.
22
+ - **Check namespace conflicts**: Collection folders and regular collections share namespace. Collection folders are
23
+ distinct from file folders. Collection folders are just collection entries without a corresponding table in the
24
+ database used for grouping.
25
+ - **Respect workflows**: Check draft/published states before modifications
26
+
27
+ ### Safety Rules
28
+
29
+ - **Deletions require confirmation**: ALWAYS ask before deleting anything
30
+ - **Warn on bulk operations**: Alert when affecting many items ("This updates 500 items")
31
+ - **Avoid duplicates**: Never create duplicates if you can't modify existing items
32
+ - **Use semantic HTML**: No classes, IDs, or inline styles in content fields (unless explictly asked for by the user)
33
+
34
+ ### Error Recovery
35
+
36
+ - **Auto-fix clear errors**: Retry once for obvious issues like "field X required"
37
+ - **Stop after 2 attempts**: Consult user if errors persist or are unclear
38
+ - **Optimize queries**: Use `fields` param to minimize overfetching and pagination for large datasets
39
+
40
+ ## Workflow
41
+
42
+ 1. Start with `schema()` to discover collections
43
+ 2. Use `schema(keys: ["collection_name"])` for field details relevant to the user task
44
+ 3. Perform operations based on user needs and permissions