@xano/developer-mcp 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +96 -31
  2. package/dist/index.js +335 -222
  3. package/dist/templates/init-workspace.d.ts +10 -0
  4. package/dist/templates/init-workspace.js +292 -0
  5. package/dist/templates/xanoscript-index.d.ts +9 -0
  6. package/dist/templates/xanoscript-index.js +61 -0
  7. package/package.json +4 -2
  8. package/xanoscript_docs/README.md +107 -1
  9. package/xanoscript_docs/agents.md +329 -0
  10. package/xanoscript_docs/apis.md +343 -0
  11. package/xanoscript_docs/database.md +417 -0
  12. package/xanoscript_docs/ephemeral.md +333 -0
  13. package/xanoscript_docs/frontend.md +291 -0
  14. package/xanoscript_docs/functions.md +232 -2035
  15. package/xanoscript_docs/integrations.md +439 -0
  16. package/xanoscript_docs/mcp-servers.md +190 -0
  17. package/xanoscript_docs/plan.md +192 -0
  18. package/xanoscript_docs/syntax.md +314 -0
  19. package/xanoscript_docs/tables.md +270 -0
  20. package/xanoscript_docs/tasks.md +254 -0
  21. package/xanoscript_docs/testing.md +335 -0
  22. package/xanoscript_docs/tools.md +305 -0
  23. package/xanoscript_docs/types.md +297 -0
  24. package/xanoscript_docs/version.json +2 -1
  25. package/xanoscript_docs/api_query_examples.md +0 -1255
  26. package/xanoscript_docs/api_query_guideline.md +0 -129
  27. package/xanoscript_docs/build_from_lovable.md +0 -715
  28. package/xanoscript_docs/db_query_guideline.md +0 -427
  29. package/xanoscript_docs/ephemeral_environment_guideline.md +0 -529
  30. package/xanoscript_docs/expression_guideline.md +0 -1086
  31. package/xanoscript_docs/frontend_guideline.md +0 -67
  32. package/xanoscript_docs/function_examples.md +0 -1406
  33. package/xanoscript_docs/function_guideline.md +0 -130
  34. package/xanoscript_docs/input_guideline.md +0 -227
  35. package/xanoscript_docs/mcp_server_examples.md +0 -36
  36. package/xanoscript_docs/mcp_server_guideline.md +0 -69
  37. package/xanoscript_docs/query_filter.md +0 -489
  38. package/xanoscript_docs/table_examples.md +0 -586
  39. package/xanoscript_docs/table_guideline.md +0 -137
  40. package/xanoscript_docs/task_examples.md +0 -511
  41. package/xanoscript_docs/task_guideline.md +0 -103
  42. package/xanoscript_docs/tips_and_tricks.md +0 -144
  43. package/xanoscript_docs/tool_examples.md +0 -69
  44. package/xanoscript_docs/tool_guideline.md +0 -139
  45. package/xanoscript_docs/unit_testing_guideline.md +0 -328
  46. package/xanoscript_docs/workspace.md +0 -17
@@ -0,0 +1,10 @@
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;
@@ -0,0 +1,292 @@
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. For detailed endpoint documentation, use \`api_docs({ object: "function" })\` etc.
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
+ See \`api_docs({ object: "api_group" })\` for complete API group and endpoint documentation.
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
+ ## API Documentation References
259
+
260
+ For detailed API documentation on each object type, use:
261
+
262
+ - \`api_docs()\` - Overview of all endpoints
263
+ - \`api_docs({ object: "workspace" })\` - Workspace management
264
+ - \`api_docs({ object: "function" })\` - Functions API
265
+ - \`api_docs({ object: "table" })\` - Tables API
266
+ - \`api_docs({ object: "task" })\` - Tasks API
267
+ - \`api_docs({ object: "api_group" })\` - API groups and endpoints
268
+ - \`api_docs({ object: "agent" })\` - AI agents
269
+ - \`api_docs({ object: "tool" })\` - AI tools
270
+ - \`api_docs({ object: "authentication" })\` - Auth and user info
271
+
272
+ ## XanoScript Documentation References
273
+
274
+ For writing XanoScript code, use:
275
+
276
+ - \`xanoscript_docs()\` - Full documentation index
277
+ - \`xanoscript_docs({ keyword: "function" })\` - Function syntax
278
+ - \`xanoscript_docs({ keyword: "table" })\` - Table schema syntax
279
+ - \`xanoscript_docs({ keyword: "api_query" })\` - API endpoint syntax
280
+ - \`xanoscript_docs({ keyword: "syntax" })\` - Language reference
281
+
282
+ ## Validating XanoScript
283
+
284
+ Before pushing changes, validate the XanoScript syntax:
285
+
286
+ \`\`\`
287
+ validate_xanoscript({ code: "function foo { ... }" })
288
+ \`\`\`
289
+
290
+ This will check for syntax errors and return line/column positions for any issues.
291
+ `;
292
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Template for xanoscript_docs index documentation
3
+ * Edit this file to update the XanoScript documentation index
4
+ */
5
+ export interface XanoscriptIndexParams {
6
+ version: string;
7
+ aliasLookup: Record<string, string[]>;
8
+ }
9
+ export declare function generateXanoscriptIndexTemplate(params: XanoscriptIndexParams): string;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Template for xanoscript_docs index documentation
3
+ * Edit this file to update the XanoScript documentation index
4
+ */
5
+ export function generateXanoscriptIndexTemplate(params) {
6
+ const { version, aliasLookup } = params;
7
+ const formatRow = (keyword, description) => {
8
+ const aliases = aliasLookup[keyword]?.slice(0, 3).join(", ") || "";
9
+ return `| \`${keyword}\` | ${aliases ? aliases : "-"} | ${description} |`;
10
+ };
11
+ return `# XanoScript Documentation Index
12
+ Version: ${version}
13
+
14
+ Use \`xanoscript_docs\` with a keyword to retrieve documentation.
15
+
16
+ ## Core Concepts
17
+ These return guidelines + examples for writing XanoScript code.
18
+
19
+ | Keyword | Aliases | Description |
20
+ |---------|---------|-------------|
21
+ ${formatRow("function", "Custom reusable functions in `functions/`")}
22
+ ${formatRow("api_query", "HTTP API endpoints in `apis/`")}
23
+ ${formatRow("table", "Database table schemas in `tables/`")}
24
+ ${formatRow("task", "Scheduled background tasks in `tasks/`")}
25
+ ${formatRow("tool", "AI-callable tools in `tools/`")}
26
+ ${formatRow("agent", "AI agents in `agents/`")}
27
+ ${formatRow("mcp_server", "MCP servers in `mcp_servers/`")}
28
+
29
+ ## Language Reference
30
+ Core syntax and operators.
31
+
32
+ | Keyword | Aliases | Description |
33
+ |---------|---------|-------------|
34
+ ${formatRow("syntax", "Complete XanoScript syntax (stack, var, conditional, foreach, etc.)")}
35
+ ${formatRow("expressions", "Pipe operators and filters (string, math, array, date)")}
36
+ ${formatRow("input", "Input definition syntax (types, filters, validation)")}
37
+ ${formatRow("db_query", "Database query patterns (query, add, edit, delete)")}
38
+ ${formatRow("query_filter", "WHERE clause and filter syntax")}
39
+
40
+ ## Development Workflows
41
+ AI agent development strategies and phases.
42
+
43
+ | Keyword | Aliases | Description |
44
+ |---------|---------|-------------|
45
+ ${formatRow("workflow", "Overall XanoScript development workflow")}
46
+ ${formatRow("function_workflow", "AI workflow for creating functions")}
47
+ ${formatRow("api_workflow", "AI workflow for creating API endpoints")}
48
+ ${formatRow("table_workflow", "AI workflow for creating tables")}
49
+ ${formatRow("task_workflow", "AI workflow for creating tasks")}
50
+
51
+ ## Specialized Topics
52
+
53
+ | Keyword | Aliases | Description |
54
+ |---------|---------|-------------|
55
+ ${formatRow("frontend", "Frontend development with Xano")}
56
+ ${formatRow("lovable", "Building from Lovable-generated websites")}
57
+ ${formatRow("testing", "Unit testing XanoScript code")}
58
+ ${formatRow("tips", "Tips and tricks")}
59
+ ${formatRow("ephemeral", "Ephemeral environment setup")}
60
+ `;
61
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xano/developer-mcp",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "MCP server for Xano Headless API documentation and XanoScript code validation",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -40,9 +40,11 @@
40
40
  "license": "MIT",
41
41
  "dependencies": {
42
42
  "@modelcontextprotocol/sdk": "^1.26.0",
43
- "@xano/xanoscript-language-server": "^11.6.3"
43
+ "@xano/xanoscript-language-server": "^11.6.3",
44
+ "minimatch": "^10.1.2"
44
45
  },
45
46
  "devDependencies": {
47
+ "@types/minimatch": "^5.1.2",
46
48
  "@types/node": "^22.0.0",
47
49
  "typescript": "^5.9.0"
48
50
  }
@@ -1 +1,107 @@
1
- # xanoscript-ai-documentation
1
+ # XanoScript Documentation
2
+
3
+ XanoScript is the declarative scripting language for [Xano](https://xano.com), a no-code/low-code backend platform. Use it to define database schemas, API endpoints, functions, scheduled tasks, and AI agents.
4
+
5
+ ## Quick Reference
6
+
7
+ | Construct | File Location | Purpose |
8
+ |-----------|---------------|---------|
9
+ | `table` | `tables/*.xs` | Database schema definition |
10
+ | `function` | `functions/**/*.xs` | Reusable logic blocks |
11
+ | `query` | `apis/<group>/*.xs` | HTTP API endpoints |
12
+ | `task` | `tasks/*.xs` | Scheduled/cron jobs |
13
+ | `agent` | `agents/**/*.xs` | AI-powered agents |
14
+ | `tool` | `tools/**/*.xs` | Tools for AI agents |
15
+ | `mcp_server` | `mcp_servers/**/*.xs` | MCP server definitions |
16
+ | `addon` | `addons/*.xs` | Subqueries for related data |
17
+
18
+ ## Workspace Structure
19
+
20
+ ```
21
+ project/
22
+ ├── tables/ # Database table schemas
23
+ ├── functions/ # Reusable functions (supports subfolders)
24
+ ├── apis/
25
+ │ └── <api-group>/ # API endpoints grouped by domain
26
+ ├── tasks/ # Scheduled jobs
27
+ ├── agents/ # AI agents
28
+ ├── tools/ # AI tools
29
+ ├── mcp_servers/ # MCP server definitions
30
+ ├── addons/ # Query addons
31
+ ├── static/ # Frontend files (HTML, CSS, JS)
32
+ └── ephemeral/ # Temporary test environments
33
+ ```
34
+
35
+ ## Environment Variables
36
+
37
+ Access with `$env.<name>`. Built-in variables:
38
+
39
+ | Variable | Description |
40
+ |----------|-------------|
41
+ | `$env.$remote_ip` | Client IP address |
42
+ | `$env.$http_headers` | Request headers array |
43
+ | `$env.$request_uri` | Request URI |
44
+ | `$env.$request_method` | HTTP method (GET, POST, etc.) |
45
+ | `$env.$request_querystring` | Query string |
46
+ | `$env.$datasource` | Current datasource |
47
+ | `$env.$branch` | Current branch |
48
+
49
+ Custom environment variables are set in the Xano dashboard and accessed as `$env.MY_VAR`.
50
+
51
+ ## Core Syntax Patterns
52
+
53
+ ### Block Structure
54
+ ```xs
55
+ <construct> "<name>" {
56
+ input { ... } # Parameters (optional)
57
+ stack { ... } # Logic
58
+ response = $var # Output
59
+ }
60
+ ```
61
+
62
+ ### Variable Access
63
+ ```xs
64
+ $input.field # Input parameters
65
+ $var.field # Stack variables
66
+ $auth.id # Authenticated user ID
67
+ $env.MY_VAR # Environment variable
68
+ $db.table.field # Database field reference (in queries)
69
+ $this # Current item in loops/maps
70
+ ```
71
+
72
+ ### Filters (Pipe Syntax)
73
+ ```xs
74
+ $value|trim|lower # Chain filters
75
+ $input.name|strlen # Get length
76
+ $array|first # First element
77
+ ($a + $b)|round:2 # Math with precision
78
+ ```
79
+
80
+ ## File Frontmatter
81
+
82
+ Documentation files use frontmatter to specify which file patterns they apply to:
83
+
84
+ ```markdown
85
+ ---
86
+ applyTo: "functions/**/*.xs"
87
+ ---
88
+ ```
89
+
90
+ This helps AI tools apply the correct documentation based on the file being edited.
91
+
92
+ ## Documentation Index
93
+
94
+ 1. [Syntax Reference](syntax.md) - Expressions, operators, filters
95
+ 2. [Types & Inputs](types.md) - Data types, validation, input blocks
96
+ 3. [Tables](tables.md) - Database schema definitions
97
+ 4. [Functions](functions.md) - Reusable function stacks
98
+ 5. [APIs](apis.md) - HTTP endpoint definitions
99
+ 6. [Tasks](tasks.md) - Scheduled jobs
100
+ 7. [Database Operations](database.md) - Query, add, edit, delete
101
+ 8. [Agents](agents.md) - AI agent configuration
102
+ 9. [Tools](tools.md) - AI tools for agents
103
+ 10. [MCP Servers](mcp-servers.md) - Model Context Protocol servers
104
+ 11. [Testing](testing.md) - Unit tests and mocking
105
+ 12. [Integrations](integrations.md) - Cloud services, Redis, security
106
+ 13. [Frontend](frontend.md) - Static frontend development
107
+ 14. [Ephemeral](ephemeral.md) - Temporary environments