@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,153 @@
|
|
|
1
|
+
# Realtime API
|
|
2
|
+
|
|
3
|
+
Realtime channels enable real-time bidirectional communication between clients using WebSockets. They support features like presence, message history, and private messaging.
|
|
4
|
+
|
|
5
|
+
## Endpoints Overview
|
|
6
|
+
|
|
7
|
+
| Method | Endpoint | Description |
|
|
8
|
+
|--------|----------|-------------|
|
|
9
|
+
| GET | `/workspace/{workspace_id}/realtime/channel` | List channels |
|
|
10
|
+
| GET | `/workspace/{workspace_id}/realtime/channel/{channel_id}` | Get channel |
|
|
11
|
+
| POST | `/workspace/{workspace_id}/realtime/channel` | Create channel |
|
|
12
|
+
| PUT | `/workspace/{workspace_id}/realtime/channel/{channel_id}` | Update channel |
|
|
13
|
+
| DELETE | `/workspace/{workspace_id}/realtime/channel/{channel_id}` | Delete channel |
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## List Realtime Channels
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
GET /workspace/{workspace_id}/realtime/channel
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Query Parameters:**
|
|
24
|
+
| Parameter | Type | Default | Description |
|
|
25
|
+
|-----------|------|---------|-------------|
|
|
26
|
+
| `page` | int | 1 | Page number |
|
|
27
|
+
| `per_page` | int | 50 | Items per page (1-10000) |
|
|
28
|
+
| `search` | text | "" | Search filter |
|
|
29
|
+
| `sort` | enum | "name" | Sort field: "name" |
|
|
30
|
+
| `order` | enum | "desc" | Sort order |
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Get Realtime Channel
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
GET /workspace/{workspace_id}/realtime/channel/{channel_id}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Returns channel definition including XanoScript.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Create Realtime Channel
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
POST /workspace/{workspace_id}/realtime/channel
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Content-Type:** `text/x-xanoscript`
|
|
51
|
+
|
|
52
|
+
### XanoScript Realtime Channel Syntax
|
|
53
|
+
|
|
54
|
+
```xanoscript
|
|
55
|
+
realtime_channel foo {
|
|
56
|
+
public_messaging = {active: false}
|
|
57
|
+
private_messaging = {active: false}
|
|
58
|
+
settings = {
|
|
59
|
+
anonymous_clients: false
|
|
60
|
+
nested_channels : false
|
|
61
|
+
message_history : 0
|
|
62
|
+
auth_channel : false
|
|
63
|
+
presence : false
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Messaging Options
|
|
69
|
+
|
|
70
|
+
| Field | Type | Description |
|
|
71
|
+
|-------|------|-------------|
|
|
72
|
+
| `public_messaging` | object | Configure public message broadcasting |
|
|
73
|
+
| `private_messaging` | object | Configure private direct messages |
|
|
74
|
+
|
|
75
|
+
### Settings
|
|
76
|
+
|
|
77
|
+
| Field | Type | Description |
|
|
78
|
+
|-------|------|-------------|
|
|
79
|
+
| `anonymous_clients` | bool | Allow connections without authentication |
|
|
80
|
+
| `nested_channels` | bool | Allow sub-channels (e.g., `chat/room1`) |
|
|
81
|
+
| `message_history` | int | Messages to keep in history (0 = disabled) |
|
|
82
|
+
| `auth_channel` | bool | Require authentication for channel access |
|
|
83
|
+
| `presence` | bool | Track online/offline status of users |
|
|
84
|
+
|
|
85
|
+
### Example: Chat Room Channel
|
|
86
|
+
|
|
87
|
+
```xanoscript
|
|
88
|
+
realtime_channel chat {
|
|
89
|
+
public_messaging = {active: true}
|
|
90
|
+
private_messaging = {active: true}
|
|
91
|
+
settings = {
|
|
92
|
+
anonymous_clients: false
|
|
93
|
+
nested_channels : true
|
|
94
|
+
message_history : 100
|
|
95
|
+
auth_channel : true
|
|
96
|
+
presence : true
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Example: Notifications Channel
|
|
102
|
+
|
|
103
|
+
```xanoscript
|
|
104
|
+
realtime_channel notifications {
|
|
105
|
+
public_messaging = {active: true}
|
|
106
|
+
private_messaging = {active: false}
|
|
107
|
+
settings = {
|
|
108
|
+
anonymous_clients: false
|
|
109
|
+
nested_channels : false
|
|
110
|
+
message_history : 50
|
|
111
|
+
auth_channel : true
|
|
112
|
+
presence : false
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Example: Public Broadcast Channel
|
|
118
|
+
|
|
119
|
+
```xanoscript
|
|
120
|
+
realtime_channel announcements {
|
|
121
|
+
public_messaging = {active: true}
|
|
122
|
+
private_messaging = {active: false}
|
|
123
|
+
settings = {
|
|
124
|
+
anonymous_clients: true
|
|
125
|
+
nested_channels : false
|
|
126
|
+
message_history : 10
|
|
127
|
+
auth_channel : false
|
|
128
|
+
presence : false
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Update Realtime Channel
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
PUT /workspace/{workspace_id}/realtime/channel/{channel_id}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Content-Type:** `text/x-xanoscript`
|
|
142
|
+
|
|
143
|
+
Send complete channel definition.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Delete Realtime Channel
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
DELETE /workspace/{workspace_id}/realtime/channel/{channel_id}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Warning:** This action cannot be undone. All connected clients will be disconnected.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Table API
|
|
2
|
+
|
|
3
|
+
Tables are database objects that store structured data. Tables are defined using XanoScript with schema definitions, indexes, and constraints.
|
|
4
|
+
|
|
5
|
+
## Endpoints Overview
|
|
6
|
+
|
|
7
|
+
| Method | Endpoint | Description |
|
|
8
|
+
|--------|----------|-------------|
|
|
9
|
+
| GET | `/workspace/{workspace_id}/table` | List all tables |
|
|
10
|
+
| GET | `/workspace/{workspace_id}/table/{table_id}` | Get table details |
|
|
11
|
+
| POST | `/workspace/{workspace_id}/table` | Create table |
|
|
12
|
+
| PUT | `/workspace/{workspace_id}/table/{table_id}` | Update table |
|
|
13
|
+
| DELETE | `/workspace/{workspace_id}/table/{table_id}` | Delete table |
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## List Tables
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
GET /workspace/{workspace_id}/table
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Query Parameters:**
|
|
24
|
+
| Parameter | Type | Default | Description |
|
|
25
|
+
|-----------|------|---------|-------------|
|
|
26
|
+
| `page` | int | 1 | Page number |
|
|
27
|
+
| `per_page` | int | 50 | Items per page (1-10000) |
|
|
28
|
+
| `search` | text | "" | Search filter |
|
|
29
|
+
| `sort` | enum | "name" | Sort: "created_at", "updated_at", "name" |
|
|
30
|
+
| `order` | enum | "asc" | Sort order: "asc", "desc" |
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Get Table
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
GET /workspace/{workspace_id}/table/{table_id}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Returns table definition including schema, indexes, and XanoScript.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Create Table
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
POST /workspace/{workspace_id}/table
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Content-Type:** `text/x-xanoscript`
|
|
51
|
+
|
|
52
|
+
### XanoScript Table Syntax
|
|
53
|
+
|
|
54
|
+
```xanoscript
|
|
55
|
+
table book {
|
|
56
|
+
schema {
|
|
57
|
+
int id
|
|
58
|
+
text title
|
|
59
|
+
text description
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
index = [
|
|
63
|
+
{type: "primary", field: [{name: "id"}]}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Schema Field Types
|
|
69
|
+
|
|
70
|
+
| Type | Description |
|
|
71
|
+
|------|-------------|
|
|
72
|
+
| `int` | Integer |
|
|
73
|
+
| `text` | Text/string |
|
|
74
|
+
| `bool` | Boolean |
|
|
75
|
+
| `float` | Floating point number |
|
|
76
|
+
| `timestamp` | Timestamp/datetime |
|
|
77
|
+
| `date` | Date only |
|
|
78
|
+
| `time` | Time only |
|
|
79
|
+
| `json` | JSON object |
|
|
80
|
+
| `uuid` | UUID string |
|
|
81
|
+
| `enum` | Enumerated values |
|
|
82
|
+
| `object` | Nested object |
|
|
83
|
+
| `object[]` | Array of objects |
|
|
84
|
+
|
|
85
|
+
### Field Modifiers
|
|
86
|
+
|
|
87
|
+
| Modifier | Syntax | Description |
|
|
88
|
+
|----------|--------|-------------|
|
|
89
|
+
| Optional | `field_name?` | Nullable field |
|
|
90
|
+
| Default | `default = value` | Default value |
|
|
91
|
+
|
|
92
|
+
### Index Types
|
|
93
|
+
|
|
94
|
+
| Type | Description |
|
|
95
|
+
|------|-------------|
|
|
96
|
+
| `primary` | Primary key index |
|
|
97
|
+
| `unique` | Unique constraint |
|
|
98
|
+
| `index` | Regular index |
|
|
99
|
+
| `fulltext` | Full-text search index |
|
|
100
|
+
|
|
101
|
+
### Complete Example
|
|
102
|
+
|
|
103
|
+
```xanoscript
|
|
104
|
+
table user {
|
|
105
|
+
schema {
|
|
106
|
+
int id
|
|
107
|
+
text email
|
|
108
|
+
text password
|
|
109
|
+
text name?
|
|
110
|
+
timestamp created_at
|
|
111
|
+
bool active default = true
|
|
112
|
+
enum role {
|
|
113
|
+
values = ["admin", "user", "guest"]
|
|
114
|
+
default = "user"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
index = [
|
|
119
|
+
{type: "primary", field: [{name: "id"}]},
|
|
120
|
+
{type: "unique", field: [{name: "email"}]},
|
|
121
|
+
{type: "index", field: [{name: "created_at"}]}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Update Table
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
PUT /workspace/{workspace_id}/table/{table_id}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Content-Type:** `text/x-xanoscript`
|
|
135
|
+
|
|
136
|
+
Send complete table definition with updated schema.
|
|
137
|
+
|
|
138
|
+
**Notes:**
|
|
139
|
+
- Schema changes may trigger database migrations
|
|
140
|
+
- Removing fields or changing types may result in data loss
|
|
141
|
+
- Adding new fields typically requires default values for existing rows
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Delete Table
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
DELETE /workspace/{workspace_id}/table/{table_id}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**Warning:** This action cannot be undone. All data in the table will be permanently deleted.
|
package/api_docs/task.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# Task API
|
|
2
|
+
|
|
3
|
+
Tasks are scheduled jobs that run automatically based on a cron-like schedule. They are defined using XanoScript.
|
|
4
|
+
|
|
5
|
+
**Note:** Task functionality is restricted to paid accounts.
|
|
6
|
+
|
|
7
|
+
## Endpoints Overview
|
|
8
|
+
|
|
9
|
+
| Method | Endpoint | Description |
|
|
10
|
+
|--------|----------|-------------|
|
|
11
|
+
| GET | `/workspace/{workspace_id}/task` | List tasks |
|
|
12
|
+
| GET | `/workspace/{workspace_id}/task/{task_id}` | Get task |
|
|
13
|
+
| POST | `/workspace/{workspace_id}/task` | Create task |
|
|
14
|
+
| PUT | `/workspace/{workspace_id}/task/{task_id}` | Update task |
|
|
15
|
+
| DELETE | `/workspace/{workspace_id}/task/{task_id}` | Delete task |
|
|
16
|
+
| PUT | `/workspace/{workspace_id}/task/{task_id}/security` | Update security |
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## List Tasks
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
GET /workspace/{workspace_id}/task
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Query Parameters:**
|
|
27
|
+
| Parameter | Type | Default | Description |
|
|
28
|
+
|-----------|------|---------|-------------|
|
|
29
|
+
| `branch` | text | "" | Branch label |
|
|
30
|
+
| `page` | int | 1 | Page number |
|
|
31
|
+
| `per_page` | int | 50 | Items per page (1-10000) |
|
|
32
|
+
| `search` | text | "" | Search filter |
|
|
33
|
+
| `sort` | enum | "created_at" | Sort field |
|
|
34
|
+
| `order` | enum | "desc" | Sort order |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Get Task
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
GET /workspace/{workspace_id}/task/{task_id}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Returns task definition including schedule and XanoScript.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Create Task
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
POST /workspace/{workspace_id}/task
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Content-Type:** `text/x-xanoscript`
|
|
55
|
+
|
|
56
|
+
**Query Parameters:**
|
|
57
|
+
- `branch` (text): Target branch label
|
|
58
|
+
|
|
59
|
+
### XanoScript Task Syntax
|
|
60
|
+
|
|
61
|
+
```xanoscript
|
|
62
|
+
task foo {
|
|
63
|
+
stack {
|
|
64
|
+
var $x1 {
|
|
65
|
+
value = 1
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
schedule = [{starts_on: 2025-10-28 18:03:58+0000, freq: 900}]
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Stack Section
|
|
74
|
+
|
|
75
|
+
The task logic (same syntax as functions):
|
|
76
|
+
|
|
77
|
+
```xanoscript
|
|
78
|
+
stack {
|
|
79
|
+
db.query user {
|
|
80
|
+
where = $db.user.active == false
|
|
81
|
+
return = {type: "list"}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
foreach $user as $u {
|
|
85
|
+
// Process each user
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Schedule Section
|
|
91
|
+
|
|
92
|
+
#### Inline Format
|
|
93
|
+
```xanoscript
|
|
94
|
+
schedule = [{
|
|
95
|
+
starts_on: 2025-10-28 18:03:58+0000,
|
|
96
|
+
freq: 900
|
|
97
|
+
}]
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### Block Format
|
|
101
|
+
```xanoscript
|
|
102
|
+
schedule {
|
|
103
|
+
events = [{
|
|
104
|
+
starts_on: 2025-07-25 20:00:12+0000,
|
|
105
|
+
freq: 900
|
|
106
|
+
}]
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Schedule Options
|
|
111
|
+
|
|
112
|
+
| Field | Description |
|
|
113
|
+
|-------|-------------|
|
|
114
|
+
| `starts_on` | ISO timestamp when schedule begins |
|
|
115
|
+
| `freq` | Frequency in seconds between runs |
|
|
116
|
+
|
|
117
|
+
### Common Frequencies
|
|
118
|
+
|
|
119
|
+
| Seconds | Interval |
|
|
120
|
+
|---------|----------|
|
|
121
|
+
| 60 | Every minute |
|
|
122
|
+
| 300 | Every 5 minutes |
|
|
123
|
+
| 900 | Every 15 minutes |
|
|
124
|
+
| 3600 | Every hour |
|
|
125
|
+
| 86400 | Every day |
|
|
126
|
+
|
|
127
|
+
### Complete Example
|
|
128
|
+
|
|
129
|
+
```xanoscript
|
|
130
|
+
task cleanup_expired_sessions {
|
|
131
|
+
stack {
|
|
132
|
+
// Find expired sessions
|
|
133
|
+
db.query session {
|
|
134
|
+
where = $db.session.expires_at < now()
|
|
135
|
+
return = {type: "list"}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Delete each expired session
|
|
139
|
+
foreach $session as $s {
|
|
140
|
+
db.delete session {
|
|
141
|
+
where = $db.session.id == $s.id
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
var $deleted_count {
|
|
146
|
+
value = count($session)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
schedule = [{
|
|
151
|
+
starts_on: 2025-01-01 00:00:00+0000,
|
|
152
|
+
freq: 3600
|
|
153
|
+
}]
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Update Task
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
PUT /workspace/{workspace_id}/task/{task_id}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Query Parameters:**
|
|
166
|
+
- `publish` (bool, default: true): Publish changes immediately
|
|
167
|
+
|
|
168
|
+
**Content-Type:** `text/x-xanoscript`
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Delete Task
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
DELETE /workspace/{workspace_id}/task/{task_id}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Warning:** This action cannot be undone.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Update Task Security
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
PUT /workspace/{workspace_id}/task/{task_id}/security
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Parameters:**
|
|
189
|
+
| Parameter | Type | Required | Description |
|
|
190
|
+
|-----------|------|----------|-------------|
|
|
191
|
+
| `guid` | text | Yes | New security GUID |
|
package/api_docs/tool.md
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Tool API
|
|
2
|
+
|
|
3
|
+
Tools are functions that AI agents can call to perform actions. They extend agent capabilities by allowing them to interact with databases, external APIs, and perform computations.
|
|
4
|
+
|
|
5
|
+
## Endpoints Overview
|
|
6
|
+
|
|
7
|
+
| Method | Endpoint | Description |
|
|
8
|
+
|--------|----------|-------------|
|
|
9
|
+
| GET | `/workspace/{workspace_id}/tool` | List tools |
|
|
10
|
+
| GET | `/workspace/{workspace_id}/tool/{tool_id}` | Get tool |
|
|
11
|
+
| POST | `/workspace/{workspace_id}/tool` | Create tool |
|
|
12
|
+
| PUT | `/workspace/{workspace_id}/tool/{tool_id}` | Update tool |
|
|
13
|
+
| DELETE | `/workspace/{workspace_id}/tool/{tool_id}` | Delete tool |
|
|
14
|
+
| PUT | `/workspace/{workspace_id}/tool/{tool_id}/security` | Update security |
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## List Tools
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
GET /workspace/{workspace_id}/tool
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Query Parameters:**
|
|
25
|
+
| Parameter | Type | Default | Description |
|
|
26
|
+
|-----------|------|---------|-------------|
|
|
27
|
+
| `branch` | text | "" | Branch label |
|
|
28
|
+
| `page` | int | 1 | Page number |
|
|
29
|
+
| `per_page` | int | 50 | Items per page (1-10000) |
|
|
30
|
+
| `search` | text | "" | Search filter |
|
|
31
|
+
| `sort` | enum | "created_at" | Sort field |
|
|
32
|
+
| `order` | enum | "desc" | Sort order |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Get Tool
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
GET /workspace/{workspace_id}/tool/{tool_id}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Returns tool definition including XanoScript.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Create Tool
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
POST /workspace/{workspace_id}/tool
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Content-Type:** `text/x-xanoscript`
|
|
53
|
+
|
|
54
|
+
**Query Parameters:**
|
|
55
|
+
- `branch` (text): Target branch label
|
|
56
|
+
|
|
57
|
+
### XanoScript Tool Syntax
|
|
58
|
+
|
|
59
|
+
Tools follow the same syntax as functions, with input, stack, and response sections:
|
|
60
|
+
|
|
61
|
+
```xanoscript
|
|
62
|
+
tool foo {
|
|
63
|
+
input {
|
|
64
|
+
int score
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
stack {
|
|
68
|
+
var $x1 {
|
|
69
|
+
value = $input.score + 1
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
response = $x1
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Input Section
|
|
78
|
+
|
|
79
|
+
Define parameters the agent can pass to the tool. Include descriptions for AI understanding:
|
|
80
|
+
|
|
81
|
+
```xanoscript
|
|
82
|
+
input {
|
|
83
|
+
text user_id {
|
|
84
|
+
description = "The user's unique identifier"
|
|
85
|
+
}
|
|
86
|
+
text query {
|
|
87
|
+
description = "Search query string"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Stack Section
|
|
93
|
+
|
|
94
|
+
The logic that executes when the tool is called:
|
|
95
|
+
|
|
96
|
+
```xanoscript
|
|
97
|
+
stack {
|
|
98
|
+
db.query user {
|
|
99
|
+
where = $db.user.id == $input.user_id
|
|
100
|
+
return = {type: "single"}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Example: Database Lookup Tool
|
|
106
|
+
|
|
107
|
+
```xanoscript
|
|
108
|
+
tool get_user_orders {
|
|
109
|
+
input {
|
|
110
|
+
int user_id {
|
|
111
|
+
description = "The ID of the user to look up orders for"
|
|
112
|
+
}
|
|
113
|
+
int limit? {
|
|
114
|
+
description = "Maximum number of orders to return"
|
|
115
|
+
default = 10
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
stack {
|
|
120
|
+
db.query order {
|
|
121
|
+
where = $db.order.user_id == $input.user_id
|
|
122
|
+
limit = $input.limit
|
|
123
|
+
order = {created_at: "desc"}
|
|
124
|
+
return = {type: "list"}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
response = $order
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Example: External API Tool
|
|
133
|
+
|
|
134
|
+
```xanoscript
|
|
135
|
+
tool search_products {
|
|
136
|
+
input {
|
|
137
|
+
text query {
|
|
138
|
+
description = "Product search query"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
stack {
|
|
143
|
+
external.api_call {
|
|
144
|
+
url = "https://api.example.com/search"
|
|
145
|
+
method = "GET"
|
|
146
|
+
params = {q: $input.query}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
response = $api_result
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Example: Data Processing Tool
|
|
155
|
+
|
|
156
|
+
```xanoscript
|
|
157
|
+
tool calculate_statistics {
|
|
158
|
+
input {
|
|
159
|
+
int[] values {
|
|
160
|
+
description = "Array of numbers to analyze"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
stack {
|
|
165
|
+
var $sum { value = sum($input.values) }
|
|
166
|
+
var $count { value = count($input.values) }
|
|
167
|
+
var $avg { value = $sum / $count }
|
|
168
|
+
var $min { value = min($input.values) }
|
|
169
|
+
var $max { value = max($input.values) }
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
response = {
|
|
173
|
+
sum: $sum,
|
|
174
|
+
count: $count,
|
|
175
|
+
average: $avg,
|
|
176
|
+
min: $min,
|
|
177
|
+
max: $max
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Update Tool
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
PUT /workspace/{workspace_id}/tool/{tool_id}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Query Parameters:**
|
|
191
|
+
- `publish` (bool, default: true): Publish changes immediately
|
|
192
|
+
|
|
193
|
+
**Content-Type:** `text/x-xanoscript`
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Delete Tool
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
DELETE /workspace/{workspace_id}/tool/{tool_id}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Warning:** This action cannot be undone. Any agents using this tool will no longer have access to it.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Update Tool Security
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
PUT /workspace/{workspace_id}/tool/{tool_id}/security
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Parameters:**
|
|
214
|
+
| Parameter | Type | Required | Description |
|
|
215
|
+
|-----------|------|----------|-------------|
|
|
216
|
+
| `guid` | text | Yes | New security GUID |
|