@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,263 @@
|
|
|
1
|
+
# History & Audit Logs API
|
|
2
|
+
|
|
3
|
+
View execution history and audit logs for various resources.
|
|
4
|
+
|
|
5
|
+
## History Endpoints
|
|
6
|
+
|
|
7
|
+
| Resource | List Endpoint | Search Endpoint |
|
|
8
|
+
|----------|---------------|-----------------|
|
|
9
|
+
| Request | `/workspace/{workspace_id}/request_history` | `.../request_history/search` |
|
|
10
|
+
| Function | `/workspace/{workspace_id}/function_history` | `.../function_history/search` |
|
|
11
|
+
| Task | `/workspace/{workspace_id}/task_history` | `.../task_history/search` |
|
|
12
|
+
| Middleware | `/workspace/{workspace_id}/middleware_history` | `.../middleware_history/search` |
|
|
13
|
+
| Tool | `/workspace/{workspace_id}/tool_history` | `.../tool_history/search` |
|
|
14
|
+
| Trigger | `/workspace/{workspace_id}/trigger_history` | `.../trigger_history/search` |
|
|
15
|
+
|
|
16
|
+
## Audit Log Endpoints
|
|
17
|
+
|
|
18
|
+
| Method | Endpoint | Description |
|
|
19
|
+
|--------|----------|-------------|
|
|
20
|
+
| GET | `/workspace/{workspace_id}/audit_log` | Workspace audit logs |
|
|
21
|
+
| GET | `/audit_log` | All audit logs (paid only) |
|
|
22
|
+
| POST | `/workspace/{workspace_id}/audit_log/search` | Search workspace logs |
|
|
23
|
+
| POST | `/audit_log/search` | Search all logs (paid only) |
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Request History
|
|
28
|
+
|
|
29
|
+
## List Request History
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
GET /workspace/{workspace_id}/request_history
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Query Parameters:**
|
|
36
|
+
| Parameter | Type | Default | Description |
|
|
37
|
+
|-----------|------|---------|-------------|
|
|
38
|
+
| `page` | int | 1 | Page number |
|
|
39
|
+
| `per_page` | int | 50 | Items per page (1-500) |
|
|
40
|
+
| `branch` | text | "" | Branch label |
|
|
41
|
+
| `apigroup_id` | int | 0 | Filter by API group ID |
|
|
42
|
+
| `query_id` | int | 0 | Filter by API endpoint ID |
|
|
43
|
+
| `include_output` | bool | false | Include response output |
|
|
44
|
+
|
|
45
|
+
## Search Request History
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
POST /workspace/{workspace_id}/request_history/search
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Parameters:**
|
|
52
|
+
| Parameter | Type | Default | Description |
|
|
53
|
+
|-----------|------|---------|-------------|
|
|
54
|
+
| `page` | int | 1 | Page number |
|
|
55
|
+
| `per_page` | int | 50 | Items per page (1-500) |
|
|
56
|
+
| `branch` | text | "" | Branch label |
|
|
57
|
+
| `apigroup_id` | int | 0 | Filter by API group |
|
|
58
|
+
| `query_id` | int | 0 | Filter by endpoint |
|
|
59
|
+
| `search` | json | [] | Search filters |
|
|
60
|
+
| `sort` | json | [] | Sort configuration |
|
|
61
|
+
| `include_output` | bool | false | Include response output |
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
# Function History
|
|
66
|
+
|
|
67
|
+
## List Function History
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
GET /workspace/{workspace_id}/function_history
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Query Parameters:**
|
|
74
|
+
| Parameter | Type | Default | Description |
|
|
75
|
+
|-----------|------|---------|-------------|
|
|
76
|
+
| `page` | int | 1 | Page number |
|
|
77
|
+
| `per_page` | int | 50 | Items per page (1-500) |
|
|
78
|
+
| `branch` | text | "" | Branch label |
|
|
79
|
+
| `function_id` | int | 0 | Filter by function ID |
|
|
80
|
+
| `include_output` | bool | false | Include response output |
|
|
81
|
+
|
|
82
|
+
## Search Function History
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
POST /workspace/{workspace_id}/function_history/search
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
# Task History
|
|
91
|
+
|
|
92
|
+
## List Task History
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
GET /workspace/{workspace_id}/task_history
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Query Parameters:**
|
|
99
|
+
| Parameter | Type | Default | Description |
|
|
100
|
+
|-----------|------|---------|-------------|
|
|
101
|
+
| `page` | int | 1 | Page number |
|
|
102
|
+
| `per_page` | int | 50 | Items per page (1-500) |
|
|
103
|
+
| `branch` | text | "" | Branch label |
|
|
104
|
+
| `task_id` | int | 0 | Filter by task ID |
|
|
105
|
+
| `include_output` | bool | false | Include response output |
|
|
106
|
+
|
|
107
|
+
## Search Task History
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
POST /workspace/{workspace_id}/task_history/search
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
# Middleware History
|
|
116
|
+
|
|
117
|
+
## List Middleware History
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
GET /workspace/{workspace_id}/middleware_history
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Query Parameters:**
|
|
124
|
+
| Parameter | Type | Default | Description |
|
|
125
|
+
|-----------|------|---------|-------------|
|
|
126
|
+
| `page` | int | 1 | Page number |
|
|
127
|
+
| `per_page` | int | 50 | Items per page (1-500) |
|
|
128
|
+
| `branch` | text | "" | Branch label |
|
|
129
|
+
| `middleware_id` | int | 0 | Filter by middleware ID |
|
|
130
|
+
| `query_id` | int | 0 | Filter by API endpoint ID |
|
|
131
|
+
| `function_id` | int | 0 | Filter by function ID |
|
|
132
|
+
| `task_id` | int | 0 | Filter by task ID |
|
|
133
|
+
| `include_output` | bool | false | Include response output |
|
|
134
|
+
|
|
135
|
+
## Search Middleware History
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
POST /workspace/{workspace_id}/middleware_history/search
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
# Tool History
|
|
144
|
+
|
|
145
|
+
## List Tool History
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
GET /workspace/{workspace_id}/tool_history
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**Query Parameters:**
|
|
152
|
+
| Parameter | Type | Default | Description |
|
|
153
|
+
|-----------|------|---------|-------------|
|
|
154
|
+
| `page` | int | 1 | Page number |
|
|
155
|
+
| `per_page` | int | 50 | Items per page (1-500) |
|
|
156
|
+
| `branch` | text | "" | Branch label |
|
|
157
|
+
| `tool_id` | int | 0 | Filter by tool ID |
|
|
158
|
+
| `include_output` | bool | false | Include response output |
|
|
159
|
+
|
|
160
|
+
## Search Tool History
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
POST /workspace/{workspace_id}/tool_history/search
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
# Trigger History
|
|
169
|
+
|
|
170
|
+
## List Trigger History
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
GET /workspace/{workspace_id}/trigger_history
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Query Parameters:**
|
|
177
|
+
| Parameter | Type | Default | Description |
|
|
178
|
+
|-----------|------|---------|-------------|
|
|
179
|
+
| `page` | int | 1 | Page number |
|
|
180
|
+
| `per_page` | int | 50 | Items per page (1-500) |
|
|
181
|
+
| `trigger_id` | int | 0 | Filter by trigger ID |
|
|
182
|
+
| `include_output` | bool | false | Include response output |
|
|
183
|
+
|
|
184
|
+
## Search Trigger History
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
POST /workspace/{workspace_id}/trigger_history/search
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
# Audit Logs
|
|
193
|
+
|
|
194
|
+
## List Workspace Audit Logs
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
GET /workspace/{workspace_id}/audit_log
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Query Parameters:**
|
|
201
|
+
| Parameter | Type | Default | Description |
|
|
202
|
+
|-----------|------|---------|-------------|
|
|
203
|
+
| `page` | int | 1 | Page number |
|
|
204
|
+
| `per_page` | int | 50 | Items per page (1-10000) |
|
|
205
|
+
| `include_data` | bool | false | Include full log data |
|
|
206
|
+
|
|
207
|
+
## List All Audit Logs
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
GET /audit_log
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Note:** Requires paid plan.
|
|
214
|
+
|
|
215
|
+
Same parameters as workspace audit logs.
|
|
216
|
+
|
|
217
|
+
## Search Workspace Audit Logs
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
POST /workspace/{workspace_id}/audit_log/search
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Parameters:**
|
|
224
|
+
| Parameter | Type | Default | Description |
|
|
225
|
+
|-----------|------|---------|-------------|
|
|
226
|
+
| `page` | int | 1 | Page number |
|
|
227
|
+
| `per_page` | int | 50 | Items per page (1-500) |
|
|
228
|
+
| `include_data` | bool | false | Include full log data |
|
|
229
|
+
| `search` | json | [] | Search filters |
|
|
230
|
+
| `sort` | json | [] | Sort configuration |
|
|
231
|
+
|
|
232
|
+
## Search All Audit Logs
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
POST /audit_log/search
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Note:** Requires paid plan.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
# Response Fields
|
|
243
|
+
|
|
244
|
+
## History Entries
|
|
245
|
+
|
|
246
|
+
| Field | Type | Description |
|
|
247
|
+
|-------|------|-------------|
|
|
248
|
+
| `id` | int | History entry ID |
|
|
249
|
+
| `created_at` | timestamp | Execution timestamp |
|
|
250
|
+
| `duration` | int | Execution duration in ms |
|
|
251
|
+
| `status` | int | HTTP status code |
|
|
252
|
+
| `input` | json | Request input |
|
|
253
|
+
| `output` | json | Response output (if requested) |
|
|
254
|
+
|
|
255
|
+
## Audit Log Entries
|
|
256
|
+
|
|
257
|
+
| Field | Type | Description |
|
|
258
|
+
|-------|------|-------------|
|
|
259
|
+
| `id` | int | Log entry ID |
|
|
260
|
+
| `created_at` | timestamp | Event timestamp |
|
|
261
|
+
| `action` | text | Action performed |
|
|
262
|
+
| `user` | object | User who performed action |
|
|
263
|
+
| `data` | json | Additional event data (if requested) |
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Xano Headless API Documentation
|
|
2
|
+
|
|
3
|
+
## How to Use This Documentation
|
|
4
|
+
|
|
5
|
+
This documentation is accessed via the `api_docs` MCP tool. Use the `object` parameter to get detailed documentation for specific API resources.
|
|
6
|
+
|
|
7
|
+
### Available Object Values
|
|
8
|
+
|
|
9
|
+
| Object | Description |
|
|
10
|
+
|--------|-------------|
|
|
11
|
+
| `workspace` | Workspace management, branches, datasources, export/import, OpenAPI specs |
|
|
12
|
+
| `table` | Database table schema management with XanoScript |
|
|
13
|
+
| `api_group` | API groups and endpoints management |
|
|
14
|
+
| `function` | Reusable function library |
|
|
15
|
+
| `task` | Scheduled tasks (cron jobs) |
|
|
16
|
+
| `middleware` | Request/response middleware |
|
|
17
|
+
| `addon` | Reusable query addons for response transformation |
|
|
18
|
+
| `agent` | AI agent configuration |
|
|
19
|
+
| `tool` | AI tool definitions for agents |
|
|
20
|
+
| `mcp_server` | Model Context Protocol server management |
|
|
21
|
+
| `realtime` | Realtime WebSocket channels |
|
|
22
|
+
| `triggers` | Event-driven triggers (table, workspace, agent, MCP, realtime) |
|
|
23
|
+
| `file` | File uploads and static hosting |
|
|
24
|
+
| `history` | Request history and audit logs |
|
|
25
|
+
| `authentication` | User authentication and session info |
|
|
26
|
+
|
|
27
|
+
### Example Usage
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
// Get overview (this document)
|
|
31
|
+
api_docs()
|
|
32
|
+
|
|
33
|
+
// Get specific documentation
|
|
34
|
+
api_docs({ object: "table" })
|
|
35
|
+
api_docs({ object: "api_group" })
|
|
36
|
+
api_docs({ object: "function" })
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## API Overview
|
|
42
|
+
|
|
43
|
+
The Xano Headless API uses **XanoScript** as the primary input/output format for most mutation operations.
|
|
44
|
+
|
|
45
|
+
### Base URL
|
|
46
|
+
All API endpoints are relative to your Xano instance's headless API base URL.
|
|
47
|
+
|
|
48
|
+
### Content Types
|
|
49
|
+
- **Mutations** (POST/PUT): `text/x-xanoscript`
|
|
50
|
+
- **Responses**: `application/json`
|
|
51
|
+
|
|
52
|
+
### Common Patterns
|
|
53
|
+
|
|
54
|
+
#### Pagination
|
|
55
|
+
```
|
|
56
|
+
GET /resource?page=1&per_page=50
|
|
57
|
+
```
|
|
58
|
+
Response:
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"curPage": 1,
|
|
62
|
+
"nextPage": 2,
|
|
63
|
+
"prevPage": null,
|
|
64
|
+
"items": [...]
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### Branch Targeting
|
|
69
|
+
Most endpoints support `?branch=<label>` (empty = live branch)
|
|
70
|
+
|
|
71
|
+
#### Sorting
|
|
72
|
+
- `sort`: Field name (varies by endpoint)
|
|
73
|
+
- `order`: `asc` or `desc`
|
|
74
|
+
|
|
75
|
+
#### Search
|
|
76
|
+
- `search`: Text search filter
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Resource Categories
|
|
81
|
+
|
|
82
|
+
### Core Resources
|
|
83
|
+
- **Workspace** - Container for all Xano resources
|
|
84
|
+
- **Table** - Database tables with schema definitions
|
|
85
|
+
- **API Group** - Groups of related API endpoints
|
|
86
|
+
|
|
87
|
+
### Logic & Code
|
|
88
|
+
- **Function** - Reusable code blocks
|
|
89
|
+
- **Middleware** - Request/response processing
|
|
90
|
+
- **Addon** - Response transformation queries
|
|
91
|
+
- **Task** - Scheduled jobs
|
|
92
|
+
|
|
93
|
+
### AI & Integrations
|
|
94
|
+
- **Agent** - AI-powered assistants
|
|
95
|
+
- **Tool** - Functions callable by AI agents
|
|
96
|
+
- **MCP Server** - Model Context Protocol servers
|
|
97
|
+
|
|
98
|
+
### Events & Realtime
|
|
99
|
+
- **Triggers** - Event-driven automation
|
|
100
|
+
- **Realtime** - WebSocket channels
|
|
101
|
+
|
|
102
|
+
### Files & Observability
|
|
103
|
+
- **File** - File storage and static hosting
|
|
104
|
+
- **History** - Execution logs and audit trails
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# MCP Server API
|
|
2
|
+
|
|
3
|
+
MCP (Model Context Protocol) Servers provide a standardized way to expose tools and resources to AI models. They allow external AI applications to interact with your Xano workspace.
|
|
4
|
+
|
|
5
|
+
## Endpoints Overview
|
|
6
|
+
|
|
7
|
+
| Method | Endpoint | Description |
|
|
8
|
+
|--------|----------|-------------|
|
|
9
|
+
| GET | `/workspace/{workspace_id}/mcp_server` | List MCP servers |
|
|
10
|
+
| GET | `/workspace/{workspace_id}/mcp_server/{mcp_server_id}` | Get MCP server |
|
|
11
|
+
| POST | `/workspace/{workspace_id}/mcp_server` | Create MCP server |
|
|
12
|
+
| PUT | `/workspace/{workspace_id}/mcp_server/{mcp_server_id}` | Update MCP server |
|
|
13
|
+
| DELETE | `/workspace/{workspace_id}/mcp_server/{mcp_server_id}` | Delete MCP server |
|
|
14
|
+
| GET | `/mcp_server/documentation` | Get XanoScript documentation |
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## List MCP Servers
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
GET /workspace/{workspace_id}/mcp_server
|
|
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
|
+
| `tools` | bool | true | Include tool information |
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Get MCP Server
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
GET /workspace/{workspace_id}/mcp_server/{mcp_server_id}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Query Parameters:**
|
|
44
|
+
- `tools` (bool, default: true): Include tool information
|
|
45
|
+
|
|
46
|
+
Returns MCP server definition including XanoScript.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Create MCP Server
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
POST /workspace/{workspace_id}/mcp_server
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Content-Type:** `text/x-xanoscript`
|
|
57
|
+
|
|
58
|
+
**Query Parameters:**
|
|
59
|
+
- `branch` (text): Target branch label
|
|
60
|
+
- `tools` (bool): Include tool information in response
|
|
61
|
+
|
|
62
|
+
### XanoScript MCP Server Syntax
|
|
63
|
+
|
|
64
|
+
```xanoscript
|
|
65
|
+
mcp_server foo {
|
|
66
|
+
description = "test"
|
|
67
|
+
canonical = "custom"
|
|
68
|
+
tags = ["test"]
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Fields
|
|
73
|
+
|
|
74
|
+
| Field | Type | Description |
|
|
75
|
+
|-------|------|-------------|
|
|
76
|
+
| `description` | text | Human-readable description |
|
|
77
|
+
| `canonical` | text | Unique canonical identifier |
|
|
78
|
+
| `tags` | array | Tags for categorization |
|
|
79
|
+
|
|
80
|
+
### Example: Data Access MCP Server
|
|
81
|
+
|
|
82
|
+
```xanoscript
|
|
83
|
+
mcp_server data_access {
|
|
84
|
+
description = "Provides read access to customer data"
|
|
85
|
+
canonical = "customer-data"
|
|
86
|
+
tags = ["data", "customer", "read-only"]
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Example: Admin MCP Server
|
|
91
|
+
|
|
92
|
+
```xanoscript
|
|
93
|
+
mcp_server admin_tools {
|
|
94
|
+
description = "Administrative tools for workspace management"
|
|
95
|
+
canonical = "admin"
|
|
96
|
+
tags = ["admin", "management", "internal"]
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Update MCP Server
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
PUT /workspace/{workspace_id}/mcp_server/{mcp_server_id}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Query Parameters:**
|
|
109
|
+
- `publish` (bool, default: true): Publish changes immediately
|
|
110
|
+
- `tools` (bool, default: true): Include tool information in response
|
|
111
|
+
|
|
112
|
+
**Content-Type:** `text/x-xanoscript`
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Delete MCP Server
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
DELETE /workspace/{workspace_id}/mcp_server/{mcp_server_id}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Warning:** This action cannot be undone.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Get MCP Documentation
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
GET /mcp_server/documentation
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Provides comprehensive XanoScript syntax documentation.
|
|
133
|
+
|
|
134
|
+
**Query Parameters:**
|
|
135
|
+
| Parameter | Type | Default | Description |
|
|
136
|
+
|-----------|------|---------|-------------|
|
|
137
|
+
| `type` | text | "start" | Documentation type/section |
|
|
138
|
+
|
|
139
|
+
This endpoint is useful for AI models to learn XanoScript syntax dynamically.
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# Middleware API
|
|
2
|
+
|
|
3
|
+
Middleware are reusable code blocks that run before or after API endpoints. They add common functionality like authentication, logging, or request/response transformation.
|
|
4
|
+
|
|
5
|
+
## Endpoints Overview
|
|
6
|
+
|
|
7
|
+
| Method | Endpoint | Description |
|
|
8
|
+
|--------|----------|-------------|
|
|
9
|
+
| GET | `/workspace/{workspace_id}/middleware` | List middlewares |
|
|
10
|
+
| GET | `/workspace/{workspace_id}/middleware/{middleware_id}` | Get middleware |
|
|
11
|
+
| POST | `/workspace/{workspace_id}/middleware` | Create middleware |
|
|
12
|
+
| PUT | `/workspace/{workspace_id}/middleware/{middleware_id}` | Update middleware |
|
|
13
|
+
| DELETE | `/workspace/{workspace_id}/middleware/{middleware_id}` | Delete middleware |
|
|
14
|
+
| PUT | `/workspace/{workspace_id}/middleware/{middleware_id}/security` | Update security |
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## List Middlewares
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
GET /workspace/{workspace_id}/middleware
|
|
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 Middleware
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
GET /workspace/{workspace_id}/middleware/{middleware_id}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Returns middleware definition including XanoScript.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Create Middleware
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
POST /workspace/{workspace_id}/middleware
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Content-Type:** `text/x-xanoscript`
|
|
53
|
+
|
|
54
|
+
**Query Parameters:**
|
|
55
|
+
- `branch` (text): Target branch label
|
|
56
|
+
|
|
57
|
+
### XanoScript Middleware Syntax
|
|
58
|
+
|
|
59
|
+
Middleware follows the same syntax as functions:
|
|
60
|
+
|
|
61
|
+
```xanoscript
|
|
62
|
+
middleware 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
|
+
### Common Use Cases
|
|
78
|
+
|
|
79
|
+
#### Authentication Check
|
|
80
|
+
|
|
81
|
+
```xanoscript
|
|
82
|
+
middleware auth_check {
|
|
83
|
+
input {
|
|
84
|
+
text token?
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
stack {
|
|
88
|
+
// Validate token
|
|
89
|
+
if $input.token == null {
|
|
90
|
+
precondition.abort {
|
|
91
|
+
status = 401
|
|
92
|
+
message = "Unauthorized"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Decode and verify token
|
|
97
|
+
var $user {
|
|
98
|
+
value = decode_jwt($input.token)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
response = $user
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
#### Request Logging
|
|
107
|
+
|
|
108
|
+
```xanoscript
|
|
109
|
+
middleware request_logger {
|
|
110
|
+
input {
|
|
111
|
+
text endpoint
|
|
112
|
+
json body?
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
stack {
|
|
116
|
+
db.insert request_log {
|
|
117
|
+
data = {
|
|
118
|
+
endpoint: $input.endpoint,
|
|
119
|
+
body: $input.body,
|
|
120
|
+
timestamp: now()
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
response = true
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### Rate Limiting
|
|
130
|
+
|
|
131
|
+
```xanoscript
|
|
132
|
+
middleware rate_limit {
|
|
133
|
+
input {
|
|
134
|
+
text client_ip
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
stack {
|
|
138
|
+
// Count recent requests
|
|
139
|
+
db.query rate_limit {
|
|
140
|
+
where = $db.rate_limit.ip == $input.client_ip
|
|
141
|
+
&& $db.rate_limit.timestamp > now() - 60
|
|
142
|
+
return = {type: "count"}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if $rate_limit > 100 {
|
|
146
|
+
precondition.abort {
|
|
147
|
+
status = 429
|
|
148
|
+
message = "Too many requests"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Log this request
|
|
153
|
+
db.insert rate_limit {
|
|
154
|
+
data = {ip: $input.client_ip, timestamp: now()}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
response = true
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Use Cases
|
|
163
|
+
|
|
164
|
+
- Authentication and authorization
|
|
165
|
+
- Request logging
|
|
166
|
+
- Rate limiting
|
|
167
|
+
- Request/response transformation
|
|
168
|
+
- Error handling
|
|
169
|
+
- CORS headers
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Update Middleware
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
PUT /workspace/{workspace_id}/middleware/{middleware_id}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Query Parameters:**
|
|
180
|
+
- `publish` (bool, default: true): Publish changes immediately
|
|
181
|
+
|
|
182
|
+
**Content-Type:** `text/x-xanoscript`
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Delete Middleware
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
DELETE /workspace/{workspace_id}/middleware/{middleware_id}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Warning:** This action cannot be undone. Any API groups using this middleware will no longer have it applied.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Update Middleware Security
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
PUT /workspace/{workspace_id}/middleware/{middleware_id}/security
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Parameters:**
|
|
203
|
+
| Parameter | Type | Required | Description |
|
|
204
|
+
|-----------|------|----------|-------------|
|
|
205
|
+
| `guid` | text | Yes | New security GUID |
|