@xano/developer-mcp 2.0.5 → 2.2.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.
@@ -0,0 +1,408 @@
1
+ ---
2
+ applyTo: "api/**/*.xs, function/**/*.xs"
3
+ ---
4
+
5
+ # File Uploads (Native Xano Storage)
6
+
7
+ > **TL;DR:** To accept an uploaded file, declare the input as `file?` — **never** `image?`. Only `file` pre-processes the upload and populates `.path`; `image`/`attachment`/`video`/`audio` pass the raw upload object and every `storage.*` op then fails with `Missing param: path` (HTTP 400). Store with `storage.create_attachment` (accepts any file type), save the result to an `attachment?`/`image?` column, then return a viewable link: `storage.sign_private_url` for **private** files, or the instance URL + `.path` for **public** files.
8
+
9
+ This topic covers uploading files **to Xano's own private/public storage** (the vault). For pushing files to external buckets (AWS S3, Azure Blob, GCP Storage), see `integrations/cloud-storage` instead.
10
+
11
+ > **Comment syntax note:** XanoScript comments use `//` only (never `#`), and `//` is valid **only on its own line at the `input {}` / `stack {}` / top level — never inside an operation's `{ ... }` argument block and never as a trailing same-line comment**. Putting a comment inside `storage.create_attachment { ... }` or after `file? photo` is a parse error. Every example below follows this rule.
12
+
13
+ ## Quick Reference
14
+
15
+ | Concern | Correct | Wrong |
16
+ |---------|---------|-------|
17
+ | Input type for an upload | `file? my_file` / `file[]? my_files` | `image?`, `attachment?`, `video?`, `audio?` |
18
+ | Storage op for any file type (PDF, HEIC, …) | `storage.create_attachment` | `storage.create_image` (image extensions only) |
19
+ | Storage op for images only (JPEG/PNG/GIF/WEBP) | `storage.create_image` | — |
20
+ | Reading the stored path | `$stored_file.path` | `$input.my_file.tmp_name`, `.path` (not real input properties) |
21
+ | Viewing a **private** file | `storage.sign_private_url` (pathname + ttl, one arg per line) | reading `.path` directly (returns HTTP 403) |
22
+ | Viewing a **public** file | instance base URL `~ $stored_file.path` (no signing) | `storage.sign_private_url` (works but is unnecessary) |
23
+ | Multiple-file form field | append as `field[]` (e.g. `photos[]`) | append repeatedly as `photos` (only the last file is kept) |
24
+ | Required `storage.*` args | always pass `value`, `access`, **and** `filename` | omitting `access` or `filename` (validation error) |
25
+ | Frontend `Content-Type` | let the browser set it | manually setting `multipart/form-data` |
26
+
27
+ ## The Core Rule: `file?`, not `image?`
28
+
29
+ When the input is declared `image?` (or `video?`/`audio?`/`attachment?`), Xano hands your stack the raw upload object, which does **not** have a populated `.path`. Xano detects the missing `.path` at the **input-parsing layer**, before your stack even runs, so every upload fails:
30
+
31
+ ```
32
+ Status 400 Bad Request
33
+ { "code": "ERROR_CODE_INPUT_ERROR", "message": "Missing param: path",
34
+ "payload": { "param": "my_file.path" } }
35
+ ```
36
+
37
+ Because this fires before the stack runs, no in-stack workaround (e.g. copying `tmp_name` into `.path`) can rescue it — see Common Mistakes. When the input is declared `file?`, Xano pre-processes the multipart upload and sets `.path` **before the stack runs**. This is the single fix for `Missing param: path`.
38
+
39
+ > The input type names (`image`, `video`, `audio`, `attachment`, `file`) look like semantic choices but are technical: **only `file` populates `.path` on a multipart upload.** Use `file?` universally for uploads regardless of what kind of file you expect.
40
+
41
+ ### Input type forms
42
+
43
+ ```xs
44
+ // single file, optional
45
+ file? my_file
46
+ // single file, required
47
+ file my_file
48
+ // multiple files, optional array
49
+ file[]? my_files
50
+ // multiple files, required array
51
+ file[] my_files
52
+ ```
53
+
54
+ ## Storage Operations
55
+
56
+ All `storage.create_*` operations require three arguments — `value`, `access`, and `filename` — written one per line (block arguments are newline-separated; commas are only used inside object literals like `data = { ... }`).
57
+
58
+ ### `storage.create_attachment` — any file type (recommended default)
59
+
60
+ ```xs
61
+ storage.create_attachment {
62
+ value = $input.my_file
63
+ access = "private"
64
+ filename = $input.my_file.name
65
+ } as $stored_file
66
+ ```
67
+
68
+ Accepts images, PDFs, HEIC, and any other file type. Use this for documents, receipts, mixed uploads — anything where the file type is not guaranteed to be an image. Set `access` to `"private"` (default for sensitive data) or `"public"`.
69
+
70
+ ### `storage.create_image` — images only
71
+
72
+ ```xs
73
+ storage.create_image {
74
+ value = $input.my_file
75
+ access = "private"
76
+ filename = $input.my_file.name
77
+ } as $stored_file
78
+ ```
79
+
80
+ Validates the extension internally and **only accepts JPEG, PNG, GIF, WEBP**. A PDF or HEIC upload returns `Invalid file extension.` (HTTP 500, `code: ERROR_FATAL`). Only use when you are certain the upload will always be one of those image formats; otherwise prefer `storage.create_attachment`.
81
+
82
+ ### The stored-file object
83
+
84
+ Both ops return an object with this shape (verified against a live workspace):
85
+
86
+ ```
87
+ {
88
+ "access": "private", // or "public" — the access you passed
89
+ "path": "/vault/Xq9lrwqH/.../doc.pdf",
90
+ "name": "doc.pdf",
91
+ "type": "image" | "pdf" | "video" | "audio" | ...,
92
+ "size": 303, // bytes
93
+ "mime": "application/pdf", // full MIME type
94
+ "meta": { "validated": false } // images add "width" and "height"
95
+ }
96
+ ```
97
+
98
+ `.path` is the permanent Xano vault path. Use it everywhere — in the DB record, in `sign_private_url`, and in responses. Save the **whole object** into an `attachment?`/`image?` column (not just the path) so the metadata is preserved.
99
+
100
+ ### Viewing a private file — `storage.sign_private_url`
101
+
102
+ A `private` file is **not** directly reachable: requesting its `.path` without a signature returns HTTP 403. Generate a time-limited signed URL to display or download it:
103
+
104
+ ```xs
105
+ storage.sign_private_url {
106
+ pathname = $stored_file.path
107
+ ttl = 3600
108
+ } as $signed_url
109
+ ```
110
+
111
+ `pathname` is the stored `.path` (use `$record.file.path` after reading the record back from the database). `ttl` is the lifetime in seconds, so `3600` = 1 hour; the URL stops working once it expires.
112
+
113
+ ### Viewing a public file — no signing needed
114
+
115
+ A file stored with `access = "public"` is served **directly** at your instance's base URL followed by the stored `.path` (no signing, valid until the file is deleted). The stored object has **no** `url` field, so build the URL from `.path`:
116
+
117
+ ```xs
118
+ storage.create_attachment {
119
+ value = $input.my_file
120
+ access = "public"
121
+ filename = $input.my_file.name
122
+ } as $stored_file
123
+ ```
124
+
125
+ Then return the path and let the client prepend its base URL, or build the absolute URL server-side (set `PUBLIC_BASE_URL` to your instance origin, e.g. `https://your-instance.xano.io`, in workspace env vars):
126
+
127
+ ```xs
128
+ response = {
129
+ path : $stored_file.path
130
+ public_url: ($env.PUBLIC_BASE_URL ~ $stored_file.path)
131
+ }
132
+ ```
133
+
134
+ Use `public` only for non-sensitive assets (anyone with the URL can access it). Use `private` + `sign_private_url` for anything access-controlled.
135
+
136
+ ### Serving a generated file (not an upload)
137
+
138
+ To serve a file you build in the stack (CSV/JSON/zip export, etc.), create it with `storage.create_file_resource`, then **store** it with `storage.create_attachment` to get a vault `.path`. The `create_file_resource` result is an internal file-resource token — it has **no** servable URL/path of its own.
139
+
140
+ ```xs
141
+ storage.create_file_resource {
142
+ filename = "export.csv"
143
+ filedata = $csv_content
144
+ } as $resource
145
+ storage.create_attachment {
146
+ value = $resource
147
+ access = "public"
148
+ filename = "export.csv"
149
+ } as $stored_file
150
+ ```
151
+
152
+ Then serve `$stored_file` like any uploaded file: instance URL + `.path` for `public`, or `storage.sign_private_url` for `private`. See `integrations/utilities` for `create_file_resource` and zip/CSV details.
153
+
154
+ ## Complete Single-Upload Pattern
155
+
156
+ This is the full, end-to-end flow validated against a live Xano workspace (`file?` input → `storage.create_attachment` → `db.add` → `storage.sign_private_url`):
157
+
158
+ ```xs
159
+ query upload verb=POST {
160
+ api_group = "FileUploadDemo"
161
+ input {
162
+ text? name? filters=trim
163
+ // MUST be `file?` — only `file` populates `.path` on a multipart upload.
164
+ file? document
165
+ }
166
+ stack {
167
+ precondition ($input.document != null) {
168
+ error_type = "inputerror"
169
+ error = "Provide a file in the `document` field."
170
+ }
171
+
172
+ // create_attachment accepts any file type (PDF, HEIC, etc.).
173
+ storage.create_attachment {
174
+ value = $input.document
175
+ access = "private"
176
+ filename = $input.document.name
177
+ } as $stored_file
178
+
179
+ db.add upload_demo_file {
180
+ data = {
181
+ created_at: "now"
182
+ name : $input.name
183
+ file : $stored_file
184
+ }
185
+ } as $rec
186
+
187
+ storage.sign_private_url {
188
+ pathname = $rec.file.path
189
+ ttl = 3600
190
+ } as $signed_url
191
+ }
192
+ response = {
193
+ id : $rec.id
194
+ name : $rec.name
195
+ path : $rec.file.path
196
+ size : $rec.file.size
197
+ signed_url: $signed_url
198
+ }
199
+ }
200
+ ```
201
+
202
+ ## Complete Multiple-Upload Pattern
203
+
204
+ Declare the input `file[]?` and loop with `foreach`/`each as`. **The multipart field name must be sent with a `[]` suffix** (e.g. `photos[]`) for Xano to collect repeated parts into the array — see the frontend note below.
205
+
206
+ ```xs
207
+ query upload_many verb=POST {
208
+ api_group = "FileUploadDemo"
209
+ input {
210
+ text item_id
211
+ file[]? photos?
212
+ }
213
+ stack {
214
+ var $created { value = [] }
215
+ conditional {
216
+ if ($input.photos != null && ($input.photos|count) > 0) {
217
+ foreach ($input.photos) {
218
+ each as $file {
219
+ storage.create_attachment {
220
+ value = $file
221
+ access = "private"
222
+ filename = $file.name
223
+ } as $stored_file
224
+ db.add item_photo {
225
+ data = {
226
+ item_id: $input.item_id
227
+ file : $stored_file
228
+ }
229
+ } as $new_photo
230
+ var.update $created {
231
+ value = $created|push:{ id: $new_photo.id, path: $new_photo.file.path }
232
+ }
233
+ }
234
+ }
235
+ }
236
+ }
237
+ }
238
+ response = {
239
+ count : $created|count
240
+ created: $created
241
+ }
242
+ }
243
+ ```
244
+
245
+ ## Table Schema for Stored Files
246
+
247
+ Store the file metadata object in an `attachment?` (or `image?`) column. Despite the names, both column types store the identical JSON structure (`access`, `path`, `name`, `type`, `size`, `mime`, `meta`), and both accept the result of `storage.create_attachment` **and** `storage.create_image` — there is no type mismatch at the data layer (verified live: an `image?` column accepts a `create_attachment` result and vice-versa).
248
+
249
+ ```xs
250
+ table upload_demo_file {
251
+ auth = false
252
+ schema {
253
+ int id
254
+ timestamp created_at?=now
255
+ text? name? filters=trim
256
+ // File metadata from storage.create_attachment / storage.create_image.
257
+ attachment? file?
258
+ }
259
+ index = [
260
+ {type: "primary", field: [{name: "id"}]}
261
+ ]
262
+ }
263
+ ```
264
+
265
+ Use `attachment?` for general files and `image?` for image-only columns if you want the schema to be semantically accurate. Functionally, both work for either storage op.
266
+
267
+ ## Deleting & Replacing Files
268
+
269
+ Delete a stored file from the vault by its `.path` (verified live — the signed URL returns 404 afterwards):
270
+
271
+ ```xs
272
+ storage.delete_file { pathname = $stored_file.path }
273
+ ```
274
+
275
+ To **replace** a file on a record: store the new upload, `db.edit`/`db.patch` the column with the new stored object, then `storage.delete_file` the old `.path`. Clearing the column (e.g. `db.patch` setting `file` to `null`) removes the reference but does not delete the vault file — call `delete_file` for that. (`storage.delete_file` lives in the `integrations/utilities` topic alongside `create_file_resource` and `read_file_resource`.)
276
+
277
+ ## Frontend Pattern (JavaScript)
278
+
279
+ Always send files via `FormData`. **Never** set `Content-Type` manually — the browser sets `multipart/form-data` with the required boundary automatically.
280
+
281
+ ```javascript
282
+ // Single file
283
+ async function uploadFile(file, name) {
284
+ const formData = new FormData();
285
+ formData.append('document', file); // field name must match the XanoScript input name
286
+ formData.append('name', name); // text fields go in the same FormData
287
+ const response = await fetch(`${BASE_URL}/upload`, {
288
+ method: 'POST',
289
+ headers: { Authorization: `Bearer ${token}` }, // NO Content-Type header
290
+ body: formData
291
+ });
292
+ if (!response.ok) throw new Error((await response.json()).message);
293
+ return response.json();
294
+ }
295
+
296
+ // Multiple files — append with a `[]` suffix so a `file[]?` input receives ALL files.
297
+ // Appending repeatedly as 'photos' (no brackets) makes Xano keep only the LAST file.
298
+ async function uploadFiles(files, itemId) {
299
+ const formData = new FormData();
300
+ files.forEach(file => formData.append('photos[]', file)); // note the [] suffix
301
+ formData.append('item_id', itemId);
302
+ const response = await fetch(`${BASE_URL}/upload_many`, {
303
+ method: 'POST',
304
+ headers: { Authorization: `Bearer ${token}` },
305
+ body: formData
306
+ });
307
+ return response.json();
308
+ }
309
+ ```
310
+
311
+ ```html
312
+ <!-- Any file (documents, images, PDFs) -->
313
+ <input type="file" id="document" accept="image/*,application/pdf">
314
+ <!-- Multiple -->
315
+ <input type="file" id="photos" accept="image/*" multiple>
316
+ ```
317
+
318
+ ## JSON Endpoints vs Multipart Endpoints
319
+
320
+ - An endpoint with **no** file inputs receives a JSON body (`Content-Type: application/json`).
321
+ - An endpoint with **any** file input must be sent as `FormData` (multipart). If you need both a file and text fields in one request, put everything in `FormData` — text fields become form fields, files become file parts. Do not mix a JSON body with a file part.
322
+ - An endpoint's mode is determined by whether it currently has any file inputs. **Adding a file input to an existing JSON-only endpoint and pushing it via the CLI works** — the endpoint switches to multipart automatically on the next request (verified live; you do **not** need to create a separate endpoint).
323
+
324
+ ## Common Mistakes
325
+
326
+ ❌ **`image?` input — `Missing param: path` at runtime (validator does NOT catch this):**
327
+ ```xs
328
+ input { image? photo }
329
+ stack {
330
+ storage.create_image {
331
+ value = $input.photo
332
+ access = "private"
333
+ filename = $input.photo.name
334
+ } as $f
335
+ }
336
+ ```
337
+ The snippet above is fully valid syntax — `xano_validate_xanoscript` passes it — but it fails at runtime because `image?` never populates `$input.photo.path`.
338
+
339
+ ✅ **`file?` input populates `.path`:**
340
+ ```xs
341
+ input { file? photo }
342
+ stack {
343
+ storage.create_attachment {
344
+ value = $input.photo
345
+ access = "private"
346
+ filename = $input.photo.name
347
+ } as $f
348
+ }
349
+ ```
350
+
351
+ ❌ **Touching `.tmp_name` / hand-setting `.path` (hallucinated input properties — AI anti-pattern).** This does **not** help: with an `image?` input the `Missing param: path` error fires at the input layer before the stack runs, so the `|set` never executes (verified live).
352
+ ```xs
353
+ input { image? photo }
354
+ stack {
355
+ var $patched {
356
+ value = $input.photo|set:"path":$input.photo.tmp_name
357
+ }
358
+ storage.create_attachment {
359
+ value = $patched
360
+ access = "private"
361
+ filename = $patched.name
362
+ } as $f
363
+ }
364
+ ```
365
+
366
+ ✅ **Just use `file?`** — Xano sets `.path` for you before the stack runs.
367
+
368
+ ❌ **`storage.create_image` for a PDF — `Invalid file extension.` (HTTP 500):**
369
+ ```xs
370
+ storage.create_image {
371
+ value = $input.document
372
+ access = "private"
373
+ filename = $input.document.name
374
+ } as $f
375
+ ```
376
+
377
+ ✅ **`storage.create_attachment` accepts any type:**
378
+ ```xs
379
+ storage.create_attachment {
380
+ value = $input.document
381
+ access = "private"
382
+ filename = $input.document.name
383
+ } as $f
384
+ ```
385
+
386
+ ❌ **Omitting `access` or `filename`** — `storage.create_attachment { value = $input.photo } as $f` fails validation with `Missing required argument 'access'`. Always pass all three.
387
+
388
+ ❌ **Comma-separated or commented op args** — `storage.create_attachment { value = ..., filename = ... }` and a comment inside the `{ }` are both parse errors. One argument per line, comments on their own line outside the block.
389
+
390
+ ## Error Reference
391
+
392
+ | Error | Status | Cause | Fix |
393
+ |-------|--------|-------|-----|
394
+ | `Missing param: path` (`ERROR_CODE_INPUT_ERROR`, `payload.param` ends in `.path`) | 400 | Input declared `image?`/`video?`/`audio?`/`attachment?` — Xano doesn't set `.path` on the raw upload object | Change input type to `file?` |
395
+ | `Invalid file extension.` (`ERROR_FATAL`) | 500 | `storage.create_image` with a non-image (PDF, HEIC, …) | Use `storage.create_attachment` |
396
+ | `Missing required argument 'access'` (validation, at push time) | — | A `storage.create_*` call omitted `access` (or `filename`) | Pass `value`, `access`, and `filename` |
397
+ | HTTP 403 when fetching a file's `.path` | 403 | The file is `private`; raw paths aren't public | Generate `storage.sign_private_url`, or store the file as `public` |
398
+ | Multiple upload stored only one file | — | Multipart field appended without the `[]` suffix | Append files as `field[]` (e.g. `photos[]`) |
399
+
400
+ ## Related Topics
401
+
402
+ | Topic | Use For |
403
+ |-------|---------|
404
+ | `integrations/utilities` | Other `storage.*` ops: `create_file_resource`, `read_file_resource`, `delete_file` |
405
+ | `integrations/cloud-storage` | Uploading to external buckets (AWS S3, Azure, GCP) instead of Xano's vault |
406
+ | `types` | Input block syntax and the full file-type list |
407
+ | `database` | `db.add` and storing the file metadata record |
408
+ | `streaming` | Streaming large files in requests/responses |
@@ -23,42 +23,70 @@ applyTo: "function/**/*.xs, api/**/*.xs, task/*.xs"
23
23
 
24
24
  ### File Operations
25
25
 
26
+ > **⚠️ XanoScript comments use `//`, never `#`.** A `#` inside a `.xs` file is a parse error. Also: comments are not allowed inside an operation's `{ ... }` argument block — keep them on their own line above the op.
27
+
26
28
  ```xs
27
- # Create file resource
29
+ // create_file_resource turns in-stack data (CSV/JSON/zip output) into a FILE
30
+ // RESOURCE — the same value type a `file?` input produces. It is NOT a stored
31
+ // vault file and has no servable URL/path of its own; to persist or serve it,
32
+ // pass it to storage.create_attachment (see "Storing a generated file" below).
28
33
  storage.create_file_resource {
29
34
  filename = "report.csv"
30
35
  filedata = $csv_content
31
- } as $file
36
+ } as $resource
32
37
 
33
- # Read file resource
38
+ // read_file_resource returns the contents of a file resource (e.g. to parse it).
34
39
  storage.read_file_resource {
35
- value = $input.file
40
+ value = $input.upload
36
41
  } as $content
37
42
 
38
- # Delete file
39
- storage.delete_file { pathname = "temp/old-file.txt" }
43
+ // Delete a stored vault file by its `.path` (the value saved on the DB record).
44
+ storage.delete_file { pathname = $stored_file.path }
45
+ ```
46
+
47
+ #### Storing a generated file (so it has a URL)
48
+
49
+ A `create_file_resource` value cannot be served directly. Store it via `storage.create_attachment` (or `create_image`), then serve it like any uploaded file — `sign_private_url` for private, or instance URL + `.path` for public:
50
+
51
+ ```xs
52
+ storage.create_file_resource {
53
+ filename = "export.csv"
54
+ filedata = $csv_content
55
+ } as $resource
56
+ storage.create_attachment {
57
+ value = $resource
58
+ access = "public"
59
+ filename = "export.csv"
60
+ } as $stored_file
40
61
  ```
41
62
 
63
+ Then return `($env.PUBLIC_BASE_URL ~ $stored_file.path)` for public, or `storage.sign_private_url` for private. See `xano_xanoscript_docs({ topic: "file-uploads" })`.
64
+
42
65
  ### Image/Attachment Handling
43
66
 
67
+ > **⚠️ Upload inputs must be typed `file?`, not `image?`/`attachment?`.** Only `file` populates `.path` on a multipart upload; the others pass the raw object and `storage.*` fails with `Missing param: path`. Use `storage.create_attachment` (any file type) over `storage.create_image` (image extensions only). Full pattern: `xano_xanoscript_docs({ topic: "file-uploads" })`.
68
+
44
69
  ```xs
45
- # Create image metadata
70
+ // The upload input is declared `file?` so Xano populates `.path` first.
71
+ // input { file? upload }
72
+
73
+ // Create image metadata (images only: JPEG/PNG/GIF/WEBP)
46
74
  storage.create_image {
47
- value = $input.image
75
+ value = $input.upload
48
76
  access = "public"
49
- filename = "profile.jpg"
77
+ filename = $input.upload.name
50
78
  } as $image_meta
51
79
 
52
- # Create attachment metadata
80
+ // Create attachment metadata (any file type — recommended default)
53
81
  storage.create_attachment {
54
- value = $input.file
82
+ value = $input.upload
55
83
  access = "private"
56
- filename = "document.pdf"
84
+ filename = $input.upload.name
57
85
  } as $attachment_meta
58
86
 
59
- # Sign private URL
87
+ // Sign private URL (use the stored .path, never a hand-built path)
60
88
  storage.sign_private_url {
61
- pathname = "private/document.pdf"
89
+ pathname = $attachment_meta.path
62
90
  ttl = 300
63
91
  } as $signed_url
64
92
  ```
@@ -70,12 +98,12 @@ storage.sign_private_url {
70
98
  ### Password Hashing
71
99
 
72
100
  ```xs
73
- # Password is auto-hashed on insert
101
+ // Password is auto-hashed on insert
74
102
  db.add "user" {
75
103
  data = { email: $input.email, password: $input.password }
76
104
  }
77
105
 
78
- # Verify password
106
+ // Verify password
79
107
  security.check_password {
80
108
  text_password = $input.password
81
109
  hash_password = $user.password
@@ -85,7 +113,7 @@ security.check_password {
85
113
  ### Encryption
86
114
 
87
115
  ```xs
88
- # Encrypt
116
+ // Encrypt
89
117
  security.encrypt {
90
118
  data = $sensitive_data
91
119
  algorithm = "aes-256-cbc"
@@ -93,7 +121,7 @@ security.encrypt {
93
121
  iv = $env.ENCRYPTION_IV
94
122
  } as $encrypted
95
123
 
96
- # Decrypt
124
+ // Decrypt
97
125
  security.decrypt {
98
126
  data = $encrypted
99
127
  algorithm = "aes-256-cbc"
@@ -105,7 +133,7 @@ security.decrypt {
105
133
  ### JWT (JWS/JWE)
106
134
 
107
135
  ```xs
108
- # Sign JWT
136
+ // Sign JWT
109
137
  security.jws_encode {
110
138
  claims = { user_id: $user.id, role: $user.role }
111
139
  key = $env.JWT_SECRET
@@ -113,7 +141,7 @@ security.jws_encode {
113
141
  ttl = 3600
114
142
  } as $token
115
143
 
116
- # Verify JWT
144
+ // Verify JWT
117
145
  security.jws_decode {
118
146
  token = $input.token
119
147
  key = $env.JWT_SECRET
@@ -264,9 +292,21 @@ query "export_data" {
264
292
  storage.create_file_resource {
265
293
  filename = "export.zip"
266
294
  filedata = $archive
295
+ } as $resource
296
+
297
+ // create_file_resource is not directly servable — store it to get a vault path.
298
+ storage.create_attachment {
299
+ value = $resource
300
+ access = "private"
301
+ filename = "export.zip"
267
302
  } as $download
303
+
304
+ storage.sign_private_url {
305
+ pathname = $download.path
306
+ ttl = 600
307
+ } as $download_url
268
308
  }
269
- response = { download_url: $download.url }
309
+ response = { download_url: $download_url }
270
310
  }
271
311
  ```
272
312
 
@@ -82,6 +82,8 @@ input {
82
82
 
83
83
  ## Tool-Specific Statements
84
84
 
85
+ > **Where these belong:** `api.call`, `task.call`, and `tool.call` are for **tools**. Use them to compose a tool from other Xano constructs. Don't reach for them in API endpoints, functions, or tasks. (To call a function from a regular stack, use `function.run`.)
86
+
85
87
  ### api.call
86
88
  Call an API endpoint:
87
89
 
@@ -204,14 +204,25 @@ object[] items {
204
204
  ```
205
205
 
206
206
  ### File Types
207
+
208
+ > **⚠️ For uploaded files, always use `file`.** Only `file` pre-processes a multipart upload and populates `.path`; `image`/`attachment`/`video`/`audio` pass the raw upload object, so any `storage.*` op fails with `Missing param: path`. The names look like semantic choices but are technical. See `xano_xanoscript_docs({ topic: "file-uploads" })`.
209
+
207
210
  ```xs
211
+ // ✅ use `file` for ALL uploads — only `file` populates .path
212
+ file generic_file
213
+ // optional upload
214
+ file? document
215
+ // multiple uploads
216
+ file[]? attachments
217
+
218
+ // image/attachment/video/audio exist but DO NOT populate .path on upload —
219
+ // they are mainly useful as table column types for stored file metadata.
208
220
  image photo {
209
221
  description = "Profile photo"
210
222
  }
211
223
  attachment document
212
224
  video recording
213
225
  audio clip
214
- file generic_file
215
226
  ```
216
227
 
217
228
  ### Geographic Types
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "2.1.1",
2
+ "version": "2.3.0",
3
3
  "updated": "2026-06-01"
4
4
  }
@@ -28,6 +28,8 @@ workflow_test "<name>" {
28
28
 
29
29
  Call functions invoke Xano constructs and capture their results. Each returns a result that can be stored with `as $variable`.
30
30
 
31
+ > **Where these belong:** Call functions are for **workflow tests**. Don't reach for them in API endpoints, functions, or tasks. (To call a function from a regular stack, use `function.run` — see the [`function.call`](#functioncall) note below.)
32
+
31
33
  | Call Function | Description | Required Properties |
32
34
  | ----------------- | ------------------------------ | ------------------------------------ |
33
35
  | `api.call` | Call an API endpoint | `api_group`, `verb` (on call), optional `headers` |
@@ -656,7 +656,7 @@ var $msg { value = ($status|to_text) ~ ": " ~ ($data|json_encode) }
656
656
  | `agents` | AI agent configuration | ~9KB |
657
657
  | `tools` | AI tools for agents | ~7KB |
658
658
  | `mcp-servers` | MCP server definitions | ~4KB |
659
- | `security` | Auth patterns, encryption | ~12KB |
659
+ | `security` | Auth patterns, encryption | ~8KB |
660
660
  | `integrations` | External APIs, cloud storage, Redis | ~varies |
661
661
  | `unit-testing` | Unit tests, mocks, assertions | ~10KB |
662
662
  | `workflow-tests` | E2E workflow tests | ~11KB |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xano/developer-mcp",
3
- "version": "2.0.5",
3
+ "version": "2.2.0",
4
4
  "description": "MCP server and library for Xano development - XanoScript validation, Meta API, Run API, and CLI documentation",
5
5
  "type": "module",
6
6
  "main": "dist/lib.js",