@xano/developer-mcp 1.0.75 → 2.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 (127) hide show
  1. package/README.md +104 -37
  2. package/dist/cli_docs/index.d.ts +13 -37
  3. package/dist/cli_docs/index.js +28 -39
  4. package/dist/cli_docs/topics/integration.js +1 -1
  5. package/dist/cli_docs/topics/workspace.js +1 -1
  6. package/dist/index.js +58 -55
  7. package/dist/lib.d.ts +3 -1
  8. package/dist/lib.js +1 -1
  9. package/dist/meta_api_docs/format.js +1 -1
  10. package/dist/meta_api_docs/index.d.ts +14 -42
  11. package/dist/meta_api_docs/index.js +34 -46
  12. package/dist/tools/cli_docs.d.ts +2 -3
  13. package/dist/tools/cli_docs.js +3 -5
  14. package/dist/tools/define_tool.d.ts +47 -0
  15. package/dist/tools/define_tool.js +36 -0
  16. package/dist/tools/index.d.ts +88 -221
  17. package/dist/tools/index.js +80 -109
  18. package/dist/tools/mcp_version.d.ts +4 -25
  19. package/dist/tools/mcp_version.js +12 -19
  20. package/dist/tools/meta_api_docs.d.ts +2 -3
  21. package/dist/tools/meta_api_docs.js +3 -5
  22. package/dist/tools/validate_xanoscript.d.ts +18 -65
  23. package/dist/tools/validate_xanoscript.js +56 -54
  24. package/dist/tools/xanoscript_docs.d.ts +25 -74
  25. package/dist/tools/xanoscript_docs.js +86 -83
  26. package/dist/xanoscript_docs/README.md +5 -5
  27. package/dist/xanoscript_docs/apis.md +2 -2
  28. package/dist/xanoscript_docs/database.md +1 -1
  29. package/dist/xanoscript_docs/essentials.md +6 -6
  30. package/dist/xanoscript_docs/functions.md +3 -3
  31. package/dist/xanoscript_docs/integrations.md +5 -5
  32. package/dist/xanoscript_docs/middleware.md +1 -1
  33. package/dist/xanoscript_docs/performance.md +4 -4
  34. package/dist/xanoscript_docs/realtime.md +2 -2
  35. package/dist/xanoscript_docs/security.md +1 -1
  36. package/dist/xanoscript_docs/survival.md +1 -1
  37. package/dist/xanoscript_docs/syntax/string-filters.md +1 -1
  38. package/dist/xanoscript_docs/syntax.md +9 -9
  39. package/dist/xanoscript_docs/tools.md +2 -2
  40. package/dist/xanoscript_docs/types.md +2 -2
  41. package/dist/xanoscript_docs/unit-testing.md +1 -1
  42. package/dist/xanoscript_docs/workflow-tests.md +1 -1
  43. package/dist/xanoscript_docs/working.md +4 -4
  44. package/package.json +5 -4
  45. package/dist/api_docs/format.d.ts +0 -5
  46. package/dist/api_docs/format.js +0 -171
  47. package/dist/api_docs/index.d.ts +0 -52
  48. package/dist/api_docs/index.js +0 -111
  49. package/dist/api_docs/topics/agent.d.ts +0 -2
  50. package/dist/api_docs/topics/agent.js +0 -142
  51. package/dist/api_docs/topics/api.d.ts +0 -2
  52. package/dist/api_docs/topics/api.js +0 -176
  53. package/dist/api_docs/topics/apigroup.d.ts +0 -2
  54. package/dist/api_docs/topics/apigroup.js +0 -124
  55. package/dist/api_docs/topics/authentication.d.ts +0 -2
  56. package/dist/api_docs/topics/authentication.js +0 -61
  57. package/dist/api_docs/topics/branch.d.ts +0 -2
  58. package/dist/api_docs/topics/branch.js +0 -73
  59. package/dist/api_docs/topics/file.d.ts +0 -2
  60. package/dist/api_docs/topics/file.js +0 -70
  61. package/dist/api_docs/topics/function.d.ts +0 -2
  62. package/dist/api_docs/topics/function.js +0 -164
  63. package/dist/api_docs/topics/history.d.ts +0 -2
  64. package/dist/api_docs/topics/history.js +0 -149
  65. package/dist/api_docs/topics/mcp_server.d.ts +0 -2
  66. package/dist/api_docs/topics/mcp_server.js +0 -139
  67. package/dist/api_docs/topics/middleware.d.ts +0 -2
  68. package/dist/api_docs/topics/middleware.js +0 -156
  69. package/dist/api_docs/topics/realtime.d.ts +0 -2
  70. package/dist/api_docs/topics/realtime.js +0 -112
  71. package/dist/api_docs/topics/start.d.ts +0 -2
  72. package/dist/api_docs/topics/start.js +0 -107
  73. package/dist/api_docs/topics/table.d.ts +0 -2
  74. package/dist/api_docs/topics/table.js +0 -195
  75. package/dist/api_docs/topics/task.d.ts +0 -2
  76. package/dist/api_docs/topics/task.js +0 -165
  77. package/dist/api_docs/topics/tool.d.ts +0 -2
  78. package/dist/api_docs/topics/tool.js +0 -150
  79. package/dist/api_docs/topics/workflows.d.ts +0 -2
  80. package/dist/api_docs/topics/workflows.js +0 -131
  81. package/dist/api_docs/topics/workspace.d.ts +0 -2
  82. package/dist/api_docs/topics/workspace.js +0 -153
  83. package/dist/api_docs/types.d.ts +0 -79
  84. package/dist/api_docs/types.js +0 -4
  85. package/dist/cli_docs/topics/run.d.ts +0 -2
  86. package/dist/cli_docs/topics/run.js +0 -248
  87. package/dist/meta_api_docs/format.test.d.ts +0 -1
  88. package/dist/meta_api_docs/format.test.js +0 -272
  89. package/dist/meta_api_docs/index.test.d.ts +0 -1
  90. package/dist/meta_api_docs/index.test.js +0 -128
  91. package/dist/meta_api_docs/types.test.d.ts +0 -1
  92. package/dist/meta_api_docs/types.test.js +0 -132
  93. package/dist/templates/init-workspace.d.ts +0 -10
  94. package/dist/templates/init-workspace.js +0 -278
  95. package/dist/templates/xanoscript-index.d.ts +0 -11
  96. package/dist/templates/xanoscript-index.js +0 -72
  97. package/dist/tools/index.test.d.ts +0 -1
  98. package/dist/tools/index.test.js +0 -179
  99. package/dist/tools/xanoscript_docs.test.d.ts +0 -1
  100. package/dist/tools/xanoscript_docs.test.js +0 -197
  101. package/dist/xanoscript.test.d.ts +0 -1
  102. package/dist/xanoscript.test.js +0 -421
  103. package/dist/xanoscript_docs/cheatsheet.md +0 -287
  104. package/dist/xanoscript_docs/ephemeral.md +0 -330
  105. package/dist/xanoscript_docs/quickstart.md +0 -692
  106. package/dist/xanoscript_docs/run.md +0 -196
  107. package/dist/xanoscript_docs/schema.md +0 -300
  108. package/dist/xanoscript_docs_auto/README.md +0 -119
  109. package/dist/xanoscript_docs_auto/agents.md +0 -446
  110. package/dist/xanoscript_docs_auto/apis.md +0 -517
  111. package/dist/xanoscript_docs_auto/control-flow.md +0 -543
  112. package/dist/xanoscript_docs_auto/database.md +0 -551
  113. package/dist/xanoscript_docs_auto/debugging.md +0 -527
  114. package/dist/xanoscript_docs_auto/filters.md +0 -464
  115. package/dist/xanoscript_docs_auto/functions.md +0 -431
  116. package/dist/xanoscript_docs_auto/integrations.md +0 -657
  117. package/dist/xanoscript_docs_auto/mcp-servers.md +0 -408
  118. package/dist/xanoscript_docs_auto/operators.md +0 -368
  119. package/dist/xanoscript_docs_auto/syntax.md +0 -287
  120. package/dist/xanoscript_docs_auto/tables.md +0 -447
  121. package/dist/xanoscript_docs_auto/tasks.md +0 -479
  122. package/dist/xanoscript_docs_auto/testing.md +0 -574
  123. package/dist/xanoscript_docs_auto/tools.md +0 -485
  124. package/dist/xanoscript_docs_auto/triggers.md +0 -595
  125. package/dist/xanoscript_docs_auto/types.md +0 -323
  126. package/dist/xanoscript_docs_auto/variables.md +0 -462
  127. package/dist/xanoscript_docs_auto/version.json +0 -5
@@ -1,132 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- describe("meta_api_docs/types", () => {
3
- describe("type structures", () => {
4
- it("should allow valid HttpMethod values", () => {
5
- const methods = ["GET", "POST", "PUT", "PATCH", "DELETE"];
6
- expect(methods).toHaveLength(5);
7
- });
8
- it("should allow valid ParameterDoc structure", () => {
9
- const param = {
10
- name: "id",
11
- type: "integer",
12
- required: true,
13
- default: 1,
14
- description: "The ID",
15
- enum: ["a", "b"],
16
- in: "path",
17
- };
18
- expect(param.name).toBe("id");
19
- expect(param.in).toBe("path");
20
- });
21
- it("should allow minimal ParameterDoc", () => {
22
- const param = {
23
- name: "test",
24
- type: "string",
25
- description: "A test parameter",
26
- };
27
- expect(param.required).toBeUndefined();
28
- });
29
- it("should allow valid RequestBodyDoc structure", () => {
30
- const body = {
31
- type: "object",
32
- description: "Request body",
33
- properties: {
34
- name: { type: "string", required: true, description: "Name" },
35
- },
36
- example: { name: "test" },
37
- };
38
- expect(body.type).toBe("object");
39
- });
40
- it("should allow valid ResponseDoc structure", () => {
41
- const response = {
42
- type: "object",
43
- description: "Response",
44
- properties: { id: { type: "integer" } },
45
- };
46
- expect(response.type).toBe("object");
47
- });
48
- it("should allow valid RequestExampleDoc structure", () => {
49
- const example = {
50
- method: "POST",
51
- path: "/test",
52
- headers: { "Content-Type": "application/json" },
53
- body: { data: "test" },
54
- };
55
- expect(example.method).toBe("POST");
56
- });
57
- it("should allow valid EndpointDoc structure", () => {
58
- const endpoint = {
59
- method: "GET",
60
- path: "/test/{id}",
61
- tool_name: "get_test",
62
- description: "Get a test",
63
- tags: ["test", "example"],
64
- parameters: [
65
- { name: "id", type: "integer", description: "ID" },
66
- ],
67
- request_body: { type: "object" },
68
- response: { type: "object" },
69
- example: { method: "GET", path: "/test/1" },
70
- };
71
- expect(endpoint.method).toBe("GET");
72
- expect(endpoint.tags).toContain("test");
73
- });
74
- it("should allow valid ExampleDoc structure", () => {
75
- const example = {
76
- title: "Example Title",
77
- description: "Example description",
78
- request: {
79
- method: "GET",
80
- path: "/test",
81
- headers: { Authorization: "Bearer token" },
82
- body: undefined,
83
- },
84
- response: { success: true },
85
- };
86
- expect(example.title).toBe("Example Title");
87
- });
88
- it("should allow valid PatternDoc structure", () => {
89
- const pattern = {
90
- name: "Workflow Name",
91
- description: "Workflow description",
92
- steps: ["Step 1", "Step 2"],
93
- example: "example code",
94
- };
95
- expect(pattern.steps).toHaveLength(2);
96
- });
97
- it("should allow valid TopicDoc structure", () => {
98
- const topic = {
99
- topic: "test",
100
- title: "Test Topic",
101
- description: "Test description",
102
- endpoints: [],
103
- examples: [],
104
- related_topics: ["other"],
105
- schemas: { TestSchema: {} },
106
- patterns: [],
107
- ai_hints: "AI hints here",
108
- };
109
- expect(topic.topic).toBe("test");
110
- expect(topic.ai_hints).toBeDefined();
111
- });
112
- it("should allow valid DetailLevel values", () => {
113
- const levels = ["overview", "detailed", "examples"];
114
- expect(levels).toHaveLength(3);
115
- });
116
- it("should allow valid MetaApiDocsArgs structure", () => {
117
- const args = {
118
- topic: "start",
119
- detail_level: "detailed",
120
- include_schemas: true,
121
- };
122
- expect(args.topic).toBe("start");
123
- });
124
- it("should allow minimal MetaApiDocsArgs", () => {
125
- const args = {
126
- topic: "start",
127
- };
128
- expect(args.detail_level).toBeUndefined();
129
- expect(args.include_schemas).toBeUndefined();
130
- });
131
- });
132
- });
@@ -1,10 +0,0 @@
1
- /**
2
- * Template for init_workspace tool documentation
3
- * Edit this file to update the workspace initialization guide
4
- */
5
- export interface ObjectTypeConfig {
6
- type: string;
7
- path: string;
8
- endpoint: string;
9
- }
10
- export declare function generateInitWorkspaceTemplate(objectTypes: ObjectTypeConfig[]): string;
@@ -1,278 +0,0 @@
1
- /**
2
- * Template for init_workspace tool documentation
3
- * Edit this file to update the workspace initialization guide
4
- */
5
- export function generateInitWorkspaceTemplate(objectTypes) {
6
- const objectTypesTable = objectTypes
7
- .map(({ type, path, endpoint }) => `| \`${type}\` | \`${path}/\` | \`${endpoint}\` |`)
8
- .join("\n");
9
- return `# Xano Workspace Initialization Guide
10
-
11
- This guide explains how to set up a local development workspace that syncs with the Xano Headless API.
12
-
13
- ## Directory Structure
14
-
15
- Initialize your workspace with these directories:
16
-
17
- \`\`\`
18
- your-project/
19
- ├── .xano/
20
- │ └── registry.json # Tracks all objects and their sync state
21
- ├── functions/ # Custom reusable functions
22
- │ ├── calculate_total.xs
23
- │ └── validate_email.xs
24
- ├── tables/ # Database table schemas
25
- │ ├── user.xs
26
- │ └── order.xs
27
- ├── tasks/ # Scheduled background tasks
28
- │ └── cleanup_sessions.xs
29
- ├── apis/ # API groups and endpoints
30
- │ └── auth/ # API group directory
31
- │ ├── api_group.xs # Group definition
32
- │ ├── POST_login.xs # Endpoint: POST /auth/login
33
- │ └── GET_me.xs # Endpoint: GET /auth/me
34
- ├── tools/ # AI-callable tools
35
- ├── agents/ # AI agents
36
- ├── middlewares/ # Request/response middleware
37
- ├── addons/ # Query addons
38
- ├── mcp_servers/ # MCP servers
39
- └── realtime/ # Realtime channels
40
- \`\`\`
41
-
42
- ## Object Types
43
-
44
- | Type | Directory | API Endpoint |
45
- |------|-----------|--------------|
46
- ${objectTypesTable}
47
-
48
- ## File Naming Convention
49
-
50
- Files should follow snake_case naming with the \`.xs\` extension:
51
- - \`{name}.xs\` - Basic format (e.g., \`calculate_total.xs\`)
52
- - \`{id}_{name}.xs\` - With ID prefix for disambiguation (e.g., \`42_calculate_total.xs\`)
53
- - API endpoints: \`{VERB}_{path}.xs\` (e.g., \`POST_login.xs\`, \`GET_users_id.xs\`)
54
-
55
- ## Registry Format
56
-
57
- The \`.xano/registry.json\` file tracks the sync state between local files and the Xano API:
58
-
59
- \`\`\`json
60
- {
61
- "workspace_id": 12345,
62
- "workspace_name": "My Project",
63
- "branch": "",
64
- "base_url": "https://your-instance.xano.io/api:headless",
65
- "created_at": "2025-01-15T10:30:00Z",
66
- "updated_at": "2025-01-15T10:30:00Z",
67
- "objects": [
68
- {
69
- "id": 1,
70
- "type": "function",
71
- "name": "calculate_total",
72
- "path": "functions/calculate_total.xs",
73
- "sha256": "abc123...",
74
- "status": "unchanged",
75
- "original": "ZnVuY3Rpb24gY2FsY3VsYXRlX3RvdGFsIHsgLi4uIH0=",
76
- "updated_at": "2025-01-15T10:30:00Z"
77
- },
78
- {
79
- "id": 0,
80
- "type": "function",
81
- "name": "new_function",
82
- "path": "functions/new_function.xs",
83
- "status": "new"
84
- }
85
- ]
86
- }
87
- \`\`\`
88
-
89
- ### Registry Record Fields
90
-
91
- | Field | Description |
92
- |-------|-------------|
93
- | \`id\` | Xano object ID (0 = new, not yet synced) |
94
- | \`type\` | Object type (function, table, task, etc.) |
95
- | \`name\` | Object name extracted from XanoScript |
96
- | \`path\` | Relative file path from workspace root |
97
- | \`sha256\` | SHA256 hash of file content for change detection |
98
- | \`status\` | Sync status: "new", "unchanged", "changed", "deleted" |
99
- | \`original\` | Base64-encoded original content (for conflict detection) |
100
- | \`updated_at\` | Last sync timestamp |
101
-
102
- ### Status Values
103
-
104
- | Status | Description |
105
- |--------|-------------|
106
- | \`new\` | Created locally, not yet pushed to Xano |
107
- | \`unchanged\` | In sync with remote |
108
- | \`changed\` | Modified locally since last sync |
109
- | \`deleted\` | Marked for deletion (file removed locally) |
110
-
111
- ## Fetching Objects from the API
112
-
113
- Use the Headless API to fetch objects.
114
-
115
- ### List Objects
116
-
117
- \`\`\`
118
- GET /workspace/{workspace_id}/{type}
119
- Headers:
120
- Authorization: Bearer {token}
121
-
122
- Query Parameters:
123
- - branch: Branch label (empty = live branch)
124
- - page: Page number (default: 1)
125
- - per_page: Items per page (default: 50, max: 10000)
126
- - search: Text search filter
127
- - sort: Sort field (created_at, updated_at, name)
128
- - order: asc or desc
129
- \`\`\`
130
-
131
- ### Get Single Object with XanoScript
132
-
133
- \`\`\`
134
- GET /workspace/{workspace_id}/{type}/{id}
135
- Headers:
136
- Authorization: Bearer {token}
137
-
138
- Query Parameters:
139
- - branch: Branch label
140
- \`\`\`
141
-
142
- The response includes the \`xanoscript\` field with the code content:
143
- \`\`\`json
144
- {
145
- "id": 1,
146
- "name": "calculate_total",
147
- "xanoscript": {
148
- "status": "ok",
149
- "value": "function calculate_total { ... }"
150
- }
151
- }
152
- \`\`\`
153
-
154
- ### API Endpoints (Nested Under API Groups)
155
-
156
- **Important:** API endpoints are nested resources under API groups. You must first fetch API groups to obtain their IDs, then use those IDs to fetch the endpoints within each group.
157
-
158
- \`\`\`
159
- # 1. First, list API groups
160
- GET /workspace/{workspace_id}/apigroup
161
-
162
- # 2. Then, list endpoints for each group using the apigroup_id
163
- GET /workspace/{workspace_id}/apigroup/{apigroup_id}/api
164
-
165
- # 3. Get a single endpoint
166
- GET /workspace/{workspace_id}/apigroup/{apigroup_id}/api/{api_id}
167
- \`\`\`
168
-
169
- This hierarchical structure is reflected in the local directory layout:
170
- \`\`\`
171
- apis/
172
- └── auth/ # API group (apigroup_id required)
173
- ├── api_group.xs # Group definition
174
- ├── POST_login.xs # Endpoint within this group
175
- └── GET_me.xs # Another endpoint
176
- \`\`\`
177
-
178
- API groups contain endpoints that share common configuration.
179
-
180
- ## Pull Workflow
181
-
182
- 1. **Fetch object list** from API (paginated)
183
- 2. **For each object**, get the full definition including XanoScript
184
- 3. **Generate file path** based on type and name
185
- 4. **Write file** to the appropriate directory
186
- 5. **Update registry** with object metadata and SHA256 hash
187
-
188
- ### Example Pull Request Sequence
189
-
190
- \`\`\`javascript
191
- // 1. List all functions
192
- const response = await fetch(
193
- \`\${baseUrl}/workspace/\${workspaceId}/function?branch=\${branch}&per_page=100\`,
194
- { headers: { Authorization: \`Bearer \${token}\` } }
195
- );
196
- const { items, nextPage } = await response.json();
197
-
198
- // 2. For each function, save to file
199
- for (const func of items) {
200
- const xanoscript = func.xanoscript?.value || '';
201
- const fileName = \`\${snakeCase(func.name)}.xs\`;
202
- const filePath = \`functions/\${fileName}\`;
203
-
204
- // Write file
205
- await writeFile(filePath, xanoscript);
206
-
207
- // Add to registry
208
- registry.objects.push({
209
- id: func.id,
210
- type: 'function',
211
- name: func.name,
212
- path: filePath,
213
- sha256: sha256(xanoscript),
214
- status: 'unchanged',
215
- original: btoa(xanoscript),
216
- updated_at: func.updated_at
217
- });
218
- }
219
- \`\`\`
220
-
221
- ## Push Workflow
222
-
223
- 1. **Read registry** to find changed/new objects
224
- 2. **For each changed file**, read content and detect changes
225
- 3. **Create or update** via API with XanoScript content
226
- 4. **Update registry** with new IDs and hashes
227
-
228
- ### Example Push Request
229
-
230
- \`\`\`javascript
231
- // Create new function
232
- const response = await fetch(
233
- \`\${baseUrl}/workspace/\${workspaceId}/function?branch=\${branch}\`,
234
- {
235
- method: 'POST',
236
- headers: {
237
- 'Authorization': \`Bearer \${token}\`,
238
- 'Content-Type': 'text/x-xanoscript'
239
- },
240
- body: xanoscriptContent
241
- }
242
- );
243
-
244
- // Update existing function
245
- const response = await fetch(
246
- \`\${baseUrl}/workspace/\${workspaceId}/function/\${functionId}?publish=true\`,
247
- {
248
- method: 'PUT',
249
- headers: {
250
- 'Authorization': \`Bearer \${token}\`,
251
- 'Content-Type': 'text/x-xanoscript'
252
- },
253
- body: xanoscriptContent
254
- }
255
- );
256
- \`\`\`
257
-
258
- ## XanoScript Documentation References
259
-
260
- For writing XanoScript code, use:
261
-
262
- - \`xanoscript_docs()\` - Full documentation index
263
- - \`xanoscript_docs({ topic: "functions" })\` - Function syntax
264
- - \`xanoscript_docs({ topic: "tables" })\` - Table schema syntax
265
- - \`xanoscript_docs({ topic: "apis" })\` - API endpoint syntax
266
- - \`xanoscript_docs({ topic: "syntax" })\` - Language reference
267
-
268
- ## Validating XanoScript
269
-
270
- Before pushing changes, validate the XanoScript syntax:
271
-
272
- \`\`\`
273
- validate_xanoscript({ code: "function foo { ... }" })
274
- \`\`\`
275
-
276
- This will check for syntax errors and return line/column positions for any issues.
277
- `;
278
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Template for xanoscript_docs index documentation
3
- * Edit this file to update the XanoScript documentation index
4
- *
5
- * NOTE: This template is currently unused. The actual documentation is served
6
- * directly from the XANOSCRIPT_DOCS_V2 config in index.ts.
7
- */
8
- export interface XanoscriptIndexParams {
9
- version: string;
10
- }
11
- export declare function generateXanoscriptIndexTemplate(params: XanoscriptIndexParams): string;
@@ -1,72 +0,0 @@
1
- /**
2
- * Template for xanoscript_docs index documentation
3
- * Edit this file to update the XanoScript documentation index
4
- *
5
- * NOTE: This template is currently unused. The actual documentation is served
6
- * directly from the XANOSCRIPT_DOCS_V2 config in index.ts.
7
- */
8
- export function generateXanoscriptIndexTemplate(params) {
9
- const { version } = params;
10
- return `# XanoScript Documentation Index
11
- Version: ${version}
12
-
13
- Use \`xanoscript_docs({ topic: "<topic>" })\` to retrieve documentation.
14
-
15
- ## Core Language
16
- | Topic | Description |
17
- |-------|-------------|
18
- | \`syntax\` | Expressions, operators, filters, system variables |
19
- | \`types\` | Data types, validation, input blocks |
20
- | \`functions\` | Reusable function stacks, async, loops |
21
- | \`schema\` | Runtime schema parsing and validation |
22
-
23
- ## Data
24
- | Topic | Description |
25
- |-------|-------------|
26
- | \`tables\` | Database schema definitions with indexes and relationships |
27
- | \`database\` | All db.* operations: query, get, add, edit, patch, delete |
28
- | \`addons\` | Reusable subqueries for fetching related data |
29
- | \`streaming\` | Streaming data from files, requests, and responses |
30
-
31
- ## APIs & Endpoints
32
- | Topic | Description |
33
- |-------|-------------|
34
- | \`apis\` | HTTP endpoint definitions with authentication and CRUD patterns |
35
- | \`tasks\` | Scheduled and cron jobs |
36
- | \`triggers\` | Event-driven handlers (table, realtime, workspace, agent, MCP) |
37
- | \`realtime\` | Real-time channels and events for push updates |
38
-
39
- ## AI & Agents
40
- | Topic | Description |
41
- |-------|-------------|
42
- | \`agents\` | AI agent configuration with LLM providers and tools |
43
- | \`tools\` | AI tools for agents and MCP servers |
44
- | \`mcp-servers\` | MCP server definitions exposing tools |
45
-
46
- ## Integrations
47
- | Topic | Description |
48
- |-------|-------------|
49
- | \`integrations\` | Cloud storage, Redis, security, and external APIs |
50
-
51
- ## Configuration
52
- | Topic | Description |
53
- |-------|-------------|
54
- | \`workspace\` | Workspace-level settings: environment variables, preferences, realtime |
55
- | \`branch\` | Branch-level settings: middleware, history retention, visual styling |
56
- | \`middleware\` | Request/response interceptors for functions, queries, tasks, and tools |
57
-
58
- ## Development
59
- | Topic | Description |
60
- |-------|-------------|
61
- | \`testing\` | Unit tests, mocks, and assertions |
62
- | \`debugging\` | Logging, inspecting, and debugging XanoScript execution |
63
- | \`frontend\` | Static frontend development and deployment |
64
- | \`run\` | Run job and service configurations for the Xano Job Runner |
65
-
66
- ## Best Practices
67
- | Topic | Description |
68
- |-------|-------------|
69
- | \`performance\` | Performance optimization best practices |
70
- | \`security\` | Security best practices for authentication and authorization |
71
- `;
72
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,179 +0,0 @@
1
- import { describe, it, expect, beforeAll } from "vitest";
2
- import { join, dirname } from "path";
3
- import { fileURLToPath } from "url";
4
- import { existsSync } from "fs";
5
- import { handleTool, toMcpResponse, toolDefinitions, } from "./index.js";
6
- import { setXanoscriptDocsPath } from "./xanoscript_docs.js";
7
- import { XANOSCRIPT_DOCS_V2 } from "../xanoscript.js";
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = dirname(__filename);
10
- const DOCS_PATH = join(__dirname, "..", "xanoscript_docs");
11
- beforeAll(() => {
12
- setXanoscriptDocsPath(DOCS_PATH);
13
- });
14
- describe("handleTool", () => {
15
- it("should handle xanoscript_docs tool", () => {
16
- const result = handleTool("xanoscript_docs", {});
17
- expect(result.success).toBe(true);
18
- expect(result.data).toBeDefined();
19
- });
20
- it("should handle xanoscript_docs with topic arg", () => {
21
- const result = handleTool("xanoscript_docs", { topic: "syntax" });
22
- expect(result.success).toBe(true);
23
- expect(typeof result.data).toBe("string");
24
- expect(result.data).toContain("Documentation version:");
25
- });
26
- it("should handle xanoscript_docs with file_path and return multi-content", () => {
27
- const result = handleTool("xanoscript_docs", { file_path: "api/users/create.xs" });
28
- expect(result.success).toBe(true);
29
- expect(Array.isArray(result.data)).toBe(true);
30
- const data = result.data;
31
- expect(data.length).toBeGreaterThan(1);
32
- expect(data[0]).toContain("Matched topics:");
33
- });
34
- it("should handle validate_xanoscript tool and return a ToolResult", () => {
35
- const result = handleTool("validate_xanoscript", { code: "var $x:int = 1" });
36
- expect(result).toHaveProperty("success");
37
- expect(typeof result.success).toBe("boolean");
38
- // Either data or error should be present
39
- expect(result.data ?? result.error).toBeDefined();
40
- });
41
- it("should handle validate_xanoscript with missing input", () => {
42
- const result = handleTool("validate_xanoscript", {});
43
- expect(result.success).toBe(false);
44
- expect(result.error).toBeDefined();
45
- });
46
- it("should handle mcp_version tool", () => {
47
- const result = handleTool("mcp_version", {});
48
- expect(result.success).toBe(true);
49
- expect(result.data).toBeDefined();
50
- });
51
- it("should handle meta_api_docs tool with topic", () => {
52
- const result = handleTool("meta_api_docs", { topic: "start" });
53
- expect(result.success).toBe(true);
54
- expect(result.data).toBeDefined();
55
- });
56
- it("should handle meta_api_docs tool without topic", () => {
57
- const result = handleTool("meta_api_docs", {});
58
- expect(result.success).toBe(false);
59
- expect(result.error).toContain("topic");
60
- });
61
- it("should handle cli_docs tool with topic", () => {
62
- const result = handleTool("cli_docs", { topic: "start" });
63
- expect(result.success).toBe(true);
64
- expect(result.data).toBeDefined();
65
- });
66
- it("should handle cli_docs tool without topic", () => {
67
- const result = handleTool("cli_docs", {});
68
- expect(result.success).toBe(false);
69
- expect(result.error).toContain("topic");
70
- });
71
- it("should return error for unknown tool", () => {
72
- const result = handleTool("nonexistent_tool", {});
73
- expect(result.success).toBe(false);
74
- expect(result.error).toContain("Unknown tool: nonexistent_tool");
75
- });
76
- it("should return validation error for wrong argument types", () => {
77
- const result = handleTool("xanoscript_docs", { mode: 123 });
78
- expect(result.success).toBe(false);
79
- expect(result.error).toContain("Invalid arguments");
80
- });
81
- it("should return validation error for invalid enum value", () => {
82
- const result = handleTool("xanoscript_docs", { mode: "invalid_mode" });
83
- expect(result.success).toBe(false);
84
- expect(result.error).toContain("Invalid arguments");
85
- });
86
- it("should return validation error when meta_api_docs topic is wrong type", () => {
87
- const result = handleTool("meta_api_docs", { topic: 123 });
88
- expect(result.success).toBe(false);
89
- expect(result.error).toContain("Invalid arguments");
90
- });
91
- });
92
- describe("toMcpResponse", () => {
93
- it("should convert success result to MCP response", () => {
94
- const response = toMcpResponse({ success: true, data: "test data" });
95
- expect(response.content).toHaveLength(1);
96
- expect(response.content[0].type).toBe("text");
97
- expect(response.content[0].text).toBe("test data");
98
- expect(response.isError).toBeUndefined();
99
- });
100
- it("should convert error result to MCP response with isError", () => {
101
- const response = toMcpResponse({ success: false, error: "test error" });
102
- expect(response.content).toHaveLength(1);
103
- expect(response.content[0].text).toBe("test error");
104
- expect(response.isError).toBe(true);
105
- });
106
- it("should convert string array data to multiple content blocks", () => {
107
- const response = toMcpResponse({
108
- success: true,
109
- data: ["block one", "block two", "block three"],
110
- });
111
- expect(response.content).toHaveLength(3);
112
- expect(response.content[0]).toEqual({ type: "text", text: "block one" });
113
- expect(response.content[1]).toEqual({ type: "text", text: "block two" });
114
- expect(response.content[2]).toEqual({ type: "text", text: "block three" });
115
- expect(response.isError).toBeUndefined();
116
- });
117
- it("should handle single-element array data", () => {
118
- const response = toMcpResponse({ success: true, data: ["only block"] });
119
- expect(response.content).toHaveLength(1);
120
- expect(response.content[0].text).toBe("only block");
121
- });
122
- it("should include structuredContent when provided", () => {
123
- const response = toMcpResponse({
124
- success: true,
125
- data: "test",
126
- structuredContent: { version: "1.0.0" },
127
- });
128
- expect(response.structuredContent).toEqual({ version: "1.0.0" });
129
- expect(response.isError).toBeUndefined();
130
- });
131
- it("should omit structuredContent when not provided", () => {
132
- const response = toMcpResponse({ success: true, data: "test" });
133
- expect(response.structuredContent).toBeUndefined();
134
- });
135
- it("should not include structuredContent on error", () => {
136
- const response = toMcpResponse({ success: false, error: "fail" });
137
- expect(response.structuredContent).toBeUndefined();
138
- expect(response.isError).toBe(true);
139
- });
140
- });
141
- describe("toolDefinitions", () => {
142
- it("should contain all 5 tools", () => {
143
- expect(toolDefinitions).toHaveLength(5);
144
- });
145
- it("should have unique tool names", () => {
146
- const names = toolDefinitions.map((t) => t.name);
147
- expect(new Set(names).size).toBe(names.length);
148
- });
149
- it("should include expected tool names", () => {
150
- const names = toolDefinitions.map((t) => t.name);
151
- expect(names).toContain("validate_xanoscript");
152
- expect(names).toContain("xanoscript_docs");
153
- expect(names).toContain("mcp_version");
154
- expect(names).toContain("meta_api_docs");
155
- expect(names).toContain("cli_docs");
156
- });
157
- it("should have annotations on all tools", () => {
158
- for (const tool of toolDefinitions) {
159
- expect(tool).toHaveProperty("annotations");
160
- expect(tool.annotations).toHaveProperty("readOnlyHint");
161
- expect(tool.annotations).toHaveProperty("destructiveHint", false);
162
- }
163
- });
164
- it("should have outputSchema on all tools", () => {
165
- for (const tool of toolDefinitions) {
166
- expect(tool).toHaveProperty("outputSchema");
167
- expect(tool.outputSchema).toHaveProperty("type", "object");
168
- expect(tool.outputSchema).toHaveProperty("properties");
169
- }
170
- });
171
- });
172
- describe("integration: all topic files exist on disk", () => {
173
- for (const [topic, config] of Object.entries(XANOSCRIPT_DOCS_V2)) {
174
- it(`topic "${topic}" -> file "${config.file}" should exist`, () => {
175
- const filePath = join(DOCS_PATH, config.file);
176
- expect(existsSync(filePath)).toBe(true);
177
- });
178
- }
179
- });
@@ -1 +0,0 @@
1
- export {};