@xano/developer-mcp 1.0.27 → 1.0.28
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.
- package/README.md +1 -1
- package/dist/api_docs/format.d.ts +5 -0
- package/dist/api_docs/format.js +171 -0
- package/dist/api_docs/index.d.ts +52 -0
- package/dist/api_docs/index.js +111 -0
- package/dist/api_docs/topics/agent.d.ts +2 -0
- package/dist/api_docs/topics/agent.js +142 -0
- package/dist/api_docs/topics/api.d.ts +2 -0
- package/dist/api_docs/topics/api.js +176 -0
- package/dist/api_docs/topics/apigroup.d.ts +2 -0
- package/dist/api_docs/topics/apigroup.js +124 -0
- package/dist/api_docs/topics/authentication.d.ts +2 -0
- package/dist/api_docs/topics/authentication.js +61 -0
- package/dist/api_docs/topics/branch.d.ts +2 -0
- package/dist/api_docs/topics/branch.js +73 -0
- package/dist/api_docs/topics/file.d.ts +2 -0
- package/dist/api_docs/topics/file.js +70 -0
- package/dist/api_docs/topics/function.d.ts +2 -0
- package/dist/api_docs/topics/function.js +164 -0
- package/dist/api_docs/topics/history.d.ts +2 -0
- package/dist/api_docs/topics/history.js +149 -0
- package/dist/api_docs/topics/mcp_server.d.ts +2 -0
- package/dist/api_docs/topics/mcp_server.js +139 -0
- package/dist/api_docs/topics/middleware.d.ts +2 -0
- package/dist/api_docs/topics/middleware.js +156 -0
- package/dist/api_docs/topics/realtime.d.ts +2 -0
- package/dist/api_docs/topics/realtime.js +112 -0
- package/dist/api_docs/topics/start.d.ts +2 -0
- package/dist/api_docs/topics/start.js +107 -0
- package/dist/api_docs/topics/table.d.ts +2 -0
- package/dist/api_docs/topics/table.js +195 -0
- package/dist/api_docs/topics/task.d.ts +2 -0
- package/dist/api_docs/topics/task.js +165 -0
- package/dist/api_docs/topics/tool.d.ts +2 -0
- package/dist/api_docs/topics/tool.js +150 -0
- package/dist/api_docs/topics/workflows.d.ts +2 -0
- package/dist/api_docs/topics/workflows.js +131 -0
- package/dist/api_docs/topics/workspace.d.ts +2 -0
- package/dist/api_docs/topics/workspace.js +153 -0
- package/dist/api_docs/types.d.ts +79 -0
- package/dist/api_docs/types.js +4 -0
- package/dist/meta_api_docs/topics/workspace.js +45 -2
- package/dist/templates/init-workspace.d.ts +10 -0
- package/dist/templates/init-workspace.js +278 -0
- package/dist/templates/xanoscript-index.d.ts +11 -0
- package/dist/templates/xanoscript-index.js +72 -0
- package/dist/xanoscript_docs/README.md +3 -13
- package/dist/xanoscript_docs/ephemeral.md +330 -0
- package/dist/xanoscript_docs/functions.md +0 -21
- package/dist/xanoscript_docs/integrations.md +0 -10
- package/dist/xanoscript_docs/performance.md +1 -10
- package/dist/xanoscript_docs/realtime.md +1 -48
- package/dist/xanoscript_docs/security.md +2 -0
- package/dist/xanoscript_docs/tools.md +2 -21
- package/dist/xanoscript_docs/triggers.md +2 -27
- package/dist/xanoscript_docs_auto/README.md +119 -0
- package/dist/xanoscript_docs_auto/agents.md +446 -0
- package/dist/xanoscript_docs_auto/apis.md +517 -0
- package/dist/xanoscript_docs_auto/control-flow.md +543 -0
- package/dist/xanoscript_docs_auto/database.md +551 -0
- package/dist/xanoscript_docs_auto/debugging.md +527 -0
- package/dist/xanoscript_docs_auto/filters.md +464 -0
- package/dist/xanoscript_docs_auto/functions.md +431 -0
- package/dist/xanoscript_docs_auto/integrations.md +657 -0
- package/dist/xanoscript_docs_auto/mcp-servers.md +408 -0
- package/dist/xanoscript_docs_auto/operators.md +368 -0
- package/dist/xanoscript_docs_auto/syntax.md +287 -0
- package/dist/xanoscript_docs_auto/tables.md +447 -0
- package/dist/xanoscript_docs_auto/tasks.md +479 -0
- package/dist/xanoscript_docs_auto/testing.md +574 -0
- package/dist/xanoscript_docs_auto/tools.md +485 -0
- package/dist/xanoscript_docs_auto/triggers.md +595 -0
- package/dist/xanoscript_docs_auto/types.md +323 -0
- package/dist/xanoscript_docs_auto/variables.md +462 -0
- package/dist/xanoscript_docs_auto/version.json +5 -0
- package/package.json +1 -1
|
@@ -45,19 +45,9 @@ project/
|
|
|
45
45
|
|
|
46
46
|
## Environment Variables
|
|
47
47
|
|
|
48
|
-
Access with `$env.<name>`.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
| --------------------------- | ----------------------------- |
|
|
52
|
-
| `$env.$remote_ip` | Client IP address |
|
|
53
|
-
| `$env.$http_headers` | Request headers array |
|
|
54
|
-
| `$env.$request_uri` | Request URI |
|
|
55
|
-
| `$env.$request_method` | HTTP method (GET, POST, etc.) |
|
|
56
|
-
| `$env.$request_querystring` | Query string |
|
|
57
|
-
| `$env.$datasource` | Current datasource |
|
|
58
|
-
| `$env.$branch` | Current branch |
|
|
59
|
-
|
|
60
|
-
Custom environment variables are set in the Xano dashboard and accessed as `$env.MY_VAR`.
|
|
48
|
+
Access with `$env.<name>`. Common built-in variables include `$env.$remote_ip`, `$env.$http_headers`, `$env.$request_method`, `$env.$datasource`, and `$env.$branch`. Custom environment variables are set in the Xano dashboard and accessed as `$env.MY_VAR`.
|
|
49
|
+
|
|
50
|
+
For the complete list of system variables, see `xanoscript_docs({ topic: "syntax" })`.
|
|
61
51
|
|
|
62
52
|
## Core Syntax Patterns
|
|
63
53
|
|
|
@@ -0,0 +1,330 @@
|
|
|
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`
|
|
@@ -87,27 +87,6 @@ input {
|
|
|
87
87
|
}
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
-
### Empty and Single-Input Blocks
|
|
91
|
-
|
|
92
|
-
Empty input blocks and single-input blocks can be written as one-liners. However, when there are two or more inputs, each must be on its own line.
|
|
93
|
-
|
|
94
|
-
```xs
|
|
95
|
-
// OK - empty input as one-liner
|
|
96
|
-
input {}
|
|
97
|
-
|
|
98
|
-
// OK - single input as one-liner
|
|
99
|
-
input { email email_input? filters=trim|lower }
|
|
100
|
-
|
|
101
|
-
// OK - multiple inputs on separate lines
|
|
102
|
-
input {
|
|
103
|
-
email email_input? filters=trim|lower
|
|
104
|
-
text name
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// WRONG - multiple inputs on one line will cause parsing errors
|
|
108
|
-
input { email email_input? filters=trim|lower text name }
|
|
109
|
-
```
|
|
110
|
-
|
|
111
90
|
---
|
|
112
91
|
|
|
113
92
|
## Stack Block
|
|
@@ -506,16 +506,6 @@ security.check_password {
|
|
|
506
506
|
} as $is_valid
|
|
507
507
|
```
|
|
508
508
|
|
|
509
|
-
### Auth Tokens
|
|
510
|
-
```xs
|
|
511
|
-
security.create_auth_token {
|
|
512
|
-
table = "user"
|
|
513
|
-
id = $user.id
|
|
514
|
-
extras = { role: $user.role }
|
|
515
|
-
expiration = 86400
|
|
516
|
-
} as $token
|
|
517
|
-
```
|
|
518
|
-
|
|
519
509
|
### Encryption
|
|
520
510
|
```xs
|
|
521
511
|
# Encrypt
|
|
@@ -276,16 +276,7 @@ api.request {
|
|
|
276
276
|
|
|
277
277
|
## Rate Limiting
|
|
278
278
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
```xs
|
|
282
|
-
redis.ratelimit {
|
|
283
|
-
key = "api:" ~ $auth.id
|
|
284
|
-
max = 100
|
|
285
|
-
ttl = 60
|
|
286
|
-
error = "Rate limit exceeded. Try again in 1 minute."
|
|
287
|
-
}
|
|
288
|
-
```
|
|
279
|
+
For basic rate limiting setup, see `xanoscript_docs({ topic: "security" })`. Below are performance-focused patterns.
|
|
289
280
|
|
|
290
281
|
### Tiered Limits
|
|
291
282
|
|
|
@@ -261,54 +261,7 @@ api.realtime_event {
|
|
|
261
261
|
|
|
262
262
|
## Realtime Triggers
|
|
263
263
|
|
|
264
|
-
Handle events from connected clients
|
|
265
|
-
|
|
266
|
-
### Basic Realtime Trigger
|
|
267
|
-
|
|
268
|
-
```xs
|
|
269
|
-
realtime_trigger "on_presence" {
|
|
270
|
-
channel = "room:*"
|
|
271
|
-
event = "join"
|
|
272
|
-
stack {
|
|
273
|
-
// $input contains event data
|
|
274
|
-
// $channel contains matched channel
|
|
275
|
-
db.add "presence" {
|
|
276
|
-
data = {
|
|
277
|
-
user_id: $auth.id,
|
|
278
|
-
room_id: $input.room_id,
|
|
279
|
-
joined_at: now
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// Notify room members
|
|
284
|
-
api.realtime_event {
|
|
285
|
-
channel = $channel
|
|
286
|
-
event = "user_joined"
|
|
287
|
-
data = { user_id: $auth.id }
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
### Channel Pattern Matching
|
|
294
|
-
|
|
295
|
-
```xs
|
|
296
|
-
realtime_trigger "document_cursor" {
|
|
297
|
-
channel = "document:*" // Wildcard match
|
|
298
|
-
event = "cursor_move"
|
|
299
|
-
stack {
|
|
300
|
-
// Broadcast cursor position to other viewers
|
|
301
|
-
api.realtime_event {
|
|
302
|
-
channel = $channel
|
|
303
|
-
event = "cursor_update"
|
|
304
|
-
data = {
|
|
305
|
-
user_id: $auth.id,
|
|
306
|
-
position: $input.position
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
```
|
|
264
|
+
Handle events from connected clients using `realtime_trigger`. For complete trigger syntax, input schemas, and configuration options, see `xanoscript_docs({ topic: "triggers" })`.
|
|
312
265
|
|
|
313
266
|
---
|
|
314
267
|
|
|
@@ -74,27 +74,6 @@ input {
|
|
|
74
74
|
}
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
### Empty and Single-Input Blocks
|
|
78
|
-
|
|
79
|
-
Empty input blocks and single-input blocks can be written as one-liners. When there are two or more inputs, each must be on its own line.
|
|
80
|
-
|
|
81
|
-
```xs
|
|
82
|
-
// OK - empty input
|
|
83
|
-
tool "get_system_status" {
|
|
84
|
-
description = "Get current system status"
|
|
85
|
-
instructions = "Use this to check if the system is healthy"
|
|
86
|
-
input {}
|
|
87
|
-
stack { ... }
|
|
88
|
-
response = $status
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// OK - single input as one-liner
|
|
92
|
-
input { text query filters=trim }
|
|
93
|
-
|
|
94
|
-
// WRONG - multiple inputs on one line will cause parsing errors
|
|
95
|
-
input { text query filters=trim int limit }
|
|
96
|
-
```
|
|
97
|
-
|
|
98
77
|
---
|
|
99
78
|
|
|
100
79
|
## Tool-Specific Statements
|
|
@@ -275,6 +254,8 @@ tool "get_order_with_items" {
|
|
|
275
254
|
|
|
276
255
|
## Error Handling
|
|
277
256
|
|
|
257
|
+
For complete error handling reference (preconditions, try-catch, throw, error types), see `xanoscript_docs({ topic: "syntax" })`.
|
|
258
|
+
|
|
278
259
|
```xs
|
|
279
260
|
tool "cancel_order" {
|
|
280
261
|
instructions = "Cancel an order. Only works for pending orders."
|
|
@@ -43,34 +43,9 @@ input {
|
|
|
43
43
|
| `action` | enum | The action that triggered: `insert`, `update`, `delete`, or `truncate` |
|
|
44
44
|
| `datasource` | text | The datasource name where the change occurred |
|
|
45
45
|
|
|
46
|
-
### Agent Trigger Input
|
|
46
|
+
### Agent Trigger Input / MCP Server Trigger Input
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
input {
|
|
50
|
-
object toolset {
|
|
51
|
-
schema {
|
|
52
|
-
int id
|
|
53
|
-
text name
|
|
54
|
-
text instructions
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
object[] tools {
|
|
59
|
-
schema {
|
|
60
|
-
int id
|
|
61
|
-
text name
|
|
62
|
-
text instructions
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
| Field | Type | Description |
|
|
69
|
-
|-------|------|-------------|
|
|
70
|
-
| `toolset` | object | The toolset configuration with id, name, and instructions |
|
|
71
|
-
| `tools` | object[] | Array of available tools with their id, name, and instructions |
|
|
72
|
-
|
|
73
|
-
### MCP Server Trigger Input
|
|
48
|
+
Agent triggers and MCP server triggers share the same input schema:
|
|
74
49
|
|
|
75
50
|
```xs
|
|
76
51
|
input {
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# XanoScript Complete Reference
|
|
2
|
+
|
|
3
|
+
XanoScript is a declarative, statically-typed scripting language for [Xano](https://xano.com). It enables developers to build API endpoints, functions, scheduled tasks, database operations, and AI agents with structured, readable syntax.
|
|
4
|
+
|
|
5
|
+
## Quick Reference
|
|
6
|
+
|
|
7
|
+
### Top-Level Object Types
|
|
8
|
+
|
|
9
|
+
| Type | File Location | Purpose |
|
|
10
|
+
|------|---------------|---------|
|
|
11
|
+
| `query` | `apis/<group>/*.xs` | HTTP API endpoints with verbs, input, processing, response |
|
|
12
|
+
| `function` | `functions/**/*.xs` | Reusable logic blocks with optional testing |
|
|
13
|
+
| `task` | `tasks/*.xs` | Scheduled operations with cron-like triggers |
|
|
14
|
+
| `table` | `tables/*.xs` | Database schema definitions |
|
|
15
|
+
| `table_trigger` | `triggers/**/*.xs` | Trigger handlers for database events |
|
|
16
|
+
| `agent` | `agents/**/*.xs` | AI agent definitions |
|
|
17
|
+
| `tool` | `tools/**/*.xs` | Tool definitions for AI agents |
|
|
18
|
+
| `mcp_server` | `mcp_servers/**/*.xs` | Model Context Protocol server definitions |
|
|
19
|
+
| `middleware` | `middleware/**/*.xs` | Request/response interceptors |
|
|
20
|
+
| `addon` | `addons/*.xs` | Subqueries for related data |
|
|
21
|
+
| `branch` | `branch.xs` | Branch-level configuration |
|
|
22
|
+
| `workspace` | `workspace.xs` | Workspace-level settings |
|
|
23
|
+
| `realtime_channel` | Configuration | Real-time channel definitions |
|
|
24
|
+
| `api_group` | `apis/<group>/` | Collections of related API endpoints |
|
|
25
|
+
|
|
26
|
+
**Important:** Each `.xs` file must contain exactly one definition.
|
|
27
|
+
|
|
28
|
+
### Block Structure
|
|
29
|
+
|
|
30
|
+
```xs
|
|
31
|
+
<construct> "<name>" {
|
|
32
|
+
input { ... } // Parameters (optional)
|
|
33
|
+
stack { ... } // Logic
|
|
34
|
+
response = $var // Output
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Variable Access
|
|
39
|
+
|
|
40
|
+
```xs
|
|
41
|
+
$input.field // Input parameters
|
|
42
|
+
$var.name // Stack variables (in some contexts)
|
|
43
|
+
$auth.id // Authenticated user ID
|
|
44
|
+
$env.MY_VAR // Environment variable
|
|
45
|
+
$db.table.field // Database field reference (in queries)
|
|
46
|
+
$this // Current item in loops/maps
|
|
47
|
+
$error // Error information (in catch blocks)
|
|
48
|
+
now // Current timestamp
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Language Blocks (Clauses)
|
|
52
|
+
|
|
53
|
+
| Block | Purpose |
|
|
54
|
+
|-------|---------|
|
|
55
|
+
| `stack` | Container for sequential operations |
|
|
56
|
+
| `input` | Define parameters with types and validation |
|
|
57
|
+
| `schema` | Database table schema |
|
|
58
|
+
| `response` | Specify output data |
|
|
59
|
+
| `schedule` | Execution times for tasks |
|
|
60
|
+
| `security` | Authentication and permissions |
|
|
61
|
+
| `auth` | Authentication configuration |
|
|
62
|
+
| `cache` | Caching configuration |
|
|
63
|
+
| `history` | History tracking |
|
|
64
|
+
| `index` | Database index definitions |
|
|
65
|
+
| `test` | Test definitions |
|
|
66
|
+
| `view` | View definitions |
|
|
67
|
+
| `middleware` | Middleware configuration |
|
|
68
|
+
|
|
69
|
+
## Workspace Structure
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
project/
|
|
73
|
+
├── workspace.xs // Workspace configuration
|
|
74
|
+
├── branch.xs // Branch configuration
|
|
75
|
+
├── tables/ // Database table schemas
|
|
76
|
+
├── functions/ // Reusable functions (supports subfolders)
|
|
77
|
+
├── apis/
|
|
78
|
+
│ └── <api-group>/ // API endpoints grouped by domain
|
|
79
|
+
├── tasks/ // Scheduled jobs
|
|
80
|
+
├── triggers/ // Event-driven handlers
|
|
81
|
+
├── agents/ // AI agents
|
|
82
|
+
├── tools/ // AI tools
|
|
83
|
+
├── mcp_servers/ // MCP server definitions
|
|
84
|
+
├── middleware/ // Request/response interceptors
|
|
85
|
+
├── addons/ // Query addons
|
|
86
|
+
├── static/ // Frontend files
|
|
87
|
+
└── run/ // Job and service configurations
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Comments
|
|
91
|
+
|
|
92
|
+
```xs
|
|
93
|
+
// Single-line comment
|
|
94
|
+
/* Multi-line comment */
|
|
95
|
+
var $total { value = 0 } // Inline comment
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Documentation Topics
|
|
99
|
+
|
|
100
|
+
| Topic | Description |
|
|
101
|
+
|-------|-------------|
|
|
102
|
+
| `syntax` | Expressions, operators, filters |
|
|
103
|
+
| `types` | Data types and validation |
|
|
104
|
+
| `operators` | Comparison, logical, math operators |
|
|
105
|
+
| `filters` | Pipe filters for transformations |
|
|
106
|
+
| `control-flow` | Conditionals, loops, error handling |
|
|
107
|
+
| `functions` | Function definitions and calls |
|
|
108
|
+
| `database` | All db.* operations |
|
|
109
|
+
| `apis` | HTTP endpoint definitions |
|
|
110
|
+
| `tables` | Database schema definitions |
|
|
111
|
+
| `tasks` | Scheduled jobs |
|
|
112
|
+
| `triggers` | Event-driven handlers |
|
|
113
|
+
| `agents` | AI agent configuration |
|
|
114
|
+
| `tools` | AI tools for agents |
|
|
115
|
+
| `mcp-servers` | MCP server definitions |
|
|
116
|
+
| `integrations` | Cloud storage, Redis, external APIs |
|
|
117
|
+
| `security-functions` | Encryption, hashing, auth tokens |
|
|
118
|
+
| `testing` | Unit tests and assertions |
|
|
119
|
+
| `variables` | System and built-in variables |
|