@xano/developer-mcp 1.0.75 → 2.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 (127) hide show
  1. package/README.md +104 -37
  2. package/dist/cli_docs/index.d.ts +13 -37
  3. package/dist/cli_docs/index.js +28 -39
  4. package/dist/cli_docs/topics/integration.js +1 -1
  5. package/dist/cli_docs/topics/workspace.js +1 -1
  6. package/dist/index.js +58 -55
  7. package/dist/lib.d.ts +3 -1
  8. package/dist/lib.js +1 -1
  9. package/dist/meta_api_docs/format.js +1 -1
  10. package/dist/meta_api_docs/index.d.ts +14 -42
  11. package/dist/meta_api_docs/index.js +34 -46
  12. package/dist/tools/cli_docs.d.ts +2 -3
  13. package/dist/tools/cli_docs.js +3 -5
  14. package/dist/tools/define_tool.d.ts +47 -0
  15. package/dist/tools/define_tool.js +36 -0
  16. package/dist/tools/index.d.ts +88 -221
  17. package/dist/tools/index.js +80 -109
  18. package/dist/tools/mcp_version.d.ts +4 -25
  19. package/dist/tools/mcp_version.js +12 -19
  20. package/dist/tools/meta_api_docs.d.ts +2 -3
  21. package/dist/tools/meta_api_docs.js +3 -5
  22. package/dist/tools/validate_xanoscript.d.ts +18 -65
  23. package/dist/tools/validate_xanoscript.js +56 -54
  24. package/dist/tools/xanoscript_docs.d.ts +25 -74
  25. package/dist/tools/xanoscript_docs.js +86 -83
  26. package/dist/xanoscript_docs/README.md +5 -5
  27. package/dist/xanoscript_docs/apis.md +2 -2
  28. package/dist/xanoscript_docs/database.md +1 -1
  29. package/dist/xanoscript_docs/essentials.md +6 -6
  30. package/dist/xanoscript_docs/functions.md +3 -3
  31. package/dist/xanoscript_docs/integrations.md +5 -5
  32. package/dist/xanoscript_docs/middleware.md +1 -1
  33. package/dist/xanoscript_docs/performance.md +4 -4
  34. package/dist/xanoscript_docs/realtime.md +2 -2
  35. package/dist/xanoscript_docs/security.md +1 -1
  36. package/dist/xanoscript_docs/survival.md +1 -1
  37. package/dist/xanoscript_docs/syntax/string-filters.md +1 -1
  38. package/dist/xanoscript_docs/syntax.md +9 -9
  39. package/dist/xanoscript_docs/tools.md +2 -2
  40. package/dist/xanoscript_docs/types.md +2 -2
  41. package/dist/xanoscript_docs/unit-testing.md +1 -1
  42. package/dist/xanoscript_docs/workflow-tests.md +1 -1
  43. package/dist/xanoscript_docs/working.md +4 -4
  44. package/package.json +5 -4
  45. package/dist/api_docs/format.d.ts +0 -5
  46. package/dist/api_docs/format.js +0 -171
  47. package/dist/api_docs/index.d.ts +0 -52
  48. package/dist/api_docs/index.js +0 -111
  49. package/dist/api_docs/topics/agent.d.ts +0 -2
  50. package/dist/api_docs/topics/agent.js +0 -142
  51. package/dist/api_docs/topics/api.d.ts +0 -2
  52. package/dist/api_docs/topics/api.js +0 -176
  53. package/dist/api_docs/topics/apigroup.d.ts +0 -2
  54. package/dist/api_docs/topics/apigroup.js +0 -124
  55. package/dist/api_docs/topics/authentication.d.ts +0 -2
  56. package/dist/api_docs/topics/authentication.js +0 -61
  57. package/dist/api_docs/topics/branch.d.ts +0 -2
  58. package/dist/api_docs/topics/branch.js +0 -73
  59. package/dist/api_docs/topics/file.d.ts +0 -2
  60. package/dist/api_docs/topics/file.js +0 -70
  61. package/dist/api_docs/topics/function.d.ts +0 -2
  62. package/dist/api_docs/topics/function.js +0 -164
  63. package/dist/api_docs/topics/history.d.ts +0 -2
  64. package/dist/api_docs/topics/history.js +0 -149
  65. package/dist/api_docs/topics/mcp_server.d.ts +0 -2
  66. package/dist/api_docs/topics/mcp_server.js +0 -139
  67. package/dist/api_docs/topics/middleware.d.ts +0 -2
  68. package/dist/api_docs/topics/middleware.js +0 -156
  69. package/dist/api_docs/topics/realtime.d.ts +0 -2
  70. package/dist/api_docs/topics/realtime.js +0 -112
  71. package/dist/api_docs/topics/start.d.ts +0 -2
  72. package/dist/api_docs/topics/start.js +0 -107
  73. package/dist/api_docs/topics/table.d.ts +0 -2
  74. package/dist/api_docs/topics/table.js +0 -195
  75. package/dist/api_docs/topics/task.d.ts +0 -2
  76. package/dist/api_docs/topics/task.js +0 -165
  77. package/dist/api_docs/topics/tool.d.ts +0 -2
  78. package/dist/api_docs/topics/tool.js +0 -150
  79. package/dist/api_docs/topics/workflows.d.ts +0 -2
  80. package/dist/api_docs/topics/workflows.js +0 -131
  81. package/dist/api_docs/topics/workspace.d.ts +0 -2
  82. package/dist/api_docs/topics/workspace.js +0 -153
  83. package/dist/api_docs/types.d.ts +0 -79
  84. package/dist/api_docs/types.js +0 -4
  85. package/dist/cli_docs/topics/run.d.ts +0 -2
  86. package/dist/cli_docs/topics/run.js +0 -248
  87. package/dist/meta_api_docs/format.test.d.ts +0 -1
  88. package/dist/meta_api_docs/format.test.js +0 -272
  89. package/dist/meta_api_docs/index.test.d.ts +0 -1
  90. package/dist/meta_api_docs/index.test.js +0 -128
  91. package/dist/meta_api_docs/types.test.d.ts +0 -1
  92. package/dist/meta_api_docs/types.test.js +0 -132
  93. package/dist/templates/init-workspace.d.ts +0 -10
  94. package/dist/templates/init-workspace.js +0 -278
  95. package/dist/templates/xanoscript-index.d.ts +0 -11
  96. package/dist/templates/xanoscript-index.js +0 -72
  97. package/dist/tools/index.test.d.ts +0 -1
  98. package/dist/tools/index.test.js +0 -179
  99. package/dist/tools/xanoscript_docs.test.d.ts +0 -1
  100. package/dist/tools/xanoscript_docs.test.js +0 -197
  101. package/dist/xanoscript.test.d.ts +0 -1
  102. package/dist/xanoscript.test.js +0 -421
  103. package/dist/xanoscript_docs/cheatsheet.md +0 -287
  104. package/dist/xanoscript_docs/ephemeral.md +0 -330
  105. package/dist/xanoscript_docs/quickstart.md +0 -692
  106. package/dist/xanoscript_docs/run.md +0 -196
  107. package/dist/xanoscript_docs/schema.md +0 -300
  108. package/dist/xanoscript_docs_auto/README.md +0 -119
  109. package/dist/xanoscript_docs_auto/agents.md +0 -446
  110. package/dist/xanoscript_docs_auto/apis.md +0 -517
  111. package/dist/xanoscript_docs_auto/control-flow.md +0 -543
  112. package/dist/xanoscript_docs_auto/database.md +0 -551
  113. package/dist/xanoscript_docs_auto/debugging.md +0 -527
  114. package/dist/xanoscript_docs_auto/filters.md +0 -464
  115. package/dist/xanoscript_docs_auto/functions.md +0 -431
  116. package/dist/xanoscript_docs_auto/integrations.md +0 -657
  117. package/dist/xanoscript_docs_auto/mcp-servers.md +0 -408
  118. package/dist/xanoscript_docs_auto/operators.md +0 -368
  119. package/dist/xanoscript_docs_auto/syntax.md +0 -287
  120. package/dist/xanoscript_docs_auto/tables.md +0 -447
  121. package/dist/xanoscript_docs_auto/tasks.md +0 -479
  122. package/dist/xanoscript_docs_auto/testing.md +0 -574
  123. package/dist/xanoscript_docs_auto/tools.md +0 -485
  124. package/dist/xanoscript_docs_auto/triggers.md +0 -595
  125. package/dist/xanoscript_docs_auto/types.md +0 -323
  126. package/dist/xanoscript_docs_auto/variables.md +0 -462
  127. package/dist/xanoscript_docs_auto/version.json +0 -5
@@ -1,287 +0,0 @@
1
- ---
2
- applyTo: "**/*.xs"
3
- ---
4
-
5
- # XanoScript Cheat Sheet
6
-
7
- > **Purpose:** Quick reference for the 20 most common XanoScript patterns. For detailed documentation, use `xanoscript_docs({ topic: "<topic>" })`.
8
-
9
- ## Quick Reference
10
-
11
- ### Variable Declaration
12
-
13
- ```xs
14
- var $name { value = "initial" }
15
- var $count { value = 0 }
16
- var $items { value = [] }
17
- var $data { value = { key: "value" } }
18
- ```
19
-
20
- ### Conditionals
21
-
22
- ```xs
23
- conditional {
24
- if ($input.age >= 18) {
25
- var $status { value = "adult" }
26
- }
27
- elseif ($input.age >= 13) {
28
- var $status { value = "teen" }
29
- }
30
- else {
31
- var $status { value = "child" }
32
- }
33
- }
34
- ```
35
-
36
- > **Note:** Use `elseif` (one word), not `else if`.
37
-
38
- ### Switch
39
-
40
- ```xs
41
- switch ($input.status) {
42
- case ("active") {
43
- var $message { value = "User is active" }
44
- } break
45
- case ("pending") {
46
- var $message { value = "User is pending" }
47
- } break
48
- default {
49
- var $message { value = "Unknown status" }
50
- }
51
- }
52
- ```
53
-
54
- > **Note:** `break` goes **after** the closing `}` of each `case` block. The `default` case does not need `break`.
55
-
56
- ### Loops
57
-
58
- ```xs
59
- // For each loop
60
- foreach ($input.items) {
61
- each as $item {
62
- debug.log { value = $item.name }
63
- }
64
- }
65
-
66
- // For loop (iterate N times)
67
- for (10) {
68
- each as $idx {
69
- debug.log { value = $idx }
70
- }
71
- }
72
-
73
- // While loop
74
- var $counter { value = 0 }
75
- while ($counter < 10) {
76
- each {
77
- var.update $counter { value = $counter + 1 }
78
- }
79
- }
80
-
81
- // Map/filter for transformations
82
- var $names { value = $items|map:$$.name }
83
- var $active { value = $items|filter:$$.is_active }
84
- ```
85
-
86
- ### Database CRUD
87
-
88
- ```xs
89
- // Get single record by field
90
- db.get "user" {
91
- field_name = "id"
92
- field_value = $input.user_id
93
- } as $user
94
-
95
- // Query with filters
96
- db.query "user" {
97
- where = $db.user.is_active == true
98
- sort = { created_at: "desc" }
99
- return = { type: "list", paging: { page: 1, per_page: 25 } }
100
- } as $users
101
-
102
- // Insert record
103
- db.add "user" {
104
- data = { name: $input.name, email: $input.email, created_at: now }
105
- } as $new_user
106
-
107
- // Update record
108
- db.edit "user" {
109
- field_name = "id"
110
- field_value = $input.user_id
111
- data = { name: $input.name, updated_at: now }
112
- }
113
-
114
- // Delete record
115
- db.del "user" {
116
- field_name = "id"
117
- field_value = $input.user_id
118
- }
119
- ```
120
-
121
- ### API Requests
122
-
123
- ```xs
124
- api.request {
125
- url = "https://api.example.com/endpoint"
126
- method = "POST"
127
- params = { key: "value" } // Note: "params" for body, NOT "body"
128
- headers = [
129
- "Content-Type: application/json",
130
- "Authorization: Bearer " ~ $env.API_KEY
131
- ]
132
- timeout = 30
133
- } as $api_result
134
-
135
- // Response structure:
136
- // $api_result.response.status → HTTP status code (200, 404, etc.)
137
- // $api_result.response.result → Parsed response body
138
- // $api_result.response.headers → Response headers
139
- ```
140
-
141
- ### Error Handling
142
-
143
- ```xs
144
- // Precondition (stops execution if false)
145
- precondition ($input.id > 0) {
146
- error_type = "inputerror"
147
- error = "ID must be positive"
148
- }
149
-
150
- // Try-catch
151
- try_catch {
152
- try {
153
- // risky operation
154
- }
155
- catch {
156
- debug.log { value = "Operation failed" }
157
- }
158
- }
159
-
160
- // Throw custom error
161
- throw {
162
- name = "ValidationError"
163
- value = "Custom error message"
164
- }
165
- ```
166
-
167
- ### Error Types
168
-
169
- | Type | HTTP Status | Use Case |
170
- |------|-------------|----------|
171
- | `inputerror` | 400 | Invalid input data |
172
- | `accessdenied` | 403 | Authorization failure |
173
- | `notfound` | 404 | Resource doesn't exist |
174
- | `standard` | 500 | General errors |
175
-
176
- ### Common Filters
177
-
178
- ```xs
179
- // String
180
- $text|trim // Remove whitespace
181
- $text|to_lower // Lowercase
182
- $text|to_upper // Uppercase
183
- $text|substr:0:10 // Substring
184
- $text|split:"," // Split to array
185
- $text|contains:"x" // Check contains → bool
186
- $text|strlen // Length of a string
187
-
188
- // Array
189
- $arr|first // First element
190
- $arr|last // Last element
191
- $arr|count // Length
192
- $arr|map:$$.field // Transform elements
193
- $arr|filter:$$.active // Filter by condition
194
- $arr|find:$$.id == 5 // Find first match
195
-
196
- // Type conversion
197
- $val|to_text // To string
198
- $val|to_int // To integer
199
- $val|to_bool // To boolean
200
- $val|json_encode // To JSON string
201
- $text|json_decode // From JSON string
202
-
203
- // Object
204
- $obj|get:"key" // Get property
205
- $obj|get:"key":"default" // Get with default
206
- $obj|set:"key":"value" // Set property
207
- $obj|has:"key" // Check key exists
208
-
209
- // Null handling
210
- $val|first_notnull:"default" // Default if null
211
- $val ?? "default" // Nullish coalescing
212
-
213
- // Math
214
- $num|round:2 // Round to 2 decimals
215
- $num|abs // Absolute value
216
- ```
217
-
218
- ### Authentication Check
219
-
220
- ```xs
221
- precondition ($auth.id != null) {
222
- error_type = "accessdenied"
223
- error = "Authentication required"
224
- }
225
- ```
226
-
227
- ### Function Call
228
-
229
- ```xs
230
- function.run "my_function" {
231
- input = { param1: "value" }
232
- } as $result
233
- ```
234
-
235
- ### String Concatenation
236
-
237
- ```xs
238
- // Basic
239
- var $msg { value = "Hello, " ~ $input.name ~ "!" }
240
-
241
- // With filters - MUST use parentheses
242
- var $msg { value = ($status|to_text) ~ ": " ~ ($data|json_encode) }
243
- ```
244
-
245
- ### Common Type Names
246
-
247
- | Use This | Not This |
248
- |----------|----------|
249
- | `text` | string |
250
- | `int` | integer |
251
- | `bool` | boolean |
252
- | `decimal` | float, number |
253
- | `type[]` | array, list |
254
-
255
- ### Reserved Variables (Cannot Use)
256
-
257
- `$response`, `$output`, `$input`, `$auth`, `$env`, `$db`, `$this`, `$result`, `$index`
258
-
259
- ### Input Block Syntax
260
-
261
- `?` after the **type** = nullable, `?` after the **variable name** = optional (not required).
262
-
263
- ```xs
264
- input {
265
- text name // Required, not nullable
266
- text? name // Required, nullable (can send null)
267
- text name? // Optional (can be omitted)
268
- text? name? // Optional and nullable
269
- text role?="user" // Optional with default
270
- email contact filters=trim // With filters
271
- text[] tags // Array type
272
- object address { // Nested object
273
- schema {
274
- text street
275
- text city
276
- }
277
- }
278
- }
279
- ```
280
-
281
- ---
282
-
283
- **Related:** For detailed documentation, use:
284
- - `xanoscript_docs({ topic: "quickstart" })` - Common patterns and mistakes
285
- - `xanoscript_docs({ topic: "syntax" })` - All filters and operators
286
- - `xanoscript_docs({ topic: "database" })` - All db.* operations
287
- - `xanoscript_docs({ topic: "types" })` - Type validation and schemas
@@ -1,330 +0,0 @@
1
- ---
2
- applyTo: "ephemeral/**/*.xs"
3
- ---
4
-
5
- # Ephemeral Environments
6
-
7
- Temporary Xano workspaces for testing and one-off operations.
8
-
9
- ## Quick Reference
10
-
11
- | Type | Purpose | Lifecycle |
12
- |------|---------|-----------|
13
- | **Service** | Temporary workspace with DB/APIs | Runs until shut down |
14
- | **Job** | One-time operation | Executes once, then shuts down |
15
-
16
- ### Directory Structure
17
- ```
18
- ephemeral/
19
- ├── my-service/
20
- │ ├── workspace.xs
21
- │ ├── tables/
22
- │ ├── functions/
23
- │ └── apis/
24
- └── my-job/
25
- ├── workspace.xs
26
- ├── tables/
27
- └── functions/
28
- ```
29
-
30
- ---
31
-
32
- ## Ephemeral Service
33
-
34
- A temporary workspace with database, functions, and API endpoints.
35
-
36
- ### workspace.xs
37
- ```xs
38
- workspace my_service {
39
- env = {
40
- api_key: "test-key"
41
- debug: "true"
42
- }
43
- }
44
- ```
45
-
46
- ### Table with Seed Data
47
- ```xs
48
- table event {
49
- auth = false
50
- schema {
51
- int id
52
- timestamp created_at?=now
53
- text name filters=trim
54
- }
55
- index = [
56
- {type: "primary", field: [{name: "id"}]}
57
- ]
58
- items = [
59
- {"id": 1, "name": "Event 1"}
60
- {"id": 2, "name": "Event 2"}
61
- ]
62
- }
63
- ```
64
-
65
- ### API Group
66
- ```xs
67
- api_group events {
68
- canonical = "events-api"
69
- }
70
- ```
71
-
72
- ### Endpoints
73
- ```xs
74
- query list verb=GET {
75
- api_group = "events"
76
- stack {
77
- db.query event {
78
- return = { type: "list" }
79
- } as $events
80
- }
81
- response = $events
82
- }
83
-
84
- query add verb=POST {
85
- api_group = "events"
86
- input { text name filters=trim }
87
- stack {
88
- db.add event {
89
- data = { name: $input.name }
90
- } as $event
91
- }
92
- response = $event
93
- }
94
- ```
95
-
96
- ---
97
-
98
- ## Ephemeral Job
99
-
100
- One-time operation with setup and cleanup hooks.
101
-
102
- ### Reserved Functions
103
- | Function | Purpose | Required |
104
- |----------|---------|----------|
105
- | `$main` | Primary logic | Yes |
106
- | `$pre` | Setup/validation | No |
107
- | `$post` | Cleanup/notification | No |
108
-
109
- ### Execution Order
110
- 1. `$pre` (if defined)
111
- 2. `$main`
112
- 3. `$post` (if defined)
113
- 4. Environment shuts down
114
-
115
- ### $main Function
116
- ```xs
117
- function "$main" {
118
- input {
119
- json args // Runtime arguments
120
- json pre // Result from $pre
121
- }
122
- stack {
123
- db.query authors {
124
- return = { type: "count" }
125
- } as $count
126
-
127
- precondition ($count > 0) {
128
- error = "No authors found"
129
- }
130
-
131
- db.add authors {
132
- data = { name: "New Author" }
133
- }
134
- }
135
- response = { processed: true }
136
- }
137
- ```
138
-
139
- ### $pre Function (optional)
140
- ```xs
141
- function "$pre" {
142
- input { json args }
143
- stack {
144
- // Validation or setup
145
- precondition ($input.args.required_field != null) {
146
- error = "Missing required field"
147
- }
148
- }
149
- response = { validated: true }
150
- }
151
- ```
152
-
153
- ### $post Function (optional)
154
- ```xs
155
- function "$post" {
156
- input {
157
- json args
158
- json pre
159
- json main
160
- }
161
- stack {
162
- // Send notification or cleanup
163
- api.request {
164
- url = $env.WEBHOOK_URL
165
- method = "POST"
166
- params = {
167
- status: "complete",
168
- result: $input.main
169
- }
170
- }
171
- }
172
- response = null
173
- }
174
- ```
175
-
176
- ---
177
-
178
- ## Complete Service Example
179
-
180
- ```
181
- ephemeral/event-tracker/
182
- ├── workspace.xs
183
- ├── tables/
184
- │ └── event.xs
185
- └── apis/
186
- ├── api_group.xs
187
- ├── list.xs
188
- ├── add.xs
189
- └── clear.xs
190
- ```
191
-
192
- ### workspace.xs
193
- ```xs
194
- workspace event_tracker {
195
- env = { api_key: "test" }
196
- }
197
- ```
198
-
199
- ### tables/event.xs
200
- ```xs
201
- table event {
202
- auth = false
203
- schema {
204
- int id
205
- timestamp created_at?=now
206
- text name
207
- }
208
- index = [
209
- {type: "primary", field: [{name: "id"}]}
210
- ]
211
- items = []
212
- }
213
- ```
214
-
215
- ### apis/list.xs
216
- ```xs
217
- query list verb=GET {
218
- api_group = "events"
219
- stack {
220
- db.query event {
221
- sort = { created_at: "desc" }
222
- return = { type: "list" }
223
- } as $events
224
- }
225
- response = $events
226
- }
227
- ```
228
-
229
- ---
230
-
231
- ## Complete Job Example
232
-
233
- ```
234
- ephemeral/data-migration/
235
- ├── workspace.xs
236
- ├── tables/
237
- │ └── users.xs
238
- └── functions/
239
- ├── $main.xs
240
- └── $post.xs
241
- ```
242
-
243
- ### workspace.xs
244
- ```xs
245
- workspace data_migration {
246
- env = { webhook_url: "https://webhook.site/xxx" }
247
- }
248
- ```
249
-
250
- ### tables/users.xs
251
- ```xs
252
- table users {
253
- auth = false
254
- schema {
255
- int id
256
- text name
257
- text email
258
- timestamp migrated_at?
259
- }
260
- index = [
261
- {type: "primary", field: [{name: "id"}]}
262
- ]
263
- items = [
264
- {"id": 1, "name": "Alice", "email": "alice@example.com"}
265
- {"id": 2, "name": "Bob", "email": "bob@example.com"}
266
- ]
267
- }
268
- ```
269
-
270
- ### functions/$main.xs
271
- ```xs
272
- function "$main" {
273
- input { json args, json pre }
274
- stack {
275
- db.query users {
276
- where = $db.users.migrated_at == null
277
- } as $pending
278
-
279
- foreach ($pending) {
280
- each as $user {
281
- db.edit users {
282
- field_name = "id"
283
- field_value = $user.id
284
- data = { migrated_at: now }
285
- }
286
- }
287
- }
288
- }
289
- response = { migrated: $pending|count }
290
- }
291
- ```
292
-
293
- ### functions/$post.xs
294
- ```xs
295
- function "$post" {
296
- input { json args, json pre, json main }
297
- stack {
298
- api.request {
299
- url = $env.webhook_url
300
- method = "POST"
301
- params = { result: $input.main }
302
- }
303
- }
304
- response = null
305
- }
306
- ```
307
-
308
- ---
309
-
310
- ## Deploying
311
-
312
- ### Deploy Service
313
- ```
314
- publish_ephemeral_service name="my-api" directory="ephemeral/my-service" mode="service"
315
- ```
316
-
317
- ### Run Job
318
- ```
319
- publish_ephemeral_service name="migration" directory="ephemeral/my-job" mode="job"
320
- ```
321
-
322
- ---
323
-
324
- ## Best Practices
325
-
326
- 1. **Keep isolated** - Self-contained with own tables/functions
327
- 2. **Seed test data** - Use `items` in table definitions
328
- 3. **Handle cleanup** - Use `$post` for notifications/cleanup
329
- 4. **Validate in $pre** - Check preconditions before main logic
330
- 5. **Name clearly** - Indicate purpose: `auth-test`, `data-migration`