@xano/developer-mcp 1.0.20 → 1.0.22

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 (57) hide show
  1. package/README.md +100 -19
  2. package/dist/index.js +4 -227
  3. package/dist/meta_api_docs/format.d.ts +16 -1
  4. package/dist/meta_api_docs/format.js +24 -6
  5. package/dist/meta_api_docs/format.test.d.ts +1 -0
  6. package/dist/meta_api_docs/format.test.js +274 -0
  7. package/dist/meta_api_docs/index.test.d.ts +1 -0
  8. package/dist/meta_api_docs/index.test.js +128 -0
  9. package/dist/meta_api_docs/types.test.d.ts +1 -0
  10. package/dist/meta_api_docs/types.test.js +132 -0
  11. package/dist/run_api_docs/format.d.ts +1 -0
  12. package/dist/run_api_docs/format.js +3 -170
  13. package/dist/run_api_docs/format.test.d.ts +1 -0
  14. package/dist/run_api_docs/format.test.js +86 -0
  15. package/dist/run_api_docs/index.test.d.ts +1 -0
  16. package/dist/run_api_docs/index.test.js +127 -0
  17. package/dist/templates/init-workspace.js +4 -4
  18. package/dist/templates/xanoscript-index.d.ts +3 -1
  19. package/dist/templates/xanoscript-index.js +54 -51
  20. package/dist/xanoscript.d.ts +41 -0
  21. package/dist/xanoscript.js +261 -0
  22. package/dist/xanoscript.test.d.ts +1 -0
  23. package/dist/xanoscript.test.js +303 -0
  24. package/dist/xanoscript_docs/README.md +53 -37
  25. package/dist/xanoscript_docs/agents.md +1 -1
  26. package/dist/xanoscript_docs/apis.md +6 -3
  27. package/dist/xanoscript_docs/branch.md +239 -0
  28. package/dist/xanoscript_docs/functions.md +6 -6
  29. package/dist/xanoscript_docs/integrations.md +43 -1
  30. package/dist/xanoscript_docs/middleware.md +321 -0
  31. package/dist/xanoscript_docs/performance.md +1 -1
  32. package/dist/xanoscript_docs/realtime.md +113 -1
  33. package/dist/xanoscript_docs/tasks.md +2 -2
  34. package/dist/xanoscript_docs/tools.md +3 -3
  35. package/dist/xanoscript_docs/types.md +25 -8
  36. package/dist/xanoscript_docs/workspace.md +209 -0
  37. package/dist/xanoscript_docs_auto/README.md +119 -0
  38. package/dist/xanoscript_docs_auto/agents.md +446 -0
  39. package/dist/xanoscript_docs_auto/apis.md +517 -0
  40. package/dist/xanoscript_docs_auto/control-flow.md +543 -0
  41. package/dist/xanoscript_docs_auto/database.md +551 -0
  42. package/dist/xanoscript_docs_auto/debugging.md +527 -0
  43. package/dist/xanoscript_docs_auto/filters.md +464 -0
  44. package/dist/xanoscript_docs_auto/functions.md +431 -0
  45. package/dist/xanoscript_docs_auto/integrations.md +657 -0
  46. package/dist/xanoscript_docs_auto/mcp-servers.md +408 -0
  47. package/dist/xanoscript_docs_auto/operators.md +368 -0
  48. package/dist/xanoscript_docs_auto/syntax.md +287 -0
  49. package/dist/xanoscript_docs_auto/tables.md +447 -0
  50. package/dist/xanoscript_docs_auto/tasks.md +479 -0
  51. package/dist/xanoscript_docs_auto/testing.md +574 -0
  52. package/dist/xanoscript_docs_auto/tools.md +485 -0
  53. package/dist/xanoscript_docs_auto/triggers.md +595 -0
  54. package/dist/xanoscript_docs_auto/types.md +323 -0
  55. package/dist/xanoscript_docs_auto/variables.md +462 -0
  56. package/dist/xanoscript_docs_auto/version.json +5 -0
  57. package/package.json +6 -2
@@ -0,0 +1,408 @@
1
+ ---
2
+ applyTo: "mcp_servers/**/*.xs"
3
+ ---
4
+
5
+ # MCP Servers
6
+
7
+ Model Context Protocol (MCP) server definitions for exposing tools to AI systems.
8
+
9
+ ## Quick Reference
10
+
11
+ ```xs
12
+ mcp_server "<name>" {
13
+ description = "Server description"
14
+ tools = [tool1, tool2]
15
+ }
16
+ ```
17
+
18
+ ---
19
+
20
+ ## MCP Server Definition
21
+
22
+ ### Basic MCP Server
23
+
24
+ ```xs
25
+ mcp_server "data_tools" {
26
+ description = "Tools for data access and manipulation"
27
+ tools = [
28
+ query_database,
29
+ search_products,
30
+ get_user_profile
31
+ ]
32
+ }
33
+ ```
34
+
35
+ ### With Configuration
36
+
37
+ ```xs
38
+ mcp_server "analytics_tools" {
39
+ description = "Analytics and reporting tools"
40
+ tools = [
41
+ get_dashboard_stats,
42
+ generate_report,
43
+ export_data
44
+ ]
45
+ auth = {
46
+ type = "api_key"
47
+ header = "X-API-Key"
48
+ }
49
+ }
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Server Properties
55
+
56
+ | Property | Description |
57
+ |----------|-------------|
58
+ | `description` | Human-readable description |
59
+ | `tools` | List of tool names to expose |
60
+ | `auth` | Authentication configuration |
61
+ | `resources` | Resource definitions |
62
+ | `prompts` | Prompt templates |
63
+
64
+ ---
65
+
66
+ ## Defining Tools for MCP
67
+
68
+ Tools exposed via MCP follow the standard tool format:
69
+
70
+ ```xs
71
+ tool "query_database" {
72
+ description = "Execute a database query and return results"
73
+ input {
74
+ text table description="Table name to query"
75
+ json? filters description="Filter conditions"
76
+ int? limit description="Maximum results" default=100
77
+ }
78
+ stack {
79
+ db.query $input.table {
80
+ where = $input.filters
81
+ return = {type: "list", paging: {per_page: $input.limit}}
82
+ } as $results
83
+ }
84
+ response = $results
85
+ }
86
+
87
+ tool "search_products" {
88
+ description = "Search products by name or category"
89
+ input {
90
+ text? query description="Search query"
91
+ text? category description="Category filter"
92
+ }
93
+ stack {
94
+ db.query product {
95
+ where = $db.product.name ilike? ("%" ~ $input.query ~ "%")
96
+ && $db.product.category ==? $input.category
97
+ } as $products
98
+ }
99
+ response = $products
100
+ }
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Authentication
106
+
107
+ ### API Key Authentication
108
+
109
+ ```xs
110
+ mcp_server "secure_tools" {
111
+ auth = {
112
+ type = "api_key"
113
+ header = "X-API-Key"
114
+ env_var = "MCP_API_KEY"
115
+ }
116
+ tools = [...]
117
+ }
118
+ ```
119
+
120
+ ### Bearer Token
121
+
122
+ ```xs
123
+ mcp_server "authenticated_tools" {
124
+ auth = {
125
+ type = "bearer"
126
+ env_var = "MCP_AUTH_TOKEN"
127
+ }
128
+ tools = [...]
129
+ }
130
+ ```
131
+
132
+ ---
133
+
134
+ ## External MCP Servers
135
+
136
+ ### Call External MCP Tools
137
+
138
+ ```xs
139
+ ai.external.mcp.tool.list {
140
+ server = "external_server_name"
141
+ } as $available_tools
142
+
143
+ ai.external.mcp.tool.run {
144
+ server = "external_server_name"
145
+ tool = "tool_name"
146
+ input = {
147
+ param1: "value1",
148
+ param2: "value2"
149
+ }
150
+ } as $result
151
+ ```
152
+
153
+ ### Get Server Details
154
+
155
+ ```xs
156
+ ai.external.mcp.server_details {
157
+ server = "external_server_name"
158
+ } as $server_info
159
+ ```
160
+
161
+ ---
162
+
163
+ ## MCP Server Triggers
164
+
165
+ Handle events from MCP server interactions:
166
+
167
+ ```xs
168
+ mcp_server_trigger "log_tool_calls" {
169
+ server = "data_tools"
170
+ event = tool_call
171
+
172
+ stack {
173
+ db.add mcp_log {
174
+ data = {
175
+ server: $trigger.server,
176
+ tool: $trigger.tool,
177
+ input: $trigger.input|json_encode,
178
+ output: $trigger.output|json_encode,
179
+ client_id: $trigger.client_id,
180
+ created_at: now
181
+ }
182
+ }
183
+ }
184
+ }
185
+ ```
186
+
187
+ ### Trigger Events
188
+
189
+ | Event | Description |
190
+ |-------|-------------|
191
+ | `tool_call` | Tool was invoked |
192
+ | `connection` | Client connected |
193
+ | `disconnection` | Client disconnected |
194
+ | `error` | Error occurred |
195
+
196
+ ---
197
+
198
+ ## Complete Example
199
+
200
+ ```xs
201
+ // MCP Server Definition
202
+ mcp_server "ecommerce_tools" {
203
+ description = "E-commerce data access tools for AI assistants"
204
+ tools = [
205
+ search_products,
206
+ get_product_details,
207
+ check_inventory,
208
+ get_order_status,
209
+ list_categories
210
+ ]
211
+ }
212
+
213
+ // Tool: Search Products
214
+ tool "search_products" {
215
+ description = "Search for products by keyword, category, or price range"
216
+ input {
217
+ text? query description="Search keyword"
218
+ text? category description="Product category"
219
+ decimal? min_price description="Minimum price"
220
+ decimal? max_price description="Maximum price"
221
+ int? limit description="Max results" default=20
222
+ }
223
+ stack {
224
+ db.query product {
225
+ where = $db.product.active == true
226
+ && $db.product.name ilike? ("%" ~ $input.query ~ "%")
227
+ && $db.product.category ==? $input.category
228
+ && $db.product.price >=? $input.min_price
229
+ && $db.product.price <=? $input.max_price
230
+ order_by = {field: "name", direction: "asc"}
231
+ return = {type: "list", paging: {per_page: $input.limit}}
232
+ } as $products
233
+ }
234
+ response = $products|map:{
235
+ id: $$.id,
236
+ name: $$.name,
237
+ category: $$.category,
238
+ price: $$.price,
239
+ in_stock: $$.stock > 0
240
+ }
241
+ }
242
+
243
+ // Tool: Get Product Details
244
+ tool "get_product_details" {
245
+ description = "Get detailed information about a specific product"
246
+ input {
247
+ int product_id description="The product ID"
248
+ }
249
+ stack {
250
+ db.get product {
251
+ field_name = "id"
252
+ field_value = $input.product_id
253
+ } as $product
254
+
255
+ conditional {
256
+ if ($product == null) {
257
+ return {
258
+ value = {error: "Product not found"}
259
+ }
260
+ }
261
+ }
262
+ }
263
+ response = {
264
+ id: $product.id,
265
+ name: $product.name,
266
+ description: $product.description,
267
+ category: $product.category,
268
+ price: $product.price,
269
+ sale_price: $product.sale_price,
270
+ stock: $product.stock,
271
+ attributes: $product.attributes,
272
+ images: $product.images
273
+ }
274
+ }
275
+
276
+ // Tool: Check Inventory
277
+ tool "check_inventory" {
278
+ description = "Check stock availability for one or more products"
279
+ input {
280
+ array<int> product_ids description="List of product IDs to check"
281
+ }
282
+ stack {
283
+ db.query product {
284
+ where = $db.product.id in $input.product_ids
285
+ } as $products
286
+ }
287
+ response = $products|map:{
288
+ product_id: $$.id,
289
+ name: $$.name,
290
+ stock: $$.stock,
291
+ available: $$.stock > 0
292
+ }
293
+ }
294
+
295
+ // Tool: Get Order Status
296
+ tool "get_order_status" {
297
+ description = "Get the current status of an order"
298
+ input {
299
+ text order_number description="Order number"
300
+ }
301
+ stack {
302
+ db.get order {
303
+ field_name = "order_number"
304
+ field_value = $input.order_number
305
+ } as $order
306
+
307
+ conditional {
308
+ if ($order == null) {
309
+ return {
310
+ value = {error: "Order not found"}
311
+ }
312
+ }
313
+ }
314
+ }
315
+ response = {
316
+ order_number: $order.order_number,
317
+ status: $order.status,
318
+ created_at: $order.created_at,
319
+ shipped_at: $order.shipped_at,
320
+ tracking_number: $order.tracking_number
321
+ }
322
+ }
323
+
324
+ // Tool: List Categories
325
+ tool "list_categories" {
326
+ description = "Get all product categories"
327
+ stack {
328
+ db.query category {
329
+ where = $db.category.active == true
330
+ order_by = {field: "name", direction: "asc"}
331
+ } as $categories
332
+ }
333
+ response = $categories|map:{
334
+ id: $$.id,
335
+ name: $$.name,
336
+ product_count: $$.product_count
337
+ }
338
+ }
339
+ ```
340
+
341
+ ---
342
+
343
+ ## Best Practices
344
+
345
+ ### Clear Descriptions
346
+
347
+ Write descriptions that help AI understand when to use each tool:
348
+
349
+ ```xs
350
+ // Good
351
+ description = "Search for products by name, category, or price range. Returns product ID, name, price, and availability."
352
+
353
+ // Bad
354
+ description = "Product search"
355
+ ```
356
+
357
+ ### Structured Responses
358
+
359
+ Return well-structured data:
360
+
361
+ ```xs
362
+ // Good: Clear structure with relevant fields
363
+ response = {
364
+ success: true,
365
+ data: $results,
366
+ count: $results|count,
367
+ has_more: $total > $limit
368
+ }
369
+
370
+ // Bad: Raw database response
371
+ response = $results
372
+ ```
373
+
374
+ ### Handle Errors Gracefully
375
+
376
+ ```xs
377
+ tool "safe_operation" {
378
+ stack {
379
+ try_catch {
380
+ try {
381
+ // Operation
382
+ }
383
+ catch {
384
+ return {
385
+ value = {
386
+ success: false,
387
+ error: $error.message
388
+ }
389
+ }
390
+ }
391
+ }
392
+ }
393
+ response = {success: true, data: $result}
394
+ }
395
+ ```
396
+
397
+ ### Limit Data Exposure
398
+
399
+ Only expose necessary data:
400
+
401
+ ```xs
402
+ // Don't expose sensitive fields
403
+ response = $users|map:{
404
+ id: $$.id,
405
+ name: $$.name,
406
+ // Omit: email, password_hash, internal_notes
407
+ }
408
+ ```