@xano/developer-mcp 1.0.57 → 1.0.59

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 (38) hide show
  1. package/README.md +15 -0
  2. package/dist/tools/index.d.ts +9 -0
  3. package/dist/tools/xanoscript_docs.d.ts +9 -0
  4. package/dist/tools/xanoscript_docs.js +27 -0
  5. package/dist/xanoscript.d.ts +5 -1
  6. package/dist/xanoscript.js +70 -6
  7. package/dist/xanoscript.test.js +5 -3
  8. package/dist/xanoscript_docs/README.md +9 -43
  9. package/dist/xanoscript_docs/addons.md +0 -2
  10. package/dist/xanoscript_docs/agents.md +2 -35
  11. package/dist/xanoscript_docs/apis.md +3 -6
  12. package/dist/xanoscript_docs/branch.md +0 -2
  13. package/dist/xanoscript_docs/database.md +3 -7
  14. package/dist/xanoscript_docs/debugging.md +1 -264
  15. package/dist/xanoscript_docs/docs_index.json +22 -0
  16. package/dist/xanoscript_docs/essentials.md +1 -9
  17. package/dist/xanoscript_docs/frontend.md +1 -138
  18. package/dist/xanoscript_docs/functions.md +3 -7
  19. package/dist/xanoscript_docs/mcp-servers.md +1 -2
  20. package/dist/xanoscript_docs/middleware.md +1 -3
  21. package/dist/xanoscript_docs/performance.md +8 -198
  22. package/dist/xanoscript_docs/realtime.md +11 -161
  23. package/dist/xanoscript_docs/run.md +2 -184
  24. package/dist/xanoscript_docs/schema.md +1 -3
  25. package/dist/xanoscript_docs/security.md +82 -313
  26. package/dist/xanoscript_docs/streaming.md +2 -37
  27. package/dist/xanoscript_docs/survival.md +161 -0
  28. package/dist/xanoscript_docs/syntax.md +0 -6
  29. package/dist/xanoscript_docs/tables.md +3 -5
  30. package/dist/xanoscript_docs/tasks.md +1 -3
  31. package/dist/xanoscript_docs/tools.md +1 -3
  32. package/dist/xanoscript_docs/triggers.md +3 -69
  33. package/dist/xanoscript_docs/types.md +3 -4
  34. package/dist/xanoscript_docs/unit-testing.md +1 -55
  35. package/dist/xanoscript_docs/workflow-tests.md +8 -35
  36. package/dist/xanoscript_docs/working.md +667 -0
  37. package/dist/xanoscript_docs/workspace.md +0 -2
  38. package/package.json +2 -2
@@ -25,38 +25,10 @@ debug.log { value = "Starting process" }
25
25
 
26
26
  debug.log { value = $user }
27
27
 
28
- debug.log { value = { step: "validation", data: $input } }
29
- ```
30
-
31
- ### With Labels
32
-
33
- ```xs
34
28
  debug.log {
35
29
  label = "User Data"
36
30
  value = $user
37
31
  }
38
-
39
- debug.log {
40
- label = "Query Result"
41
- value = $products
42
- }
43
- ```
44
-
45
- ### Conditional Logging
46
-
47
- ```xs
48
- conditional {
49
- if ($env.DEBUG == "true") {
50
- debug.log {
51
- label = "Debug Info"
52
- value = {
53
- input: $input,
54
- auth: $auth,
55
- timestamp: now
56
- }
57
- }
58
- }
59
- }
60
32
  ```
61
33
 
62
34
  ---
@@ -78,194 +50,6 @@ debug.stop // Execution pauses here
78
50
  db.edit "user" { ... }
79
51
  ```
80
52
 
81
- ### Conditional Stop
82
-
83
- ```xs
84
- conditional {
85
- if ($user == null) {
86
- debug.log { value = "User not found, stopping" }
87
- debug.stop
88
- }
89
- }
90
- ```
91
-
92
- ### With Data Inspection
93
-
94
- ```xs
95
- debug.log {
96
- label = "State at stop point"
97
- value = {
98
- input: $input,
99
- user: $user,
100
- calculated: $total
101
- }
102
- }
103
- debug.stop
104
- ```
105
-
106
- ---
107
-
108
- ## Logging Patterns
109
-
110
- ### Request Tracing
111
-
112
- ```xs
113
- function "process_order" {
114
- input { int order_id }
115
- stack {
116
- security.create_uuid as $trace_id
117
-
118
- debug.log {
119
- label = "TRACE_START"
120
- value = { trace_id: $trace_id, order_id: $input.order_id }
121
- }
122
-
123
- // ... processing ...
124
-
125
- debug.log {
126
- label = "TRACE_END"
127
- value = { trace_id: $trace_id, status: "success" }
128
- }
129
- }
130
- }
131
- ```
132
-
133
- ### Error Context
134
-
135
- ```xs
136
- try_catch {
137
- try {
138
- function.run "risky_operation" { input = $data }
139
- }
140
- catch {
141
- debug.log {
142
- label = "ERROR"
143
- value = {
144
- operation: "risky_operation",
145
- input: $data,
146
- error: $error.message,
147
- stack: $error.stack
148
- }
149
- }
150
- throw { name = $error.name, value = $error.message }
151
- }
152
- }
153
- ```
154
-
155
- ### Performance Timing
156
-
157
- ```xs
158
- var $start { value = now|to_ms }
159
-
160
- db.query "product" { ... } as $products
161
-
162
- var $query_time { value = (now|to_ms) - $start }
163
-
164
- debug.log {
165
- label = "PERF"
166
- value = {
167
- operation: "product_query",
168
- duration_ms: $query_time,
169
- record_count: $products|count
170
- }
171
- }
172
- ```
173
-
174
- ### Step-by-Step
175
-
176
- ```xs
177
- debug.log { value = "Step 1: Validating input" }
178
- // validation code
179
-
180
- debug.log { value = "Step 2: Fetching user" }
181
- db.get "user" { ... } as $user
182
-
183
- debug.log { value = "Step 3: Processing order" }
184
- // order processing
185
-
186
- debug.log { value = "Step 4: Sending notification" }
187
- // notification code
188
-
189
- debug.log { value = "Complete" }
190
- ```
191
-
192
- ---
193
-
194
- ## Inspecting Variables
195
-
196
- ### Object Inspection
197
-
198
- ```xs
199
- debug.log {
200
- label = "User object"
201
- value = $user
202
- }
203
-
204
- // Logs full object structure:
205
- // {
206
- // id: 123,
207
- // name: "John",
208
- // email: "john@example.com",
209
- // ...
210
- // }
211
- ```
212
-
213
- ### Array Inspection
214
-
215
- ```xs
216
- debug.log {
217
- label = "Products"
218
- value = {
219
- count: $products|count,
220
- first: $products|first,
221
- last: $products|last,
222
- sample: $products|slice:0:3
223
- }
224
- }
225
- ```
226
-
227
- ### Expression Evaluation
228
-
229
- ```xs
230
- debug.log {
231
- label = "Calculated values"
232
- value = {
233
- total: $items|map:$$.price * $$.quantity|sum,
234
- tax: ($items|map:$$.price * $$.quantity|sum) * 0.08,
235
- item_count: $items|count
236
- }
237
- }
238
- ```
239
-
240
- ---
241
-
242
- ## Environment-Based Debugging
243
-
244
- ### Development Only
245
-
246
- ```xs
247
- conditional {
248
- if ($env.ENVIRONMENT == "development") {
249
- debug.log { value = "Development mode: verbose logging enabled" }
250
- debug.log { value = $input }
251
- }
252
- }
253
- ```
254
-
255
- ### Debug Flag
256
-
257
- ```xs
258
- // Enable with environment variable DEBUG=true
259
- conditional {
260
- if ($env.DEBUG|to_bool == true) {
261
- debug.log {
262
- label = "Debug"
263
- value = { step: "after_query", data: $result }
264
- }
265
- }
266
- }
267
- ```
268
-
269
53
  ---
270
54
 
271
55
  ## Request History
@@ -289,54 +73,7 @@ View past request executions in the Xano dashboard:
289
73
 
290
74
  ---
291
75
 
292
- ## Debugging Strategies
293
-
294
- ### Isolate the Problem
295
-
296
- ```xs
297
- // Comment out sections to isolate issues
298
- debug.log { value = "Checkpoint 1" }
299
- // potentially problematic code
300
- debug.log { value = "Checkpoint 2" }
301
- ```
302
-
303
- ### Validate Assumptions
304
-
305
- ```xs
306
- debug.log {
307
- label = "Assumption check"
308
- value = {
309
- user_exists: $user != null,
310
- has_permission: $user.role == "admin",
311
- input_valid: $input.amount > 0
312
- }
313
- }
314
- ```
315
-
316
- ### Compare Expected vs Actual
317
-
318
- ```xs
319
- var $expected { value = 100 }
320
- var $actual { value = $items|count }
321
-
322
- debug.log {
323
- label = "Comparison"
324
- value = {
325
- expected: $expected,
326
- actual: $actual,
327
- match: $expected == $actual
328
- }
329
- }
330
- ```
331
-
332
- ---
333
-
334
76
  ## Best Practices
335
77
 
336
78
  1. **Remove debug.stop in production** - Causes execution to halt
337
- 2. **Use labels consistently** - Makes log searching easier
338
- 3. **Log at boundaries** - Function entry/exit, external calls
339
- 4. **Include context** - IDs, timestamps, relevant state
340
- 5. **Don't log sensitive data** - Passwords, tokens, PII
341
- 6. **Use environment flags** - Enable verbose logging conditionally
342
- 7. **Check request history** - Built-in debugging in dashboard
79
+ 2. **Don't log sensitive data** - Passwords, tokens, PII
@@ -3,6 +3,20 @@
3
3
  "description": "Machine-readable index for XanoScript documentation",
4
4
 
5
5
  "topics": {
6
+ "survival": {
7
+ "file": "survival.md",
8
+ "description": "Minimal syntax survival kit for writing valid XanoScript (~3KB)",
9
+ "applyTo": ["**/*.xs"],
10
+ "priority": 0,
11
+ "aliases": ["minimal", "tiny", "nano", "small"]
12
+ },
13
+ "working": {
14
+ "file": "working.md",
15
+ "description": "Complete working reference for common XanoScript tasks (~12KB)",
16
+ "applyTo": ["**/*.xs"],
17
+ "priority": 0,
18
+ "aliases": ["compact", "reference", "medium"]
19
+ },
6
20
  "readme": {
7
21
  "file": "README.md",
8
22
  "description": "XanoScript overview, workspace structure, and quick reference",
@@ -52,30 +66,35 @@
52
66
  "file": "tables.md",
53
67
  "description": "Database schema definitions with indexes and relationships",
54
68
  "applyTo": ["tables/*.xs"],
69
+ "priority": 8,
55
70
  "aliases": ["schema", "fields", "indexes"]
56
71
  },
57
72
  "functions": {
58
73
  "file": "functions.md",
59
74
  "description": "Reusable function stacks with inputs and responses",
60
75
  "applyTo": ["functions/**/*.xs"],
76
+ "priority": 6,
61
77
  "aliases": ["fn", "reusable", "stack"]
62
78
  },
63
79
  "apis": {
64
80
  "file": "apis.md",
65
81
  "description": "HTTP endpoint definitions with authentication and CRUD patterns",
66
82
  "applyTo": ["apis/**/*.xs"],
83
+ "priority": 7,
67
84
  "aliases": ["endpoints", "http", "rest", "query"]
68
85
  },
69
86
  "tasks": {
70
87
  "file": "tasks.md",
71
88
  "description": "Scheduled and cron jobs",
72
89
  "applyTo": ["tasks/*.xs"],
90
+ "priority": 10,
73
91
  "aliases": ["scheduled", "jobs", "cron"]
74
92
  },
75
93
  "triggers": {
76
94
  "file": "triggers.md",
77
95
  "description": "Event-driven handlers (table, realtime, workspace, agent, MCP)",
78
96
  "applyTo": ["triggers/**/*.xs"],
97
+ "priority": 10,
79
98
  "aliases": ["events", "hooks", "handlers"]
80
99
  },
81
100
  "database": {
@@ -89,18 +108,21 @@
89
108
  "file": "agents.md",
90
109
  "description": "AI agent configuration with LLM providers and tools",
91
110
  "applyTo": ["agents/**/*.xs"],
111
+ "priority": 12,
92
112
  "aliases": ["ai", "llm", "chatbot"]
93
113
  },
94
114
  "tools": {
95
115
  "file": "tools.md",
96
116
  "description": "AI tools for agents and MCP servers",
97
117
  "applyTo": ["tools/**/*.xs"],
118
+ "priority": 12,
98
119
  "aliases": ["ai-tools", "agent-tools"]
99
120
  },
100
121
  "mcp-servers": {
101
122
  "file": "mcp-servers.md",
102
123
  "description": "MCP server definitions exposing tools",
103
124
  "applyTo": ["mcp_servers/**/*.xs"],
125
+ "priority": 15,
104
126
  "aliases": ["mcp", "model-context-protocol"]
105
127
  },
106
128
  "unit-testing": {
@@ -52,15 +52,7 @@ var $api_response { value = "test" }
52
52
 
53
53
  XanoScript uses specific type names. Common aliases from other languages won't work.
54
54
 
55
- > **Full reference:** See `xanoscript_docs({ topic: "types" })` for complete type details and validation.
56
-
57
- | Wrong | Correct | Description |
58
- |-------|---------|-------------|
59
- | `boolean` | `bool` | Boolean true/false |
60
- | `integer` | `int` | 32-bit integer |
61
- | `string` | `text` | UTF-8 string |
62
- | `number` / `float` | `decimal` | Floating-point number |
63
- | `array` / `list` | `type[]` | Array (e.g., `text[]`, `int[]`) |
55
+ > **Type names:** Use `text` (not string), `int` (not integer), `bool` (not boolean), `decimal` (not float). Full list: `xanoscript_docs({ topic: "types" })`
64
56
 
65
57
  ### Variable Declaration
66
58
 
@@ -4,7 +4,7 @@ applyTo: "static/**/*"
4
4
 
5
5
  # Frontend
6
6
 
7
- Static frontend development and Lovable/Supabase migration.
7
+ Static frontend development with Xano APIs.
8
8
 
9
9
  ## Quick Reference
10
10
 
@@ -129,142 +129,6 @@ async function getCurrentUser() {
129
129
 
130
130
  ---
131
131
 
132
- ## Lovable Migration
133
-
134
- Migrate from Supabase to Xano using the compatibility SDK.
135
-
136
- ### 1. Install SDK
137
- ```bash
138
- npm install @xano/supabase-compat
139
- ```
140
-
141
- ### 2. Create Xano Client
142
- ```typescript
143
- // src/integrations/xano/client.ts
144
- import { createClient } from '@xano/supabase-compat';
145
-
146
- export const xano = createClient(
147
- import.meta.env.VITE_XANO_URL,
148
- import.meta.env.VITE_XANO_AUTH_ENDPOINT,
149
- {
150
- auth: {
151
- storage: localStorage,
152
- persistSession: true,
153
- autoRefreshToken: true
154
- }
155
- }
156
- );
157
- ```
158
-
159
- ### 3. Update Environment
160
- ```env
161
- VITE_XANO_URL=https://your-instance.xano.io
162
- VITE_XANO_AUTH_ENDPOINT=/api:groupId/auth
163
- ```
164
-
165
- ### 4. Update Auth Hooks
166
-
167
- Before (Supabase):
168
- ```typescript
169
- import { supabase } from '@/integrations/supabase/client';
170
-
171
- supabase.auth.signInWithPassword({ email, password });
172
- supabase.auth.signUp({ email, password });
173
- supabase.auth.signOut();
174
- ```
175
-
176
- After (Xano):
177
- ```typescript
178
- import { xano } from '@/integrations/xano/client';
179
-
180
- xano.auth.signInWithPassword({ email, password });
181
- xano.auth.signUp({ email, password });
182
- xano.auth.signOut();
183
- ```
184
-
185
- ### 5. Update Data Hooks
186
-
187
- Before (Supabase):
188
- ```typescript
189
- const { data, error } = await supabase
190
- .from('products')
191
- .select('*')
192
- .eq('category', 'electronics')
193
- .order('created_at', { ascending: false });
194
- ```
195
-
196
- After (Xano):
197
- ```typescript
198
- const { data, error } = await xano
199
- .endpoint('/api:group/products')
200
- .get({
201
- category: 'electronics',
202
- sort: 'created_at',
203
- order: 'desc'
204
- });
205
- ```
206
-
207
- ---
208
-
209
- ## Common Patterns
210
-
211
- ### Pagination
212
- ```javascript
213
- async function getProducts(page = 1, perPage = 20) {
214
- return api.get(`/products?page=${page}&per_page=${perPage}`);
215
- }
216
- ```
217
-
218
- ### Filtering
219
- ```javascript
220
- async function searchProducts(query, category) {
221
- const params = new URLSearchParams();
222
- if (query) params.append('query', query);
223
- if (category) params.append('category', category);
224
- return api.get(`/products?${params}`);
225
- }
226
- ```
227
-
228
- ### File Upload
229
- ```javascript
230
- async function uploadImage(file) {
231
- const formData = new FormData();
232
- formData.append('image', file);
233
-
234
- const response = await fetch(`${API_BASE}/upload`, {
235
- method: 'POST',
236
- headers: {
237
- 'Authorization': `Bearer ${localStorage.getItem('auth_token')}`
238
- },
239
- body: formData
240
- });
241
-
242
- return response.json();
243
- }
244
- ```
245
-
246
- ---
247
-
248
- ## Migration Checklist
249
-
250
- ### Backend (Xano)
251
- - [ ] Create tables matching Supabase schema
252
- - [ ] Create CRUD endpoints for each resource
253
- - [ ] Set up authentication endpoints
254
- - [ ] Push changes: `push_all_changes_to_xano`
255
- - [ ] Get API specs: `get_xano_api_specifications`
256
-
257
- ### Frontend
258
- - [ ] Install `@xano/supabase-compat`
259
- - [ ] Create Xano client
260
- - [ ] Update environment variables
261
- - [ ] Update auth hooks (minimal changes)
262
- - [ ] Update data fetching (table → endpoint)
263
- - [ ] Test all operations
264
- - [ ] Remove Supabase dependencies
265
-
266
- ---
267
-
268
132
  ## Deployment
269
133
 
270
134
  Deploy static files to Xano CDN:
@@ -285,7 +149,6 @@ The tool will:
285
149
  1. **Get API specs first** - Use `get_xano_api_specifications` before coding
286
150
  2. **Centralize API calls** - Single `api.js` file
287
151
  3. **Store tokens securely** - localStorage for web, secure storage for mobile
288
- 4. **Test incrementally** - Migrate one feature at a time
289
152
 
290
153
  ---
291
154
 
@@ -456,13 +456,9 @@ foreach ($items) {
456
456
 
457
457
  ## Best Practices
458
458
 
459
- 1. **Single responsibility** - Each function does one thing well
460
- 2. **Descriptive names** - Use verb_noun format: `calculate_total`, `validate_user`
461
- 3. **Organize in folders** - Group related functions: `utils/`, `auth/`, `orders/`
462
- 4. **Return early** - Use return for guard clauses
463
- 5. **Keep stacks shallow** - Avoid deeply nested conditionals
464
- 6. **Use group for organization** - Visually group related statements for readability
465
- 7. **Use remove sparingly** - Consider filtering arrays instead
459
+ 1. **Organize in folders** - Group related functions in subfolders (`utils/`, `auth/`); call with `function.run "utils/format" { ... }`
460
+ 2. **Return early** - Use `return { value = ... }` for guard clauses to avoid deep nesting
461
+ 3. **Use `remove` sparingly** - Prefer `$items|filter:$$.condition` over in-loop `remove` for cleaner array filtering
466
462
 
467
463
  ---
468
464
 
@@ -183,8 +183,7 @@ The MCP protocol handles:
183
183
 
184
184
  1. **Clear naming** - Server name should indicate its purpose
185
185
  2. **Comprehensive instructions** - Guide AI on server's overall purpose
186
- 3. **Logical tool grouping** - Group related tools in one server
187
- 4. **Keep focused** - One domain per server (support, analytics, etc.)
186
+ 3. **Logical tool grouping** - Group related tools in one server; one domain per server
188
187
 
189
188
  ---
190
189
 
@@ -303,6 +303,4 @@ branch "production" {
303
303
 
304
304
  1. **Keep middleware focused** - Each middleware should do one thing well
305
305
  2. **Use appropriate exception policies** - Critical for security, silent for optional enrichment
306
- 3. **Consider performance** - Middleware runs on every request
307
- 4. **Log failures** - Even silent failures should be logged for debugging
308
- 5. **Test independently** - Middleware should be testable in isolation
306
+ 3. **Consider performance** - Middleware runs on every request; log even silent failures