@xano/developer-mcp 1.0.38 → 1.0.40

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.
@@ -153,6 +153,7 @@ $text|to_upper // Uppercase
153
153
  $text|substr:0:10 // Substring
154
154
  $text|split:"," // Split to array
155
155
  $text|contains:"x" // Check contains → bool
156
+ $text|strlen // Length of a string
156
157
 
157
158
  // Array
158
159
  $arr|first // First element
@@ -88,6 +88,40 @@ conditional {
88
88
  }
89
89
  ```
90
90
 
91
+ ### Early Return
92
+
93
+ Stop execution and return a value immediately. Useful for guard clauses and skipping unnecessary work.
94
+
95
+ ```xs
96
+ // Guard clause - return early if condition is met
97
+ conditional {
98
+ if ($input.skip) {
99
+ return { value = null }
100
+ }
101
+ }
102
+
103
+ // Return early with a value
104
+ conditional {
105
+ if ($input.use_cache && $cached_result != null) {
106
+ return { value = $cached_result }
107
+ }
108
+ }
109
+
110
+ // Short-circuit with a successful response
111
+ db.get "order" {
112
+ field_name = "id"
113
+ field_value = $input.order_id
114
+ } as $order
115
+
116
+ conditional {
117
+ if ($order.status == "completed") {
118
+ return { value = $order }
119
+ }
120
+ }
121
+
122
+ // Continue with expensive processing for non-completed orders...
123
+ ```
124
+
91
125
  ### API Request with Error Handling
92
126
  ```xs
93
127
  api.request {
@@ -27,24 +27,40 @@ Complete reference for XanoScript expressions, operators, and filters.
27
27
  | [Error Handling](#error-handling) | `precondition`, `try_catch`, `throw` |
28
28
  | [System Variables](#system-variables) | `$env.*`, `$auth.*`, request context |
29
29
 
30
+ ## CRITICAL: Filters Are Type-Specific
31
+
32
+ > **Filters only work on the correct input type.** String filters and array filters are NOT interchangeable. Using the wrong filter type will produce errors or incorrect results.
33
+
34
+ | Task | WRONG (type mismatch) | CORRECT |
35
+ |------|----------------------|---------|
36
+ | Get string length | `$text\|count` | `$text\|strlen` |
37
+ | Get array length | `$arr\|strlen` | `$arr\|count` |
38
+ | Reverse a string | `$text\|reverse` | `$text\|split:""\|reverse\|join:""` |
39
+ | Reverse an array | Use `reverse` directly | `$arr\|reverse` |
40
+ | Check string has substring | `$text\|some:...` | `$text\|contains:"sub"` |
41
+ | Check array has element | `$arr\|contains:$val` (db only) | `$arr\|some:$$==$val` |
42
+ | Get part of string | `$text\|slice:0:3` | `$text\|substr:0:3` |
43
+ | Get part of array | `$arr\|substr:0:3` | `$arr\|slice:0:3` |
44
+
30
45
  ## Choosing a Filter
31
46
 
32
47
  ```
33
48
  Working with...
34
- ├── Strings?
49
+ ├── Strings? → USE STRING FILTERS ONLY (see String Filters section)
35
50
  │ ├── Clean whitespace? → trim, ltrim, rtrim
36
51
  │ ├── Change case? → to_lower, to_upper, capitalize
37
- │ ├── Extract part? → substr
52
+ │ ├── Extract part? → substr (NOT slice)
38
53
  │ ├── Split to array? → split
39
54
  │ ├── Find/replace? → replace, contains
40
- │ └── Get length? → strlen
41
- ├── Arrays?
55
+ │ └── Get length? → strlen (NOT count)
56
+ ├── Arrays? → USE ARRAY FILTERS ONLY (see Array Filters section)
42
57
  │ ├── Get element? → first, last, get
43
- │ ├── Count items? → count
58
+ │ ├── Count items? → count (NOT strlen)
44
59
  │ ├── Transform all? → map
45
60
  │ ├── Keep some? → filter
46
61
  │ ├── Find one? → find
47
62
  │ ├── Combine? → reduce
63
+ │ ├── Reverse? → reverse (NOT available on strings)
48
64
  │ └── Sort? → sort
49
65
  ├── Objects?
50
66
  │ ├── Get value? → get
@@ -74,16 +90,20 @@ Working with...
74
90
  | Null-safe | `==?`, `!=?`, `>=?`, `<=?` (ignore if null) |
75
91
 
76
92
  ### Common Filters
77
- | Filter | Purpose | Example |
78
- |--------|---------|---------|
79
- | `trim` | Remove whitespace | `$s\|trim` |
80
- | `to_lower` / `to_upper` | Case conversion | `$s\|to_lower` |
81
- | `first` / `last` | Array endpoints | `$arr\|first` |
82
- | `count` | Array/object length | `$arr\|count` |
83
- | `get` | Object property | `$obj\|get:"key"` |
84
- | `set` | Set property | `$obj\|set:"key":"val"` |
85
- | `json_encode` / `json_decode` | JSON conversion | `$obj\|json_encode` |
86
- | `to_text` / `to_int` | Type conversion | `$num\|to_text` |
93
+ | Filter | Type | Purpose | Example |
94
+ |--------|------|---------|---------|
95
+ | `trim` | STRING | Remove whitespace | `$s\|trim` |
96
+ | `to_lower` / `to_upper` | STRING | Case conversion | `$s\|to_lower` |
97
+ | `strlen` | STRING | String length | `$s\|strlen` |
98
+ | `substr` | STRING | Extract substring | `$s\|substr:0:5` |
99
+ | `first` / `last` | ARRAY | Array endpoints | `$arr\|first` |
100
+ | `count` | ARRAY | Array length | `$arr\|count` |
101
+ | `slice` | ARRAY | Extract sub-array | `$arr\|slice:0:3` |
102
+ | `reverse` | ARRAY | Reverse array | `$arr\|reverse` |
103
+ | `get` | OBJECT | Object property | `$obj\|get:"key"` |
104
+ | `set` | OBJECT | Set property | `$obj\|set:"key":"val"` |
105
+ | `json_encode` / `json_decode` | ANY | JSON conversion | `$obj\|json_encode` |
106
+ | `to_text` / `to_int` | ANY | Type conversion | `$num\|to_text` |
87
107
 
88
108
  > **Note:** There is no `default` filter. Use conditional blocks or `first_notnull`/`first_notempty` instead.
89
109
 
@@ -213,6 +233,8 @@ $db.post.date >=? $input.start_date
213
233
 
214
234
  ## String Filters
215
235
 
236
+ > **These filters operate on STRING values only.** Do not use array filters (`count`, `reverse`, `first`, `last`, `slice`) on strings. Use `strlen` for string length, `substr` for substrings.
237
+
216
238
  | Filter | Example | Result |
217
239
  |--------|---------|--------|
218
240
  | `trim` | `" hi "\|trim` | `"hi"` |
@@ -244,6 +266,8 @@ $db.post.date >=? $input.start_date
244
266
 
245
267
  ## Array Filters
246
268
 
269
+ > **These filters operate on ARRAY values only.** Do not use string filters (`strlen`, `substr`, `split`, `replace`) on arrays. Use `count` for array length, `slice` for sub-arrays, `join` to convert to string.
270
+
247
271
  | Filter | Example | Result |
248
272
  |--------|---------|--------|
249
273
  | `first` | `[1,2,3]\|first` | `1` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xano/developer-mcp",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
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",