@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.
- package/LICENSE +21 -0
- package/README.md +261 -0
- package/api_docs/addon.md +193 -0
- package/api_docs/agent.md +154 -0
- package/api_docs/api_group.md +236 -0
- package/api_docs/authentication.md +68 -0
- package/api_docs/file.md +190 -0
- package/api_docs/function.md +217 -0
- package/api_docs/history.md +263 -0
- package/api_docs/index.md +104 -0
- package/api_docs/mcp_server.md +139 -0
- package/api_docs/middleware.md +205 -0
- package/api_docs/realtime.md +153 -0
- package/api_docs/table.md +151 -0
- package/api_docs/task.md +191 -0
- package/api_docs/tool.md +216 -0
- package/api_docs/triggers.md +344 -0
- package/api_docs/workspace.md +246 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +495 -0
- package/package.json +49 -0
- package/xanoscript_docs/README.md +1 -0
- package/xanoscript_docs/api_query_examples.md +1255 -0
- package/xanoscript_docs/api_query_guideline.md +129 -0
- package/xanoscript_docs/build_from_lovable.md +715 -0
- package/xanoscript_docs/db_query_guideline.md +427 -0
- package/xanoscript_docs/ephemeral_environment_guideline.md +529 -0
- package/xanoscript_docs/expression_guideline.md +1086 -0
- package/xanoscript_docs/frontend_guideline.md +67 -0
- package/xanoscript_docs/function_examples.md +1406 -0
- package/xanoscript_docs/function_guideline.md +130 -0
- package/xanoscript_docs/functions.md +2155 -0
- package/xanoscript_docs/input_guideline.md +227 -0
- package/xanoscript_docs/mcp_server_examples.md +36 -0
- package/xanoscript_docs/mcp_server_guideline.md +69 -0
- package/xanoscript_docs/query_filter.md +489 -0
- package/xanoscript_docs/table_examples.md +586 -0
- package/xanoscript_docs/table_guideline.md +137 -0
- package/xanoscript_docs/task_examples.md +511 -0
- package/xanoscript_docs/task_guideline.md +103 -0
- package/xanoscript_docs/tips_and_tricks.md +144 -0
- package/xanoscript_docs/tool_examples.md +69 -0
- package/xanoscript_docs/tool_guideline.md +139 -0
- package/xanoscript_docs/unit_testing_guideline.md +328 -0
- package/xanoscript_docs/version.json +3 -0
- package/xanoscript_docs/workspace.md +17 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# XanoScript Input Guidelines
|
|
2
|
+
|
|
3
|
+
This document provides comprehensive guidelines for defining and utilizing inputs in XanoScript queries and functions. Adhere to these principles when generating or reviewing XanoScript code to facilitate reliable API endpoints, reusable functions.
|
|
4
|
+
|
|
5
|
+
## Core Principles
|
|
6
|
+
|
|
7
|
+
- **Explicitness**: Always specify data types, optionality, and constraints to prevent runtime errors and enhance readability.
|
|
8
|
+
- **Validation**: Use filters and preconditions to enforce data integrity early in the execution flow.
|
|
9
|
+
- **Security**: Mark sensitive fields (e.g., passwords, emails) explicitly and apply appropriate filters (e.g., `lower` for emails).
|
|
10
|
+
- **Documentation**: Include a `description` for every input field to clarify its purpose and expected format.
|
|
11
|
+
- **Conciseness**: Avoid redundant validation; leverage defaults and filters where appropriate.
|
|
12
|
+
|
|
13
|
+
Inputs are defined within the `input` block of `query` or `function` declarations. The `response` block remains unaffected by inputs, focusing solely on outputs.
|
|
14
|
+
|
|
15
|
+
```xs
|
|
16
|
+
function "foo" {
|
|
17
|
+
input {
|
|
18
|
+
...
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
stack {
|
|
22
|
+
...
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
response = null
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Input Structure
|
|
30
|
+
|
|
31
|
+
The `input` block accepts a series of field definitions, each following this syntax:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
<type> <field_name>[?]? [filters=<filter_list>] {
|
|
35
|
+
description = "<explanation>"
|
|
36
|
+
[sensitive = true/false]
|
|
37
|
+
[table = "<table_name>"]
|
|
38
|
+
[schema { ... }] // For nested objects
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
- **`<type>`**: Specifies the data type (see Types section below).
|
|
43
|
+
- **`?` (nullable marker)**: Append one `?` to the type for nullable fields (`int?` can be `null`).
|
|
44
|
+
- **`<field_name>`**: A descriptive identifier (e.g., `user_id`).
|
|
45
|
+
- **`?` (optional marker)**: Append one `?` to the field name for optional fields (not required).
|
|
46
|
+
- **`?=<default>`**: Alternatively from the single `?`, use `?=<value>` to set a default value for optional fields.
|
|
47
|
+
- **`filters=`**: Pipe-separated list of transformations or validations (e.g., `filters=trim|lower|min:1`).
|
|
48
|
+
- **`description`**: Optional but recommended explanatory text.
|
|
49
|
+
- **`sensitive`**: Boolean flag for logging/masking sensitive data from the logs (default: false).
|
|
50
|
+
- **`table`**: Links to a database table for foreign key validation (e.g., primary keys).
|
|
51
|
+
- **`schema`**: Nested block used by the `object` type to enforce structure.
|
|
52
|
+
|
|
53
|
+
### Nullable vs Optional
|
|
54
|
+
|
|
55
|
+
The first `?` on the type indicates the field can be of the given type or `null` (nullable).
|
|
56
|
+
The second `?` on the field name indicates it is optional (not required).
|
|
57
|
+
|
|
58
|
+
Examples:
|
|
59
|
+
|
|
60
|
+
```xs
|
|
61
|
+
input {
|
|
62
|
+
text? required_and_nullable {
|
|
63
|
+
description = "Can be null but must be provided"
|
|
64
|
+
}
|
|
65
|
+
text required_and_not_nullable {
|
|
66
|
+
description = "Must be provided and cannot be null"
|
|
67
|
+
}
|
|
68
|
+
text? not_required_and_nullable? {
|
|
69
|
+
description = "Can be null and is optional"
|
|
70
|
+
}
|
|
71
|
+
text not_required_and_not_nullable? {
|
|
72
|
+
description = "Must be provided but cannot be null"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Arrays
|
|
78
|
+
|
|
79
|
+
Denote arrays with `[]` after the type (e.g., `int[]` for an array of integers). To limit the number of elements, use a range (e.g., `int[1:10]`). Filters apply element-wise.
|
|
80
|
+
|
|
81
|
+
```xs
|
|
82
|
+
input {
|
|
83
|
+
int[1:10] max_10_scores? filters=min:0|max:100 {
|
|
84
|
+
description = "Accepts between 1 and 10 scores between 0 and 100"
|
|
85
|
+
}
|
|
86
|
+
text[] tags? filters=trim|lower|ok:abcdefghijklmnopqrstuvwxyz0123456789, {
|
|
87
|
+
description = "Array of tags, each trimmed and lowercased"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Defaults
|
|
93
|
+
|
|
94
|
+
Assign defaults with `?=<value>` (e.g., `int page?=1`).
|
|
95
|
+
|
|
96
|
+
```xs
|
|
97
|
+
input {
|
|
98
|
+
int page?=1 filters=min:1 {
|
|
99
|
+
description = "Page number, defaults to 1"
|
|
100
|
+
}
|
|
101
|
+
int page_size?=20 filters=min:1|max:100 {
|
|
102
|
+
description = "Page size, defaults to 20, max 100"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Supported Types
|
|
108
|
+
|
|
109
|
+
The following types are accepted. Select based on the expected data format to enable automatic parsing and validation:
|
|
110
|
+
|
|
111
|
+
| Type | Description | Example Usage |
|
|
112
|
+
| ---------------- | ---------------------------------------------------------------------- | ------------------------------------------------- |
|
|
113
|
+
| `int` | Signed 32-bit integer. | `int user_id` |
|
|
114
|
+
| `decimal` | Floating-point number with arbitrary precision. | `decimal price filters=min:0` |
|
|
115
|
+
| `text` | Arbitrary string (UTF-8). | `text title filters=trim` |
|
|
116
|
+
| `email` | Validated email address. | `email contact_email sensitive=true` |
|
|
117
|
+
| `password` | Secure string for credentials (hashed internally). | `password api_key filters=min:12` |
|
|
118
|
+
| `bool` | Boolean (true/false). | `bool is_active?=true` |
|
|
119
|
+
| `timestamp` | Epoch milliseconds (UTC) or ISO string. | `timestamp created_at` |
|
|
120
|
+
| `date` | ISO date string (YYYY-MM-DD). | `date birth_date` |
|
|
121
|
+
| `uuid` | Universally unique identifier (validated format). | `uuid session_id?` |
|
|
122
|
+
| `json` | Parsed JSON object or array. | `json metadata` |
|
|
123
|
+
| `vector` | Fixed-size numeric array for embeddings (specify dimension if needed). | `vector embedding` |
|
|
124
|
+
| `dblink` | Database-linked object (auto-populates from table). | `dblink { table = "orders" }` |
|
|
125
|
+
| `enum` | Restricted to predefined values. | `enum status { values = ["active", "inactive"] }` |
|
|
126
|
+
| `file` | File resource (accepts URL or data URI). | `file avatar` |
|
|
127
|
+
| `image` | Image file (subset of `file` with validation). | `image profile_photo` |
|
|
128
|
+
| `video` | Video file. | `video tutorial` |
|
|
129
|
+
| `audio` | Audio file. | `audio recording` |
|
|
130
|
+
| `attachment` | Generic file attachment. | `attachment document` |
|
|
131
|
+
| `geo_point` | Geographic point (lat, lng). | `geo_point location` |
|
|
132
|
+
| `geo_multipoint` | Array of geographic points. | `geo_multipoint points` |
|
|
133
|
+
| `geo_linestring` | Line string of coordinates. | `geo_linestring path` |
|
|
134
|
+
| `geo_polygon` | Closed polygon of coordinates. | `geo_polygon boundary` |
|
|
135
|
+
|
|
136
|
+
For arrays: Append `[]` (e.g., `decimal[] scores`).
|
|
137
|
+
|
|
138
|
+
For nested objects: Use `object` with a `schema` sub-block. For example we could define a `person` object like this:
|
|
139
|
+
|
|
140
|
+
```xs
|
|
141
|
+
input {
|
|
142
|
+
object person? {
|
|
143
|
+
schema {
|
|
144
|
+
enum gender?=undisclosed {
|
|
145
|
+
description = "Gender identity, defaults to undisclosed"
|
|
146
|
+
values = ["undisclosed", "male", "female"]
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
text name filters=trim {
|
|
150
|
+
description = "Full name (required)"
|
|
151
|
+
}
|
|
152
|
+
int age? {
|
|
153
|
+
description = "Age in years (optional)"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Filters and Transformations
|
|
161
|
+
|
|
162
|
+
Filters process inputs declaratively. Chain them with `|` (e.g., `filters=trim|lower|min:1|max:100`). Common filters include:
|
|
163
|
+
|
|
164
|
+
| Filter | Purpose | Example |
|
|
165
|
+
| --------------------- | -------------------------------------------- | -------------------------------------- |
|
|
166
|
+
| `trim` | Remove leading/trailing whitespace. | `text name filters=trim` |
|
|
167
|
+
| `lower` | Convert to lowercase. | `email addr filters=lower` |
|
|
168
|
+
| `upper` | Convert to uppercase. | `text code filters=upper` |
|
|
169
|
+
| `min:<value>` | Enforce minimum value (numeric or length). | `int age filters=min:18` |
|
|
170
|
+
| `max:<value>` | Enforce maximum value. | `text desc filters=max:500` |
|
|
171
|
+
| `startsWith:<prefix>` | Require string prefix. | `text code filters=startsWith:ABC` |
|
|
172
|
+
| `ok:<pattern>` | Allow only matching characters (regex-like). | `text hex filters=ok:abcdef0123456789` |
|
|
173
|
+
| `prevent:<substring>` | Block specific substrings. | `text msg filters=prevent:spam` |
|
|
174
|
+
| `digitOk` | Permit only digits (for arrays/strings). | `text[] nums filters=digitOk` |
|
|
175
|
+
| `alphaOk` | Permit only alphabetic characters. | `text name filters=alphaOk` |
|
|
176
|
+
|
|
177
|
+
- **Array-Specific**: Filters like `count:min:5|max:20` apply to array length.
|
|
178
|
+
- **Chaining Order**: Filters execute left-to-right; transformations (e.g., `trim`) precede validations (e.g., `min`).
|
|
179
|
+
- **Custom Validation**: For complex rules, use `precondition` in the `stack` block post-input.
|
|
180
|
+
|
|
181
|
+
## Validation and Error Handling
|
|
182
|
+
|
|
183
|
+
- **Built-in**: Filters trigger `inputerror` exceptions on failure (this is the preferred method).
|
|
184
|
+
- **Preconditions**: In the `stack` (when validating complex rules), for example if we wanted to ensure that a provided start date is before an end date we could do:
|
|
185
|
+
|
|
186
|
+
```xs
|
|
187
|
+
precondition ($input.start_date < $input.end_date) {
|
|
188
|
+
description = "Start date must be before end date"
|
|
189
|
+
error_type = "inputerror"
|
|
190
|
+
error = "Start date must be before end date"
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
- **Error Types**: Use `inputerror` for validation, `accessdenied` for auth-related issues.
|
|
195
|
+
- **Sensitive Handling**: Set `sensitive=true` on input fields to mask in logs/responses.
|
|
196
|
+
|
|
197
|
+
## Best Practices
|
|
198
|
+
|
|
199
|
+
1. **Optionality**: Default to required fields; use `?` sparingly to avoid null-handling complexity.
|
|
200
|
+
2. **Arrays and Loops**: For array inputs, pair with `for` or `foreach` in `stack` for iteration.
|
|
201
|
+
3. **Database Integration**: Use `table` for foreign keys to auto-validate against schemas.
|
|
202
|
+
4. **Testing**: Include `test` blocks in functions/queries to verify input scenarios:
|
|
203
|
+
|
|
204
|
+
```xs
|
|
205
|
+
test "valid input" {
|
|
206
|
+
input = {
|
|
207
|
+
field: "value"
|
|
208
|
+
}
|
|
209
|
+
expect.to_equal ($response) {
|
|
210
|
+
value = "expected"
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
5. **Performance**: Limit array sizes with `max` filters; avoid large vectors without pagination.
|
|
216
|
+
6. **Security**: Always filter user inputs; never trust raw data.
|
|
217
|
+
7. **Nesting**: Limit schema depth to 2-3 levels to prevent over-complexity.
|
|
218
|
+
|
|
219
|
+
## Common Pitfalls
|
|
220
|
+
|
|
221
|
+
- **Missing Descriptions**: Omitting `description` reduces code clarity—always include.
|
|
222
|
+
- **Filter Misordering**: Validate after transformation (e.g., `trim` before `strlen`).
|
|
223
|
+
- **Type Mismatches**: Enforce types strictly; use `decimal` over `int` for precision.
|
|
224
|
+
- **Null Propagation**: Optional fields can cascade nulls—handle in `conditional` blocks.
|
|
225
|
+
- **No Comments**: Use `description` exclusively; the input section does not support inline comments.
|
|
226
|
+
|
|
227
|
+
By following these guidelines, inputs will be robust, self-documenting, and aligned with XanoScript's declarative paradigm. For advanced usage, refer to the full syntax reference. If discrepancies arise, prioritize schema consistency across related files.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: "mcp_servers/**/*.xs"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## MCP Server with Tools
|
|
6
|
+
|
|
7
|
+
This example shows a basic MCP server configuration that exposes two tools.
|
|
8
|
+
|
|
9
|
+
```xs
|
|
10
|
+
mcp_server "My Mcp Server" {
|
|
11
|
+
description = "An example MCP server."
|
|
12
|
+
canonical = "u3D7kj5Q"
|
|
13
|
+
instructions = "General guidelines for AI agents about this server's overall purpose and usage context. These instructions apply server-wide and are separate from individual tool descriptions and parameters."
|
|
14
|
+
tags = ["sample_tag"]
|
|
15
|
+
tools = [
|
|
16
|
+
{ name: "new_statements" },
|
|
17
|
+
{ name: "what_is_xano" }
|
|
18
|
+
]
|
|
19
|
+
history = "inherit"
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## MCP Server without Tools
|
|
24
|
+
|
|
25
|
+
This example shows an MCP server that does not yet have any tools configured.
|
|
26
|
+
|
|
27
|
+
```xs
|
|
28
|
+
mcp_server "Empty Mcp Server" {
|
|
29
|
+
description = "An MCP server with no tools yet."
|
|
30
|
+
canonical = "a1B2c3D4"
|
|
31
|
+
instructions = "This server is currently under development and does not yet have any tools available."
|
|
32
|
+
tags = ["development"]
|
|
33
|
+
tools = []
|
|
34
|
+
history = "inherit"
|
|
35
|
+
}
|
|
36
|
+
```
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: "mcp_servers/**/*.xs"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# How to Define MCP Servers in XanoScript
|
|
6
|
+
|
|
7
|
+
MCP (Model Context Protocol) servers in Xano are the gateways that expose your AI Tools to external clients and AI models. They act as a standardized endpoint that AI-powered applications can connect to, discover available tools, and execute them.
|
|
8
|
+
|
|
9
|
+
MCP Servers are defined in `.xs` files within the `mcp_servers/` directory of your project. For example, you might have a file named `mcp_servers/task_manager_mcp.xs` that contains the definition of an MCP server dedicated to task management:
|
|
10
|
+
|
|
11
|
+
```xs
|
|
12
|
+
mcp_server "Task Manager MCP" {
|
|
13
|
+
canonical = "1TuBS8V2"
|
|
14
|
+
instructions = "Manages tasks specifically for the user, all tools directly relate to the users records in the database. "
|
|
15
|
+
tags = ["internal"]
|
|
16
|
+
tools = [
|
|
17
|
+
{name: "add_task"}
|
|
18
|
+
{name: "delete_task"}
|
|
19
|
+
{name: "edit_task"}
|
|
20
|
+
{name: "get_user_tasks"}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Core MCP Server Syntax
|
|
26
|
+
|
|
27
|
+
Every MCP server is defined within an `mcp_server` block.
|
|
28
|
+
|
|
29
|
+
```xs
|
|
30
|
+
mcp_server "MCP Server Display Name" {
|
|
31
|
+
canonical = "unique-server-id"
|
|
32
|
+
description = "A brief explanation of what this server is for."
|
|
33
|
+
instructions = "These instructions apply server-wide and guide the AI on how to use the collection of tools."
|
|
34
|
+
tags = ["tag1", "tag2"]
|
|
35
|
+
tools = [
|
|
36
|
+
{ name: "tool-name-1" },
|
|
37
|
+
{ name: "tool-name-2" }
|
|
38
|
+
]
|
|
39
|
+
history = "inherit"
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- **`mcp_server "Name"`**: The top-level declaration. The name is a human-readable string.
|
|
44
|
+
- **`canonical`**: A required unique, non-changeable string identifier for the server.
|
|
45
|
+
- **`description`**: An optional string for internal documentation. This is not broadcast with the server.
|
|
46
|
+
- **`instructions`**: A string containing general guidelines for AI agents about the server's overall purpose and usage context.
|
|
47
|
+
- **`tags`**: An optional list of strings for categorizing and organizing your servers.
|
|
48
|
+
- **`tools`**: A required list of objects, where each object references an AI Tool by its unique name.
|
|
49
|
+
|
|
50
|
+
## Tools Block
|
|
51
|
+
|
|
52
|
+
The `tools` block is a list that specifies the tools exposed by the MCP server:
|
|
53
|
+
|
|
54
|
+
```xs
|
|
55
|
+
tools = [
|
|
56
|
+
{ name: "get_user_details_by_email" },
|
|
57
|
+
{ name: "cancel_subscription" },
|
|
58
|
+
{ name: "create_support_ticket" }
|
|
59
|
+
]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The value of the `name` key must be an exact match the unique name of a tool defined in your `tools/` directory, see [Tool Guideline](./tool_guideline.md) for more information.
|
|
63
|
+
|
|
64
|
+
## Best Practices
|
|
65
|
+
|
|
66
|
+
- **Use a Clear Naming Convention**: Give your servers a descriptive name and a memorable canonical ID.
|
|
67
|
+
- **Write Comprehensive Instructions**: The server-level `instructions` should provide a high-level overview of what the collection of tools can accomplish. For example, "A set of tools for managing customer support tickets, including creating, updating, and closing tickets."
|
|
68
|
+
- **Group Related Tools**: Create logical groupings of tools within a single MCP server. For instance, a `user-management-server` could contain tools for creating, updating, and deleting users.
|
|
69
|
+
- **Use Tags for Organization**: Use tags to categorize your servers, making them easier to manage in a large project.
|