@xano/developer-mcp 1.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 (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +261 -0
  3. package/api_docs/addon.md +193 -0
  4. package/api_docs/agent.md +154 -0
  5. package/api_docs/api_group.md +236 -0
  6. package/api_docs/authentication.md +68 -0
  7. package/api_docs/file.md +190 -0
  8. package/api_docs/function.md +217 -0
  9. package/api_docs/history.md +263 -0
  10. package/api_docs/index.md +104 -0
  11. package/api_docs/mcp_server.md +139 -0
  12. package/api_docs/middleware.md +205 -0
  13. package/api_docs/realtime.md +153 -0
  14. package/api_docs/table.md +151 -0
  15. package/api_docs/task.md +191 -0
  16. package/api_docs/tool.md +216 -0
  17. package/api_docs/triggers.md +344 -0
  18. package/api_docs/workspace.md +246 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +495 -0
  21. package/package.json +49 -0
  22. package/xanoscript_docs/README.md +1 -0
  23. package/xanoscript_docs/api_query_examples.md +1255 -0
  24. package/xanoscript_docs/api_query_guideline.md +129 -0
  25. package/xanoscript_docs/build_from_lovable.md +715 -0
  26. package/xanoscript_docs/db_query_guideline.md +427 -0
  27. package/xanoscript_docs/ephemeral_environment_guideline.md +529 -0
  28. package/xanoscript_docs/expression_guideline.md +1086 -0
  29. package/xanoscript_docs/frontend_guideline.md +67 -0
  30. package/xanoscript_docs/function_examples.md +1406 -0
  31. package/xanoscript_docs/function_guideline.md +130 -0
  32. package/xanoscript_docs/functions.md +2155 -0
  33. package/xanoscript_docs/input_guideline.md +227 -0
  34. package/xanoscript_docs/mcp_server_examples.md +36 -0
  35. package/xanoscript_docs/mcp_server_guideline.md +69 -0
  36. package/xanoscript_docs/query_filter.md +489 -0
  37. package/xanoscript_docs/table_examples.md +586 -0
  38. package/xanoscript_docs/table_guideline.md +137 -0
  39. package/xanoscript_docs/task_examples.md +511 -0
  40. package/xanoscript_docs/task_guideline.md +103 -0
  41. package/xanoscript_docs/tips_and_tricks.md +144 -0
  42. package/xanoscript_docs/tool_examples.md +69 -0
  43. package/xanoscript_docs/tool_guideline.md +139 -0
  44. package/xanoscript_docs/unit_testing_guideline.md +328 -0
  45. package/xanoscript_docs/version.json +3 -0
  46. package/xanoscript_docs/workspace.md +17 -0
@@ -0,0 +1,130 @@
1
+ ---
2
+ applyTo: "functions/**/*.xs"
3
+ ---
4
+
5
+ # How to Define Functions in XanoScript
6
+
7
+ A **function** in XanoScript is a reusable block of logic that can be called from other scripts, queries, or tasks. Functions are created in the `functions` folder and can be organized into subfolders for better structure.
8
+
9
+ ## Function Structure
10
+
11
+ A function file consists of:
12
+
13
+ - The function name (e.g., `calculate_total`, `utilities/parse_email`)
14
+ - An optional `description` field
15
+ - An `input` block defining parameters
16
+ - A `stack` block containing the logic to execute
17
+ - A `response` block specifying the output
18
+
19
+ ## Example Function
20
+
21
+ ```xs
22
+ function "maths/calculate_total" {
23
+ description = "Calculate the total cost based on quantity and price per item"
24
+
25
+ input {
26
+ int quantity filters=min:0 {
27
+ description = "Number of items"
28
+ }
29
+
30
+ decimal price_per_item filters=min:0.01 {
31
+ description = "Price for each item"
32
+ }
33
+ }
34
+
35
+ stack {
36
+ var $total {
37
+ value = 0
38
+ description = "Initialize total"
39
+ }
40
+
41
+ math.add $total {
42
+ value = $input.quantity * $input.price_per_item
43
+ description = "Calculate total"
44
+ }
45
+ }
46
+
47
+ response = $total
48
+ }
49
+ ```
50
+
51
+ ## How to call a function in your code
52
+
53
+ You can call a function using the `function.run` keyword followed by the function's name.
54
+
55
+ **Example:**
56
+
57
+ ```xs
58
+ function.run "maths/calculate_total" {
59
+ input = {
60
+ quantity: 5,
61
+ price_per_item: 20
62
+ }
63
+ } as $result
64
+ ```
65
+
66
+ ## Input Block
67
+
68
+ The `input` block defines the parameters your function expects. You can specify:
69
+
70
+ - Data types (`int`, `text`, `decimal`, etc.)
71
+ - Optional fields (add `?`)
72
+ - Filters (e.g., `trim`, `lower`)
73
+ - Metadata (`description`, `sensitive`)
74
+
75
+ **Example:**
76
+
77
+ ```xs
78
+ input {
79
+ text username filters=trim {
80
+ description = "User's login name"
81
+ }
82
+
83
+ text email filters=trim {
84
+ description = "User's email address"
85
+ }
86
+
87
+ date dob? {
88
+ description = "User's date of birth (YYYY-MM-DD)"
89
+ sensitive = true
90
+ }
91
+ }
92
+ ```
93
+
94
+ ## Stack Block
95
+
96
+ The `stack` block contains the logic for your function, such as:
97
+
98
+ - Variable declarations (`var`)
99
+ - Control flow (`conditional`, `for`, `foreach`)
100
+ - Function calls (`math.add`, `debug.log`)
101
+ - Database operations (`db.query`, `db.add`)
102
+ - Error handling (`throw`, `try_catch`)
103
+
104
+ ## Response Block
105
+
106
+ The `response` block defines what your function returns. The value can be a variable, object, or expression.
107
+
108
+ **Example:**
109
+
110
+ ```xs
111
+ response = $total
112
+ ```
113
+
114
+ ## Best Practices
115
+
116
+ - Use `description` for documentation.
117
+ - Validate inputs with `filters=...` first, fallback on `precondition` or `conditional` blocks.
118
+ - Place all logic inside the `stack` block.
119
+ - Always define a `response` block for output.
120
+ - Organize functions in subfolders for clarity.
121
+
122
+ ## Summary
123
+
124
+ - Place functions in the `functions` folder.
125
+ - Use `input` for parameters.
126
+ - Use `stack` for logic.
127
+ - Use `response` for output.
128
+ - Document your function with `description` fields.
129
+
130
+ For more examples, see the documentation or sample functions in your project.