@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,129 @@
1
+ ---
2
+ applyTo: "apis/**/*.xs"
3
+ ---
4
+
5
+ # How to Define API Queries in XanoScript
6
+
7
+ An **API query** in XanoScript defines an endpoint for handling HTTP requests (GET, POST, etc.). Queries are created in the `apis/<api-group>/` folder, where `<api-group>` is the name of your API group. Queries cannot have subfolders; each query belongs to its API group.
8
+
9
+ ## Query Structure
10
+
11
+ A query file consists of:
12
+
13
+ - The query name and HTTP verb (e.g., `products verb=GET`)
14
+ - An optional `description` field
15
+ - An `input` block for request parameters
16
+ - A `stack` block for processing logic
17
+ - A `response` block for returned data
18
+
19
+ ## Authentication
20
+
21
+ By default a query will be public. To require authentication, add an `auth` field with the name of the table to use for authentication (this would usually be a `user` table). When `auth` is set, the variable `$auth.id` will contain the authenticated user's ID. Xano offers built-in JWT authentication endpoint to signup, login and retrieve your user information. Endpoints requiring authentication expect the JWT token to be sent in the `Authorization` header as a Bearer token.
22
+
23
+ ## Example Query
24
+
25
+ The following script would be stored in `apis/product/products.xs`, which means its API group would be `product`. It requires authentication and returns a list of products filtered by category.
26
+
27
+ ```xs
28
+ query "products" verb=GET {
29
+ description = "Returns a list of products filtered by category, requires user authentication"
30
+ auth = "user"
31
+
32
+ input {
33
+ text category filters=trim {
34
+ description = "Product category to filter by"
35
+ }
36
+ }
37
+ stack {
38
+ var $category_filter {
39
+ value = $input.category
40
+ }
41
+ conditional {
42
+ if (($category_filter|strlen) > 0) {
43
+ db.query "product" {
44
+ where = ($db.product.category|to_lower) == ($category_filter|to_lower)
45
+ } as $filtered_products
46
+ }
47
+ else {
48
+ db.query "product" {
49
+ } as $filtered_products
50
+ }
51
+ }
52
+ }
53
+ response = $filtered_products
54
+ }
55
+ ```
56
+
57
+ ## Input Block
58
+
59
+ Defines the parameters accepted by the API endpoint. You can specify:
60
+
61
+ - Data types (`int`, `text`, `decimal`, etc.)
62
+ - Optional fields (add `?`)
63
+ - Filters (e.g., `trim`, `lower`)
64
+ - Metadata (`description`, `sensitive`)
65
+
66
+ **Example:**
67
+
68
+ ```xs
69
+ input {
70
+ int page?=1 {
71
+ description = "Page number for pagination"
72
+ }
73
+ int per_page?=10 {
74
+ description = "Items per page"
75
+ }
76
+ }
77
+ ```
78
+
79
+ ## Stack Block
80
+
81
+ Contains the logic for processing the request, such as:
82
+
83
+ - Variable declarations (`var`)
84
+ - Control flow (`conditional`, `for`, `foreach`)
85
+ - Database operations (`db.query`, `db.add`)
86
+ - Function calls (`function.run`)
87
+ - Logging (`debug.log`)
88
+ - Error handling (`throw`, `try_catch`)
89
+
90
+ ## Response Content Type
91
+
92
+ By default the response type is "application/json", to return a web page set the response type to "text/html" using the `util.set_header` statement:
93
+
94
+ ```xs
95
+ util.set_header {
96
+ value = "Content-Type: text/html; charset=utf-8"
97
+ duplicates = "replace"
98
+ }
99
+ ```
100
+
101
+ ## Response Block
102
+
103
+ Specifies the data returned by the API. The value can be a variable, object, or expression.
104
+
105
+ **Example:**
106
+
107
+ ```xs
108
+ response = $filtered_products
109
+ ```
110
+
111
+ ## Best Practices
112
+
113
+ - Use `description` for documentation.
114
+ - Validate inputs with filters and `precondition` blocks.
115
+ - Place all logic inside the `stack` block.
116
+ - Always define a `response` block for output.
117
+ - Use pagination and sorting for large datasets.
118
+
119
+ ## Summary
120
+
121
+ - Always place a query in under an API group folder.
122
+ - To create a new API group, just create a folder under `apis/`.
123
+ - Place queries in the `apis/<api-group>/` folder.
124
+ - Use `input` for request parameters.
125
+ - Use `stack` for processing logic.
126
+ - Use `response` for returned data.
127
+ - Document your query with `description` fields.
128
+
129
+ For more examples, see the documentation or sample queries in your