@xano/developer-mcp 1.0.31 → 1.0.33

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 (45) hide show
  1. package/README.md +172 -9
  2. package/dist/cli_docs/topics/workspace.js +50 -6
  3. package/dist/index.d.ts +8 -0
  4. package/dist/index.js +14 -286
  5. package/dist/lib.d.ts +53 -0
  6. package/dist/lib.js +71 -0
  7. package/dist/tools/cli_docs.d.ts +40 -0
  8. package/dist/tools/cli_docs.js +68 -0
  9. package/dist/tools/index.d.ts +91 -0
  10. package/dist/tools/index.js +104 -0
  11. package/dist/tools/mcp_version.d.ts +45 -0
  12. package/dist/tools/mcp_version.js +94 -0
  13. package/dist/tools/meta_api_docs.d.ts +41 -0
  14. package/dist/tools/meta_api_docs.js +69 -0
  15. package/dist/tools/run_api_docs.d.ts +46 -0
  16. package/dist/tools/run_api_docs.js +69 -0
  17. package/dist/tools/types.d.ts +18 -0
  18. package/dist/tools/types.js +17 -0
  19. package/dist/tools/validate_xanoscript.d.ts +68 -0
  20. package/dist/tools/validate_xanoscript.js +114 -0
  21. package/dist/tools/xanoscript_docs.d.ts +72 -0
  22. package/dist/tools/xanoscript_docs.js +129 -0
  23. package/dist/xanoscript_docs/README.md +67 -31
  24. package/dist/xanoscript_docs/addons.md +2 -2
  25. package/dist/xanoscript_docs/agents.md +2 -2
  26. package/dist/xanoscript_docs/apis.md +9 -7
  27. package/dist/xanoscript_docs/branch.md +5 -4
  28. package/dist/xanoscript_docs/database.md +1 -1
  29. package/dist/xanoscript_docs/functions.md +2 -2
  30. package/dist/xanoscript_docs/integrations.md +1 -1
  31. package/dist/xanoscript_docs/mcp-servers.md +12 -12
  32. package/dist/xanoscript_docs/performance.md +1 -1
  33. package/dist/xanoscript_docs/realtime.md +1 -1
  34. package/dist/xanoscript_docs/run.md +15 -14
  35. package/dist/xanoscript_docs/schema.md +1 -1
  36. package/dist/xanoscript_docs/security.md +1 -1
  37. package/dist/xanoscript_docs/streaming.md +114 -92
  38. package/dist/xanoscript_docs/tables.md +1 -1
  39. package/dist/xanoscript_docs/tasks.md +16 -8
  40. package/dist/xanoscript_docs/testing.md +1 -1
  41. package/dist/xanoscript_docs/tools.md +1 -1
  42. package/dist/xanoscript_docs/triggers.md +1 -1
  43. package/dist/xanoscript_docs/types.md +1 -1
  44. package/dist/xanoscript_docs/workspace.md +6 -5
  45. package/package.json +22 -3
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Run API Documentation Tool
3
+ *
4
+ * Retrieves documentation for Xano's Run API.
5
+ * Re-exports from the run_api_docs module with ToolResult support.
6
+ */
7
+ import { runApiDocsToolDefinition, topics, getTopicNames, getTopicDescriptions } from "../run_api_docs/index.js";
8
+ import type { TopicDoc, DetailLevel } from "../meta_api_docs/types.js";
9
+ import type { ToolResult } from "./types.js";
10
+ export { runApiDocsToolDefinition, topics as runApiTopics, getTopicNames as getRunApiTopicNames, getTopicDescriptions as getRunApiTopicDescriptions, };
11
+ export type { TopicDoc, DetailLevel };
12
+ export interface RunApiDocsArgs {
13
+ topic: string;
14
+ detail_level?: DetailLevel;
15
+ include_schemas?: boolean;
16
+ }
17
+ export interface RunApiDocsResult {
18
+ documentation: string;
19
+ }
20
+ /**
21
+ * Get Xano Run API documentation.
22
+ *
23
+ * @param args - Documentation arguments
24
+ * @returns Documentation content
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { runApiDocs } from '@xano/developer-mcp';
29
+ *
30
+ * // Get overview
31
+ * const overview = runApiDocs({ topic: 'start' });
32
+ *
33
+ * // Get session documentation with examples
34
+ * const sessionDocs = runApiDocs({
35
+ * topic: 'session',
36
+ * detail_level: 'examples',
37
+ * include_schemas: true
38
+ * });
39
+ * ```
40
+ */
41
+ export declare function runApiDocs(args: RunApiDocsArgs): RunApiDocsResult;
42
+ /**
43
+ * Get Run API documentation and return a ToolResult.
44
+ */
45
+ export declare function runApiDocsTool(args: RunApiDocsArgs): ToolResult;
46
+ export { runApiDocsToolDefinition as toolDefinition };
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Run API Documentation Tool
3
+ *
4
+ * Retrieves documentation for Xano's Run API.
5
+ * Re-exports from the run_api_docs module with ToolResult support.
6
+ */
7
+ import { handleRunApiDocs as _handleRunApiDocs, runApiDocsToolDefinition, topics, getTopicNames, getTopicDescriptions, } from "../run_api_docs/index.js";
8
+ // =============================================================================
9
+ // Re-exports
10
+ // =============================================================================
11
+ export { runApiDocsToolDefinition, topics as runApiTopics, getTopicNames as getRunApiTopicNames, getTopicDescriptions as getRunApiTopicDescriptions, };
12
+ // =============================================================================
13
+ // Standalone Tool Function
14
+ // =============================================================================
15
+ /**
16
+ * Get Xano Run API documentation.
17
+ *
18
+ * @param args - Documentation arguments
19
+ * @returns Documentation content
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { runApiDocs } from '@xano/developer-mcp';
24
+ *
25
+ * // Get overview
26
+ * const overview = runApiDocs({ topic: 'start' });
27
+ *
28
+ * // Get session documentation with examples
29
+ * const sessionDocs = runApiDocs({
30
+ * topic: 'session',
31
+ * detail_level: 'examples',
32
+ * include_schemas: true
33
+ * });
34
+ * ```
35
+ */
36
+ export function runApiDocs(args) {
37
+ if (!args?.topic) {
38
+ throw new Error("'topic' parameter is required. Use topic='start' for overview.");
39
+ }
40
+ const documentation = _handleRunApiDocs(args.topic, args.detail_level, args.include_schemas);
41
+ return { documentation };
42
+ }
43
+ /**
44
+ * Get Run API documentation and return a ToolResult.
45
+ */
46
+ export function runApiDocsTool(args) {
47
+ if (!args?.topic) {
48
+ return {
49
+ success: false,
50
+ error: "Error: 'topic' parameter is required. Use run_api_docs with topic='start' for overview.",
51
+ };
52
+ }
53
+ try {
54
+ const result = runApiDocs(args);
55
+ return {
56
+ success: true,
57
+ data: result.documentation,
58
+ };
59
+ }
60
+ catch (error) {
61
+ const errorMessage = error instanceof Error ? error.message : String(error);
62
+ return {
63
+ success: false,
64
+ error: `Error retrieving Run API documentation: ${errorMessage}`,
65
+ };
66
+ }
67
+ }
68
+ // Re-export tool definition for MCP
69
+ export { runApiDocsToolDefinition as toolDefinition };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Common types for tool results
3
+ */
4
+ export interface ToolResult {
5
+ success: boolean;
6
+ data?: string;
7
+ error?: string;
8
+ }
9
+ /**
10
+ * Convert a ToolResult to MCP tool response format
11
+ */
12
+ export declare function toMcpResponse(result: ToolResult): {
13
+ content: {
14
+ type: "text";
15
+ text: string;
16
+ }[];
17
+ isError?: boolean;
18
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Common types for tool results
3
+ */
4
+ /**
5
+ * Convert a ToolResult to MCP tool response format
6
+ */
7
+ export function toMcpResponse(result) {
8
+ if (result.success) {
9
+ return {
10
+ content: [{ type: "text", text: result.data }],
11
+ };
12
+ }
13
+ return {
14
+ content: [{ type: "text", text: result.error }],
15
+ isError: true,
16
+ };
17
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * XanoScript Validation Tool
3
+ *
4
+ * Validates XanoScript code for syntax errors using the XanoScript language server.
5
+ * Can be used standalone or within the MCP server.
6
+ */
7
+ import type { ToolResult } from "./types.js";
8
+ export interface ValidateXanoscriptArgs {
9
+ /** The XanoScript code to validate */
10
+ code: string;
11
+ }
12
+ export interface ParserDiagnostic {
13
+ range: {
14
+ start: {
15
+ line: number;
16
+ character: number;
17
+ };
18
+ end: {
19
+ line: number;
20
+ character: number;
21
+ };
22
+ };
23
+ message: string;
24
+ source: string;
25
+ }
26
+ export interface ValidationResult {
27
+ valid: boolean;
28
+ errors: ParserDiagnostic[];
29
+ message: string;
30
+ }
31
+ /**
32
+ * Validate XanoScript code for syntax errors.
33
+ *
34
+ * @param args - The validation arguments
35
+ * @returns Validation result with errors if any
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { validateXanoscript } from '@xano/developer-mcp';
40
+ *
41
+ * const result = validateXanoscript({ code: 'return 1 + 1' });
42
+ * if (result.valid) {
43
+ * console.log('Code is valid!');
44
+ * } else {
45
+ * console.log('Errors:', result.errors);
46
+ * }
47
+ * ```
48
+ */
49
+ export declare function validateXanoscript(args: ValidateXanoscriptArgs): ValidationResult;
50
+ /**
51
+ * Validate XanoScript and return a simplified result.
52
+ * Returns ToolResult format for consistent error handling.
53
+ */
54
+ export declare function validateXanoscriptTool(args: ValidateXanoscriptArgs): ToolResult;
55
+ export declare const validateXanoscriptToolDefinition: {
56
+ name: string;
57
+ description: string;
58
+ inputSchema: {
59
+ type: string;
60
+ properties: {
61
+ code: {
62
+ type: string;
63
+ description: string;
64
+ };
65
+ };
66
+ required: string[];
67
+ };
68
+ };
@@ -0,0 +1,114 @@
1
+ /**
2
+ * XanoScript Validation Tool
3
+ *
4
+ * Validates XanoScript code for syntax errors using the XanoScript language server.
5
+ * Can be used standalone or within the MCP server.
6
+ */
7
+ import { xanoscriptParser } from "@xano/xanoscript-language-server/parser/parser.js";
8
+ import { getSchemeFromContent } from "@xano/xanoscript-language-server/utils.js";
9
+ // =============================================================================
10
+ // Standalone Tool Function
11
+ // =============================================================================
12
+ /**
13
+ * Validate XanoScript code for syntax errors.
14
+ *
15
+ * @param args - The validation arguments
16
+ * @returns Validation result with errors if any
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { validateXanoscript } from '@xano/developer-mcp';
21
+ *
22
+ * const result = validateXanoscript({ code: 'return 1 + 1' });
23
+ * if (result.valid) {
24
+ * console.log('Code is valid!');
25
+ * } else {
26
+ * console.log('Errors:', result.errors);
27
+ * }
28
+ * ```
29
+ */
30
+ export function validateXanoscript(args) {
31
+ if (!args?.code) {
32
+ return {
33
+ valid: false,
34
+ errors: [],
35
+ message: "Error: 'code' parameter is required",
36
+ };
37
+ }
38
+ try {
39
+ const text = args.code;
40
+ const scheme = getSchemeFromContent(text);
41
+ const parser = xanoscriptParser(text, scheme);
42
+ if (parser.errors.length === 0) {
43
+ return {
44
+ valid: true,
45
+ errors: [],
46
+ message: "XanoScript is valid. No syntax errors found.",
47
+ };
48
+ }
49
+ const diagnostics = parser.errors.map((error) => {
50
+ const startOffset = error.token?.startOffset ?? 0;
51
+ const endOffset = error.token?.endOffset ?? 5;
52
+ const lines = text.substring(0, startOffset).split("\n");
53
+ const line = lines.length - 1;
54
+ const character = lines[lines.length - 1].length;
55
+ const endLines = text.substring(0, endOffset + 1).split("\n");
56
+ const endLine = endLines.length - 1;
57
+ const endCharacter = endLines[endLines.length - 1].length;
58
+ return {
59
+ range: {
60
+ start: { line, character },
61
+ end: { line: endLine, character: endCharacter },
62
+ },
63
+ message: error.message,
64
+ source: error.name || "XanoScript Parser",
65
+ };
66
+ });
67
+ const errorMessages = diagnostics.map((d, i) => {
68
+ const location = `Line ${d.range.start.line + 1}, Column ${d.range.start.character + 1}`;
69
+ return `${i + 1}. [${location}] ${d.message}`;
70
+ });
71
+ return {
72
+ valid: false,
73
+ errors: diagnostics,
74
+ message: `Found ${diagnostics.length} error(s):\n\n${errorMessages.join("\n")}`,
75
+ };
76
+ }
77
+ catch (error) {
78
+ const errorMessage = error instanceof Error ? error.message : String(error);
79
+ return {
80
+ valid: false,
81
+ errors: [],
82
+ message: `Validation error: ${errorMessage}`,
83
+ };
84
+ }
85
+ }
86
+ /**
87
+ * Validate XanoScript and return a simplified result.
88
+ * Returns ToolResult format for consistent error handling.
89
+ */
90
+ export function validateXanoscriptTool(args) {
91
+ const result = validateXanoscript(args);
92
+ return {
93
+ success: result.valid,
94
+ data: result.valid ? result.message : undefined,
95
+ error: result.valid ? undefined : result.message,
96
+ };
97
+ }
98
+ // =============================================================================
99
+ // MCP Tool Definition
100
+ // =============================================================================
101
+ export const validateXanoscriptToolDefinition = {
102
+ name: "validate_xanoscript",
103
+ description: "Validate XanoScript code for syntax errors. Returns a list of errors with line/column positions, or confirms the code is valid. The language server auto-detects the object type from the code syntax.",
104
+ inputSchema: {
105
+ type: "object",
106
+ properties: {
107
+ code: {
108
+ type: "string",
109
+ description: "The XanoScript code to validate",
110
+ },
111
+ },
112
+ required: ["code"],
113
+ },
114
+ };
@@ -0,0 +1,72 @@
1
+ /**
2
+ * XanoScript Documentation Tool
3
+ *
4
+ * Retrieves XanoScript programming language documentation.
5
+ * Can be used standalone or within the MCP server.
6
+ */
7
+ import { type XanoscriptDocsArgs } from "../xanoscript.js";
8
+ import type { ToolResult } from "./types.js";
9
+ export type { XanoscriptDocsArgs };
10
+ export interface XanoscriptDocsResult {
11
+ documentation: string;
12
+ }
13
+ /**
14
+ * Get the path to XanoScript documentation files.
15
+ * Searches common locations for production and development.
16
+ */
17
+ export declare function getXanoscriptDocsPath(): string;
18
+ /**
19
+ * Set a custom docs path (useful for testing or custom installations)
20
+ */
21
+ export declare function setXanoscriptDocsPath(path: string): void;
22
+ /**
23
+ * Get XanoScript documentation.
24
+ *
25
+ * @param args - Optional documentation arguments
26
+ * @returns Documentation content
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import { xanoscriptDocs } from '@xano/developer-mcp';
31
+ *
32
+ * // Get overview
33
+ * const overview = xanoscriptDocs();
34
+ *
35
+ * // Get specific topic
36
+ * const syntaxDocs = xanoscriptDocs({ topic: 'syntax' });
37
+ *
38
+ * // Get context-aware docs for a file
39
+ * const fileDocs = xanoscriptDocs({ file_path: 'apis/users/create.xs' });
40
+ *
41
+ * // Get quick reference only
42
+ * const quickRef = xanoscriptDocs({ topic: 'syntax', mode: 'quick_reference' });
43
+ * ```
44
+ */
45
+ export declare function xanoscriptDocs(args?: XanoscriptDocsArgs): XanoscriptDocsResult;
46
+ /**
47
+ * Get XanoScript documentation and return a ToolResult.
48
+ */
49
+ export declare function xanoscriptDocsTool(args?: XanoscriptDocsArgs): ToolResult;
50
+ export declare const xanoscriptDocsToolDefinition: {
51
+ name: string;
52
+ description: string;
53
+ inputSchema: {
54
+ type: string;
55
+ properties: {
56
+ topic: {
57
+ type: string;
58
+ description: string;
59
+ };
60
+ file_path: {
61
+ type: string;
62
+ description: string;
63
+ };
64
+ mode: {
65
+ type: string;
66
+ enum: string[];
67
+ description: string;
68
+ };
69
+ };
70
+ required: never[];
71
+ };
72
+ };
@@ -0,0 +1,129 @@
1
+ /**
2
+ * XanoScript Documentation Tool
3
+ *
4
+ * Retrieves XanoScript programming language documentation.
5
+ * Can be used standalone or within the MCP server.
6
+ */
7
+ import { readFileSync } from "fs";
8
+ import { dirname, join } from "path";
9
+ import { fileURLToPath } from "url";
10
+ import { readXanoscriptDocsV2, getTopicDescriptions, } from "../xanoscript.js";
11
+ // =============================================================================
12
+ // Path Resolution
13
+ // =============================================================================
14
+ let _docsPath = null;
15
+ /**
16
+ * Get the path to XanoScript documentation files.
17
+ * Searches common locations for production and development.
18
+ */
19
+ export function getXanoscriptDocsPath() {
20
+ if (_docsPath)
21
+ return _docsPath;
22
+ const __filename = fileURLToPath(import.meta.url);
23
+ const __dirname = dirname(__filename);
24
+ const possiblePaths = [
25
+ join(__dirname, "..", "xanoscript_docs"), // dist/xanoscript_docs (production)
26
+ join(__dirname, "..", "..", "src", "xanoscript_docs"), // src/xanoscript_docs (dev)
27
+ join(__dirname, "..", "..", "xanoscript_docs"), // fallback
28
+ ];
29
+ for (const p of possiblePaths) {
30
+ try {
31
+ readFileSync(join(p, "version.json"));
32
+ _docsPath = p;
33
+ return p;
34
+ }
35
+ catch {
36
+ continue;
37
+ }
38
+ }
39
+ // Default fallback
40
+ _docsPath = join(__dirname, "..", "xanoscript_docs");
41
+ return _docsPath;
42
+ }
43
+ /**
44
+ * Set a custom docs path (useful for testing or custom installations)
45
+ */
46
+ export function setXanoscriptDocsPath(path) {
47
+ _docsPath = path;
48
+ }
49
+ // =============================================================================
50
+ // Standalone Tool Function
51
+ // =============================================================================
52
+ /**
53
+ * Get XanoScript documentation.
54
+ *
55
+ * @param args - Optional documentation arguments
56
+ * @returns Documentation content
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * import { xanoscriptDocs } from '@xano/developer-mcp';
61
+ *
62
+ * // Get overview
63
+ * const overview = xanoscriptDocs();
64
+ *
65
+ * // Get specific topic
66
+ * const syntaxDocs = xanoscriptDocs({ topic: 'syntax' });
67
+ *
68
+ * // Get context-aware docs for a file
69
+ * const fileDocs = xanoscriptDocs({ file_path: 'apis/users/create.xs' });
70
+ *
71
+ * // Get quick reference only
72
+ * const quickRef = xanoscriptDocs({ topic: 'syntax', mode: 'quick_reference' });
73
+ * ```
74
+ */
75
+ export function xanoscriptDocs(args) {
76
+ const docsPath = getXanoscriptDocsPath();
77
+ const documentation = readXanoscriptDocsV2(docsPath, args);
78
+ return { documentation };
79
+ }
80
+ /**
81
+ * Get XanoScript documentation and return a ToolResult.
82
+ */
83
+ export function xanoscriptDocsTool(args) {
84
+ try {
85
+ const result = xanoscriptDocs(args);
86
+ return {
87
+ success: true,
88
+ data: result.documentation,
89
+ };
90
+ }
91
+ catch (error) {
92
+ const errorMessage = error instanceof Error ? error.message : String(error);
93
+ return {
94
+ success: false,
95
+ error: `Error retrieving XanoScript documentation: ${errorMessage}`,
96
+ };
97
+ }
98
+ }
99
+ // =============================================================================
100
+ // MCP Tool Definition
101
+ // =============================================================================
102
+ export const xanoscriptDocsToolDefinition = {
103
+ name: "xanoscript_docs",
104
+ description: "Get XanoScript programming language documentation for AI code generation. " +
105
+ "Call without parameters for overview (README). " +
106
+ "Use 'topic' for specific documentation, or 'file_path' for context-aware docs based on the file you're editing. " +
107
+ "Use mode='quick_reference' for compact syntax cheatsheet (recommended for context efficiency).",
108
+ inputSchema: {
109
+ type: "object",
110
+ properties: {
111
+ topic: {
112
+ type: "string",
113
+ description: "Documentation topic. Available: " + getTopicDescriptions(),
114
+ },
115
+ file_path: {
116
+ type: "string",
117
+ description: "File path being edited (e.g., 'apis/users/create.xs', 'functions/utils/format.xs'). " +
118
+ "Returns all relevant docs based on file type using applyTo pattern matching.",
119
+ },
120
+ mode: {
121
+ type: "string",
122
+ enum: ["full", "quick_reference"],
123
+ description: "full = complete documentation, quick_reference = compact Quick Reference sections only. " +
124
+ "Use quick_reference for smaller context window usage.",
125
+ },
126
+ },
127
+ required: [],
128
+ },
129
+ };
@@ -4,45 +4,81 @@ XanoScript is the declarative scripting language for [Xano](https://xano.com), a
4
4
 
5
5
  ## Quick Reference
6
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
- | `*_trigger` | `triggers/**/*.xs` | Event-driven handlers |
14
- | `agent` | `agents/**/*.xs` | AI-powered agents |
15
- | `tool` | `tools/**/*.xs` | Tools for AI agents |
16
- | `mcp_server` | `mcp_servers/**/*.xs` | MCP server definitions |
17
- | `addon` | `addons/*.xs` | Subqueries for related data |
18
- | `middleware` | `middleware/**/*.xs` | Request/response interceptors |
19
- | `branch` | `branch.xs` | Branch-level configuration |
20
- | `workspace` | `workspace.xs` | Workspace-level configuration |
21
- | `realtime_channel` | Configuration | Realtime channel settings |
7
+ | Construct | File Location | Purpose |
8
+ | ------------------- | ------------------------------------ | ----------------------------- |
9
+ | `workspace` | `workspace/{name}.xs` | Workspace-level configuration |
10
+ | `workspace_trigger` | `workspace/trigger/{name}.xs` | Workspace event handlers |
11
+ | `table` | `table/{name}.xs` | Database schema definition |
12
+ | `table_trigger` | `table/trigger/{name}.xs` | Table event handlers |
13
+ | `api_group` | `api/{group}/api_group.xs` | API group definition |
14
+ | `query` | `api/{group}/{endpoint}_{verb}.xs` | HTTP API endpoints |
15
+ | `function` | `function/{name}.xs` | Reusable logic blocks |
16
+ | `task` | `task/{name}.xs` | Scheduled/cron jobs |
17
+ | `agent` | `agent/{name}.xs` | AI-powered agents |
18
+ | `agent_trigger` | `agent/trigger/{name}.xs` | Agent event handlers |
19
+ | `tool` | `tool/{name}.xs` | Tools for AI agents |
20
+ | `mcp_server` | `mcp_server/{name}.xs` | MCP server definitions |
21
+ | `mcp_server_trigger`| `mcp_server/trigger/{name}.xs` | MCP server event handlers |
22
+ | `addon` | `addon/{name}.xs` | Subqueries for related data |
23
+ | `middleware` | `middleware/{name}.xs` | Request/response interceptors |
24
+ | `branch` | `branch.xs` | Branch-level configuration |
25
+ | `realtime_channel` | Configuration | Realtime channel settings |
26
+
27
+ **Naming convention:** All folder and file names use `snake_case` (e.g., `user_profile.xs`, `get_all_users_get.xs`).
22
28
 
23
29
  **Important:** Each `.xs` file must contain exactly one definition. You cannot define multiple tables, functions, queries, or other constructs in a single file.
24
30
 
25
31
  ## Workspace Structure
26
32
 
33
+ After pulling from Xano, files are organized using `snake_case` naming:
34
+
27
35
  ```
28
36
  project/
29
- ├── workspace.xs // Workspace configuration (env vars, preferences)
30
- ├── branch.xs // Branch configuration (middleware, history)
31
- ├── tables/ // Database table schemas
32
- ├── functions/ // Reusable functions (supports subfolders)
33
- ├── apis/
34
- │ └── <api-group>/ // API endpoints grouped by domain
35
- ├── tasks/ // Scheduled jobs
36
- ├── triggers/ // Event-driven handlers
37
- ├── agents/ // AI agents
38
- ├── tools/ // AI tools
39
- ├── mcp_servers/ // MCP server definitions
40
- ├── middleware/ // Request/response interceptors
41
- ├── addons/ // Query addons
42
- ├── static/ // Frontend files (HTML, CSS, JS)
43
- └── run/ // Job and service configurations
37
+ ├── branch.xs # Branch configuration
38
+ ├── workspace/
39
+ ├── my_workspace.xs # Workspace configuration
40
+ │ └── trigger/
41
+ │ └── on_deploy.xs # Workspace triggers
42
+ ├── api/
43
+ │ └── users/ # API group folder
44
+ ├── api_group.xs # API group definition
45
+ ├── get_all_get.xs # GET /users
46
+ ├── get_one_get.xs # GET /users/:id
47
+ ├── create_post.xs # POST /users
48
+ │ └── nested/
49
+ │ └── profile_get.xs # Nested endpoint: GET /users/nested/profile
50
+ ├── function/
51
+ └── validate_token.xs # Reusable functions
52
+ ├── task/
53
+ │ └── daily_cleanup.xs # Scheduled jobs
54
+ ├── table/
55
+ │ ├── users.xs # Table schema
56
+ │ └── trigger/
57
+ │ └── on_user_create.xs # Table triggers
58
+ ├── agent/
59
+ │ ├── support_bot.xs # AI agents
60
+ │ └── trigger/
61
+ │ └── on_message.xs # Agent triggers
62
+ ├── tool/
63
+ │ └── search_docs.xs # AI tools
64
+ ├── mcp_server/
65
+ │ ├── my_server.xs # MCP server definitions
66
+ │ └── trigger/
67
+ │ └── on_connect.xs # MCP server triggers
68
+ ├── middleware/
69
+ │ └── auth_check.xs # Request/response interceptors
70
+ ├── addon/
71
+ │ └── user_posts.xs # Query addons
72
+ ├── static/ # Frontend files (HTML, CSS, JS)
73
+ └── run/ # Job and service configurations
44
74
  ```
45
75
 
76
+ **Key conventions:**
77
+ - All folders and files use `snake_case` naming
78
+ - API endpoints include the HTTP verb suffix (e.g., `create_post.xs`, `get_one_get.xs`)
79
+ - Triggers are nested under `{type}/trigger/` folders
80
+ - Nested API paths become nested folders (e.g., `/users/nested/profile` → `api/users/nested/profile_get.xs`)
81
+
46
82
  ## Environment Variables
47
83
 
48
84
  Access with `$env.<name>`. Common built-in variables include `$env.$remote_ip`, `$env.$http_headers`, `$env.$request_method`, `$env.$datasource`, and `$env.$branch`. Custom environment variables are set in the Xano dashboard and accessed as `$env.MY_VAR`.
@@ -100,7 +136,7 @@ Documentation files use frontmatter to specify which file patterns they apply to
100
136
 
101
137
  ```markdown
102
138
  ---
103
- applyTo: "functions/**/*.xs"
139
+ applyTo: "function/**/*.xs"
104
140
  ---
105
141
  ```
106
142
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- applyTo: "addons/*.xs, functions/**/*.xs, apis/**/*.xs"
2
+ applyTo: "addon/**/*.xs, function/**/*.xs, api/**/*.xs"
3
3
  ---
4
4
 
5
5
  # Addons
@@ -231,7 +231,7 @@ db.query product {
231
231
  ### File Structure
232
232
 
233
233
  ```
234
- addons/
234
+ addon/
235
235
  ├── comment_count.xs
236
236
  ├── like_count.xs
237
237
  ├── author_details.xs