@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,336 @@
1
+ Perform CRUD operations on Directus Collections.
2
+
3
+ <actions>
4
+
5
+ - `create`: Add new collections
6
+ - `read`: Retrieve available collections
7
+ - `update`: Modify existing collections
8
+ - `delete`: Remove collections </actions>
9
+
10
+ <collection_structure>
11
+
12
+ ### Collection Structure
13
+
14
+ ```json
15
+ {
16
+ "collection": "products",
17
+ "meta": {
18
+ "collection": "ai_prompts",
19
+ "icon": "inventory_2", // Any Material Symbols icons
20
+ "note": "Main product catalog with inventory tracking" // Helpful 1 sentence description
21
+ "color": "#6366F1", // Color shown in content module sidebar
22
+ "singleton": false, // Single-item collections (settings, globals)
23
+ "hidden": false, // Hide from navigation
24
+ "accountability": "all", // Track who activity and revisions (`"all"`, `"activity"`, `null`)
25
+ "sort_field": "sort", // Default sorting field (auto-creates if needed)
26
+ "archive_app_filter": true, // Enable soft delete in the app
27
+ "archive_field": "status", // Field used for archiving (status, deleted_at, etc.)
28
+ "archive_value": "archived", // Value that marks items as archived
29
+ "unarchive_value": "published", // Value that marks items as active
30
+ "display_template": "{{name}} - ${{price}}",
31
+ "versioning": false, // Enable content versioning for this collection
32
+ "sort": 2, // Sort order for this collection
33
+ "group": null, // Parent collection (use to group and nest collections in data model)
34
+ "collapse": "open" // Default collection to expanded or collapsed if child collections
35
+ "preview_url": "https://store.example.com/products/{{slug}}", // Live preview URL to view items within collection - supports using template variables
36
+ "translations": [
37
+ {
38
+ "language": "en-US",
39
+ "translation": "Products",
40
+ "singular": "product",
41
+ "plural": "products"
42
+ },
43
+ {
44
+ "language": "es-ES",
45
+ "translation": "Productos",
46
+ "singular": "producto",
47
+ "plural": "productos"
48
+ }
49
+ ],
50
+ }
51
+ }
52
+ ```
53
+
54
+ </collection_structure>
55
+
56
+ <creating_collections>
57
+
58
+ - **Primary Keys**: Use UUID primary keys (see `fields` tool `<primary_keys>` section for detailed guidance)
59
+ - **System Fields**: Include system fields for content collections (see `<system_fields>` section below for complete
60
+ template) unless specifically asked by user to omit them.
61
+ - ALWAYS show the collection URL to the user if it is present in the result.
62
+ - When creating a new collection, include both collection settings and initial fields (see `fields` tool for complete
63
+ examples).
64
+
65
+ ### Basic Collection Example
66
+
67
+ ```json
68
+ {
69
+ "action": "create",
70
+ "data": {
71
+ "collection": "articles",
72
+ "fields": [
73
+ {
74
+ "field": "id",
75
+ "type": "uuid",
76
+ "meta": { "special": ["uuid"], "hidden": true, "readonly": true, "interface": "input" },
77
+ "schema": { "is_primary_key": true, "length": 36, "has_auto_increment": false }
78
+ },
79
+ {
80
+ "field": "title",
81
+ "type": "string",
82
+ "meta": { "interface": "input", "required": true },
83
+ "schema": { "is_nullable": false }
84
+ }
85
+ ],
86
+ "schema": {}, // Always send empty object for new collection unless creating a folder collection
87
+ "meta": {
88
+ "singleton": false,
89
+ "display_template": "{{title}}"
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ </creating_collections>
96
+
97
+ <system_fields>
98
+
99
+ ### Complete System Fields Template
100
+
101
+ For content collections (blogs, products, pages), include these optional system fields for full CMS functionality:
102
+
103
+ ```json
104
+ {
105
+ "action": "create",
106
+ "data": {
107
+ "collection": "articles",
108
+ "fields": [
109
+ {
110
+ "field": "id",
111
+ "type": "uuid",
112
+ "meta": {
113
+ "hidden": true,
114
+ "readonly": true,
115
+ "interface": "input",
116
+ "special": ["uuid"]
117
+ },
118
+ "schema": {
119
+ "is_primary_key": true,
120
+ "length": 36,
121
+ "has_auto_increment": false
122
+ }
123
+ },
124
+ {
125
+ "field": "status",
126
+ "type": "string",
127
+ "meta": {
128
+ "width": "full",
129
+ "options": {
130
+ // You might choose to customize these options based on the users request
131
+ "choices": [
132
+ {
133
+ "text": "$t:published",
134
+ "value": "published",
135
+ "color": "var(--theme--primary)"
136
+ },
137
+ {
138
+ "text": "$t:draft",
139
+ "value": "draft",
140
+ "color": "var(--theme--foreground)"
141
+ },
142
+ {
143
+ "text": "$t:archived",
144
+ "value": "archived",
145
+ "color": "var(--theme--warning)"
146
+ }
147
+ ]
148
+ },
149
+ "interface": "select-dropdown",
150
+ "display": "labels",
151
+ "display_options": {
152
+ "showAsDot": true,
153
+ "choices": [
154
+ {
155
+ "text": "$t:published",
156
+ "value": "published",
157
+ "color": "var(--theme--primary)",
158
+ "foreground": "var(--theme--primary)",
159
+ "background": "var(--theme--primary-background)"
160
+ },
161
+ {
162
+ "text": "$t:draft",
163
+ "value": "draft",
164
+ "color": "var(--theme--foreground)",
165
+ "foreground": "var(--theme--foreground)",
166
+ "background": "var(--theme--background-normal)"
167
+ },
168
+ {
169
+ "text": "$t:archived",
170
+ "value": "archived",
171
+ "color": "var(--theme--warning)",
172
+ "foreground": "var(--theme--warning)",
173
+ "background": "var(--theme--warning-background)"
174
+ }
175
+ ]
176
+ }
177
+ },
178
+ "schema": {
179
+ "default_value": "draft",
180
+ "is_nullable": false
181
+ }
182
+ },
183
+ {
184
+ "field": "sort",
185
+ "type": "integer",
186
+ "meta": {
187
+ "interface": "input",
188
+ "hidden": true
189
+ },
190
+ "schema": {}
191
+ },
192
+ {
193
+ "field": "user_created",
194
+ "type": "uuid",
195
+ "meta": {
196
+ "special": ["user-created"],
197
+ "interface": "select-dropdown-m2o",
198
+ "options": {
199
+ "template": "{{avatar}} {{first_name}} {{last_name}}"
200
+ },
201
+ "display": "user",
202
+ "readonly": true,
203
+ "hidden": true,
204
+ "width": "half"
205
+ },
206
+ "schema": {}
207
+ },
208
+ {
209
+ "field": "date_created",
210
+ "type": "timestamp",
211
+ "meta": {
212
+ "special": ["date-created"],
213
+ "interface": "datetime",
214
+ "readonly": true,
215
+ "hidden": true,
216
+ "width": "half",
217
+ "display": "datetime",
218
+ "display_options": {
219
+ "relative": true
220
+ }
221
+ },
222
+ "schema": {}
223
+ },
224
+ {
225
+ "field": "user_updated",
226
+ "type": "uuid",
227
+ "meta": {
228
+ "special": ["user-updated"],
229
+ "interface": "select-dropdown-m2o",
230
+ "options": {
231
+ "template": "{{avatar}} {{first_name}} {{last_name}}"
232
+ },
233
+ "display": "user",
234
+ "readonly": true,
235
+ "hidden": true,
236
+ "width": "half"
237
+ },
238
+ "schema": {}
239
+ },
240
+ {
241
+ "field": "date_updated",
242
+ "type": "timestamp",
243
+ "meta": {
244
+ "special": ["date-updated"],
245
+ "interface": "datetime",
246
+ "readonly": true,
247
+ "hidden": true,
248
+ "width": "half",
249
+ "display": "datetime",
250
+ "display_options": {
251
+ "relative": true
252
+ }
253
+ },
254
+ "schema": {}
255
+ }
256
+ ],
257
+ "schema": {}, // Always send empty object for new collection unless creating a folder collection
258
+ "meta": {
259
+ "sort_field": "sort",
260
+ "archive_field": "status",
261
+ "archive_value": "archived",
262
+ "unarchive_value": "draft",
263
+ "singleton": false
264
+ }
265
+ }
266
+ }
267
+ ```
268
+
269
+ **System Fields Explained:**
270
+
271
+ - `status` - Content workflow (draft/published/archived) with visual indicators
272
+ - `sort` - Manual ordering capability (used with `sort_field` in collection meta)
273
+ - `user_created`/`user_updated` - Track content authors and editors (requires relations to `directus_users`)
274
+ - `date_created`/`date_updated` - Automatic timestamps for content lifecycle tracking
275
+
276
+ **Required Relations for User Fields:** After creating the collection, add relations for user tracking fields (use
277
+ `relations` tool):
278
+
279
+ ```json
280
+ // User created relation
281
+ {
282
+ "action": "create",
283
+ "data": {
284
+ "collection": "articles",
285
+ "field": "user_created",
286
+ "related_collection": "directus_users",
287
+ "schema": {}
288
+ }
289
+ }
290
+
291
+ // User updated relation
292
+ {
293
+ "action": "create",
294
+ "data": {
295
+ "collection": "articles",
296
+ "field": "user_updated",
297
+ "related_collection": "directus_users",
298
+ "schema": {}
299
+ }
300
+ }
301
+ ```
302
+
303
+ </system_fields>
304
+
305
+ <translations>
306
+ For collection name translations, check for `languages` collection first, then provide collection names in available languages (similar to field translations - see `fields` tool `<translations>` section for translation workflow).
307
+
308
+ ```json
309
+ {
310
+ "meta": {
311
+ "translations": [
312
+ { "language": "en-US", "translation": "Products", "singular": "product", "plural": "products" },
313
+ { "language": "es-ES", "translation": "Productos", "singular": "producto", "plural": "productos" }
314
+ ]
315
+ }
316
+ }
317
+ ```
318
+
319
+ </translations>
320
+
321
+ <display_templates>
322
+
323
+ Control how collection items appear in relationships and lists:
324
+
325
+ ```json
326
+ {
327
+ "meta": {
328
+ "display_template": "{{name}} - {{category}} ({{status}})"
329
+ }
330
+ }
331
+ ```
332
+
333
+ **Template Variables:**
334
+
335
+ - `{{field_name}}` - Any field from the collection
336
+ - `{{field_name.nested}}` - Access nested object properties </display_templates>