@xano/developer-mcp 1.0.75 → 2.0.0-beta.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,43 +1,18 @@
1
1
  /**
2
2
  * Xano Developer MCP Tools
3
3
  *
4
- * This module exports all tools for both MCP server usage and standalone library usage.
5
- *
6
- * @example MCP Server Usage (internal)
7
- * ```ts
8
- * import { toolDefinitions, handleTool } from './tools/index.js';
9
- *
10
- * // Register tools with MCP server
11
- * server.setRequestHandler(ListToolsRequestSchema, () => ({
12
- * tools: toolDefinitions
13
- * }));
14
- * ```
15
- *
16
- * @example Library Usage (external)
17
- * ```ts
18
- * import {
19
- * validateXanoscript,
20
- * xanoscriptDocs,
21
- * metaApiDocs,
22
- * cliDocs,
23
- * mcpVersion
24
- * } from '@xano/developer-mcp';
25
- *
26
- * // Use tools directly
27
- * const result = validateXanoscript({ code: 'return 1 + 1' });
28
- * const docs = xanoscriptDocs({ topic: 'syntax' });
29
- * ```
4
+ * Exports all tools for both MCP server usage and standalone library usage.
5
+ * Tool registration goes through `toolSpecs` and `handleTool` below — the
6
+ * `toolSpecs` map is the single source of truth for which tools exist and
7
+ * the dispatch table in `handleTool` is statically required to cover every
8
+ * key, so a new tool cannot be registered without being routed.
30
9
  */
31
- // =============================================================================
32
- // Tool Imports
33
- // =============================================================================
34
- import { validateXanoscript, validateXanoscriptTool, validateXanoscriptToolDefinition, TYPE_ALIASES, RESERVED_VARIABLES, } from "./validate_xanoscript.js";
35
- import { xanoscriptDocs, xanoscriptDocsTool, xanoscriptDocsToolDefinition, getXanoscriptDocsPath, setXanoscriptDocsPath, } from "./xanoscript_docs.js";
36
- import { mcpVersion, mcpVersionTool, mcpVersionToolDefinition, getServerVersion, setServerVersion, } from "./mcp_version.js";
37
- import { metaApiDocs, metaApiDocsTool, metaApiDocsToolDefinition, metaApiTopics, getMetaApiTopicNames, getMetaApiTopicDescriptions, } from "./meta_api_docs.js";
38
- import { cliDocs, cliDocsTool, cliDocsToolDefinition, cliTopics, getCliTopicNames, getCliTopicDescriptions, } from "./cli_docs.js";
10
+ import { validateXanoscript, validateXanoscriptTool, validateXanoscriptToolSpec, TYPE_ALIASES, RESERVED_VARIABLES, } from "./validate_xanoscript.js";
11
+ import { xanoscriptDocs, xanoscriptDocsTool, xanoscriptDocsToolSpec, getXanoscriptDocsPath, setXanoscriptDocsPath, } from "./xanoscript_docs.js";
12
+ import { mcpVersion, mcpVersionTool, mcpVersionToolSpec, getServerVersion, setServerVersion, } from "./mcp_version.js";
13
+ import { metaApiDocs, metaApiDocsTool, metaApiDocsToolSpec, metaApiTopics, getMetaApiTopicNames, getMetaApiTopicDescriptions, } from "./meta_api_docs.js";
14
+ import { cliDocs, cliDocsTool, cliDocsToolSpec, cliTopics, getCliTopicNames, getCliTopicDescriptions, } from "./cli_docs.js";
39
15
  import { toMcpResponse } from "./types.js";
40
- import { z } from "zod";
41
16
  // =============================================================================
42
17
  // Standalone Tool Functions (for library usage)
43
18
  // =============================================================================
@@ -57,93 +32,89 @@ cliDocs, cliTopics, getCliTopicNames, getCliTopicDescriptions, toMcpResponse, };
57
32
  // =============================================================================
58
33
  export { validateXanoscriptTool, xanoscriptDocsTool, mcpVersionTool, metaApiDocsTool, cliDocsTool, };
59
34
  // =============================================================================
60
- // MCP Tool Definitions
35
+ // Tool Registry — single source of truth
61
36
  // =============================================================================
62
- export { validateXanoscriptToolDefinition, xanoscriptDocsToolDefinition, mcpVersionToolDefinition, metaApiDocsToolDefinition, cliDocsToolDefinition, };
63
37
  /**
64
- * All tool definitions for MCP server registration
38
+ * Full tool specs (Zod shapes + derived JSON Schema). Use these to register
39
+ * tools with `McpServer.registerTool` — descriptions live in the shapes and
40
+ * the JSON Schema can never drift from the parser.
65
41
  */
66
- export const toolDefinitions = [
67
- validateXanoscriptToolDefinition,
68
- xanoscriptDocsToolDefinition,
69
- mcpVersionToolDefinition,
70
- metaApiDocsToolDefinition,
71
- cliDocsToolDefinition,
72
- ];
42
+ export const toolSpecs = {
43
+ xano_validate_xanoscript: validateXanoscriptToolSpec,
44
+ xano_xanoscript_docs: xanoscriptDocsToolSpec,
45
+ xano_version: mcpVersionToolSpec,
46
+ xano_meta_api_docs: metaApiDocsToolSpec,
47
+ xano_cli_docs: cliDocsToolSpec,
48
+ };
49
+ /**
50
+ * Tool definitions array (derived from toolSpecs). Kept for callers that
51
+ * want a flat list to advertise.
52
+ */
53
+ export const toolDefinitions = Object.values(toolSpecs).map((spec) => spec.definition);
73
54
  // =============================================================================
74
- // Argument Schemas (Zod validation)
55
+ // Tool Handler (typed dispatch — adding to toolSpecs without adding here is
56
+ // a compile error)
75
57
  // =============================================================================
76
- const validateXanoscriptSchema = z.object({
77
- code: z.string().optional(),
78
- file_path: z.string().optional(),
79
- file_paths: z.array(z.string()).optional(),
80
- directory: z.string().optional(),
81
- pattern: z.string().optional(),
82
- });
83
- const xanoscriptDocsSchema = z.object({
84
- topic: z.string().optional(),
85
- file_path: z.string().optional(),
86
- mode: z.enum(["full", "quick_reference", "index"]).optional(),
87
- exclude_topics: z.array(z.string()).optional(),
88
- });
89
- const metaApiDocsSchema = z.object({
90
- topic: z.string(),
91
- detail_level: z.enum(["overview", "detailed", "examples"]).optional(),
92
- include_schemas: z.boolean().optional(),
93
- });
94
- const cliDocsSchema = z.object({
95
- topic: z.string(),
96
- detail_level: z.enum(["overview", "detailed", "examples"]).optional(),
97
- });
98
- function parseArgs(schema, args) {
99
- const result = schema.safeParse(args);
58
+ function parseWithSpec(spec, args) {
59
+ const result = spec.inputParser.safeParse(args);
100
60
  if (!result.success) {
101
61
  const issues = result.error.issues
102
- .map((i) => `${i.path.join(".")}: ${i.message}`)
62
+ .map((i) => {
63
+ const path = i.path.join(".") || "(root)";
64
+ return `${path} [${i.code}]: ${i.message}`;
65
+ })
103
66
  .join("; ");
104
- return { ok: false, error: { success: false, error: `Invalid arguments: ${issues}` } };
67
+ return {
68
+ ok: false,
69
+ error: { success: false, error: `Invalid arguments: ${issues}` },
70
+ };
105
71
  }
106
72
  return { ok: true, data: result.data };
107
73
  }
108
- // =============================================================================
109
- // Tool Handler (for MCP server)
110
- // =============================================================================
74
+ /**
75
+ * Dispatch table — every key in `toolSpecs` must have a handler here, or
76
+ * TypeScript will fail to compile. Adding a tool means: add to `toolSpecs`,
77
+ * then add a handler entry below.
78
+ */
79
+ const dispatch = {
80
+ async xano_validate_xanoscript(args) {
81
+ const parsed = parseWithSpec(validateXanoscriptToolSpec, args);
82
+ if (!parsed.ok)
83
+ return parsed.error;
84
+ return validateXanoscriptTool(parsed.data);
85
+ },
86
+ async xano_xanoscript_docs(args) {
87
+ const parsed = parseWithSpec(xanoscriptDocsToolSpec, args);
88
+ if (!parsed.ok)
89
+ return parsed.error;
90
+ return xanoscriptDocsTool(parsed.data);
91
+ },
92
+ async xano_version() {
93
+ return mcpVersionTool();
94
+ },
95
+ async xano_meta_api_docs(args) {
96
+ const parsed = parseWithSpec(metaApiDocsToolSpec, args);
97
+ if (!parsed.ok)
98
+ return parsed.error;
99
+ return metaApiDocsTool(parsed.data);
100
+ },
101
+ async xano_cli_docs(args) {
102
+ const parsed = parseWithSpec(cliDocsToolSpec, args);
103
+ if (!parsed.ok)
104
+ return parsed.error;
105
+ return cliDocsTool(parsed.data);
106
+ },
107
+ };
108
+ function isToolName(name) {
109
+ return name in dispatch;
110
+ }
111
111
  /**
112
112
  * Handle a tool call by name and return the result.
113
- * This is used by the MCP server to dispatch tool calls.
113
+ * Async to allow future tools that perform I/O without breaking the signature.
114
114
  */
115
- export function handleTool(name, args) {
116
- switch (name) {
117
- case "validate_xanoscript": {
118
- const parsed = parseArgs(validateXanoscriptSchema, args);
119
- if (!parsed.ok)
120
- return parsed.error;
121
- return validateXanoscriptTool(parsed.data);
122
- }
123
- case "xanoscript_docs": {
124
- const parsed = parseArgs(xanoscriptDocsSchema, args);
125
- if (!parsed.ok)
126
- return parsed.error;
127
- return xanoscriptDocsTool(parsed.data);
128
- }
129
- case "mcp_version":
130
- return mcpVersionTool();
131
- case "meta_api_docs": {
132
- const parsed = parseArgs(metaApiDocsSchema, args);
133
- if (!parsed.ok)
134
- return parsed.error;
135
- return metaApiDocsTool(parsed.data);
136
- }
137
- case "cli_docs": {
138
- const parsed = parseArgs(cliDocsSchema, args);
139
- if (!parsed.ok)
140
- return parsed.error;
141
- return cliDocsTool(parsed.data);
142
- }
143
- default:
144
- return {
145
- success: false,
146
- error: `Unknown tool: ${name}`,
147
- };
115
+ export async function handleTool(name, args) {
116
+ if (!isToolName(name)) {
117
+ return { success: false, error: `Unknown tool: ${name}` };
148
118
  }
119
+ return dispatch[name](args);
149
120
  }
@@ -4,6 +4,7 @@
4
4
  * Returns the current version of the Xano Developer MCP server.
5
5
  * Can be used standalone or within the MCP server.
6
6
  */
7
+ import { z } from "zod";
7
8
  import type { ToolResult } from "./types.js";
8
9
  export interface McpVersionResult {
9
10
  version: string;
@@ -34,28 +35,6 @@ export declare function mcpVersion(): McpVersionResult;
34
35
  * Get the MCP version and return a ToolResult.
35
36
  */
36
37
  export declare function mcpVersionTool(): ToolResult;
37
- export declare const mcpVersionToolDefinition: {
38
- name: string;
39
- annotations: {
40
- readOnlyHint: boolean;
41
- destructiveHint: boolean;
42
- idempotentHint: boolean;
43
- openWorldHint: boolean;
44
- };
45
- description: string;
46
- inputSchema: {
47
- type: string;
48
- properties: {};
49
- required: never[];
50
- };
51
- outputSchema: {
52
- type: string;
53
- properties: {
54
- version: {
55
- type: string;
56
- description: string;
57
- };
58
- };
59
- required: string[];
60
- };
61
- };
38
+ export declare const mcpVersionToolSpec: import("./define_tool.js").BuiltTool<{}, {
39
+ version: z.ZodString;
40
+ }>;
@@ -7,6 +7,8 @@
7
7
  import { readFileSync } from "fs";
8
8
  import { dirname, join } from "path";
9
9
  import { fileURLToPath } from "url";
10
+ import { z } from "zod";
11
+ import { defineTool } from "./define_tool.js";
10
12
  // =============================================================================
11
13
  // Version Resolution
12
14
  // =============================================================================
@@ -84,29 +86,20 @@ export function mcpVersionTool() {
84
86
  // =============================================================================
85
87
  // MCP Tool Definition
86
88
  // =============================================================================
87
- export const mcpVersionToolDefinition = {
88
- name: "mcp_version",
89
+ export const mcpVersionToolSpec = defineTool({
90
+ name: "xano_version",
91
+ description: "Get the current version of the Xano Developer MCP server. " +
92
+ "Returns the version string from package.json.",
89
93
  annotations: {
90
94
  readOnlyHint: true,
91
95
  destructiveHint: false,
92
96
  idempotentHint: true,
93
97
  openWorldHint: false,
94
98
  },
95
- description: "Get the current version of the Xano Developer MCP server. " +
96
- "Returns the version string from package.json.",
97
- inputSchema: {
98
- type: "object",
99
- properties: {},
100
- required: [],
101
- },
102
- outputSchema: {
103
- type: "object",
104
- properties: {
105
- version: {
106
- type: "string",
107
- description: "The semantic version string of the MCP server.",
108
- },
109
- },
110
- required: ["version"],
99
+ inputShape: {},
100
+ outputShape: {
101
+ version: z
102
+ .string()
103
+ .describe("The semantic version string of the MCP server."),
111
104
  },
112
- };
105
+ });
@@ -4,10 +4,10 @@
4
4
  * Retrieves documentation for Xano's Meta API.
5
5
  * Re-exports from the meta_api_docs module with ToolResult support.
6
6
  */
7
- import { metaApiDocsToolDefinition, topics, getTopicNames, getTopicDescriptions } from "../meta_api_docs/index.js";
7
+ import { metaApiDocsToolSpec, topics, getTopicNames, getTopicDescriptions } from "../meta_api_docs/index.js";
8
8
  import type { MetaApiDocsArgs, DetailLevel, TopicDoc } from "../meta_api_docs/types.js";
9
9
  import type { ToolResult } from "./types.js";
10
- export { metaApiDocsToolDefinition, topics as metaApiTopics, getTopicNames as getMetaApiTopicNames, getTopicDescriptions as getMetaApiTopicDescriptions, };
10
+ export { metaApiDocsToolSpec, topics as metaApiTopics, getTopicNames as getMetaApiTopicNames, getTopicDescriptions as getMetaApiTopicDescriptions, };
11
11
  export type { MetaApiDocsArgs, DetailLevel, TopicDoc };
12
12
  export interface MetaApiDocsResult {
13
13
  documentation: string;
@@ -38,4 +38,3 @@ export declare function metaApiDocs(args: MetaApiDocsArgs): MetaApiDocsResult;
38
38
  * Get Meta API documentation and return a ToolResult.
39
39
  */
40
40
  export declare function metaApiDocsTool(args: MetaApiDocsArgs): ToolResult;
41
- export { metaApiDocsToolDefinition as toolDefinition };
@@ -4,11 +4,11 @@
4
4
  * Retrieves documentation for Xano's Meta API.
5
5
  * Re-exports from the meta_api_docs module with ToolResult support.
6
6
  */
7
- import { handleMetaApiDocs as _handleMetaApiDocs, metaApiDocsToolDefinition, topics, getTopicNames, getTopicDescriptions, } from "../meta_api_docs/index.js";
7
+ import { handleMetaApiDocs as _handleMetaApiDocs, metaApiDocsToolSpec, topics, getTopicNames, getTopicDescriptions, } from "../meta_api_docs/index.js";
8
8
  // =============================================================================
9
9
  // Re-exports
10
10
  // =============================================================================
11
- export { metaApiDocsToolDefinition, topics as metaApiTopics, getTopicNames as getMetaApiTopicNames, getTopicDescriptions as getMetaApiTopicDescriptions, };
11
+ export { metaApiDocsToolSpec, topics as metaApiTopics, getTopicNames as getMetaApiTopicNames, getTopicDescriptions as getMetaApiTopicDescriptions, };
12
12
  // =============================================================================
13
13
  // Standalone Tool Function
14
14
  // =============================================================================
@@ -47,7 +47,7 @@ export function metaApiDocsTool(args) {
47
47
  if (!args?.topic) {
48
48
  return {
49
49
  success: false,
50
- error: "Error: 'topic' parameter is required. Use meta_api_docs with topic='start' for overview.",
50
+ error: "Error: 'topic' parameter is required. Use xano_meta_api_docs with topic='start' for overview.",
51
51
  };
52
52
  }
53
53
  try {
@@ -66,5 +66,3 @@ export function metaApiDocsTool(args) {
66
66
  };
67
67
  }
68
68
  }
69
- // Re-export tool definition for MCP
70
- export { metaApiDocsToolDefinition as toolDefinition };
@@ -10,19 +10,14 @@
10
10
  * - file_paths: Array of file paths for batch validation
11
11
  * - directory: Directory path with optional glob pattern
12
12
  */
13
+ import { z } from "zod";
13
14
  import type { ToolResult } from "./types.js";
14
- export interface ValidateXanoscriptArgs {
15
- /** The XanoScript code to validate (mutually exclusive with file_path/file_paths/directory) */
16
- code?: string;
17
- /** Path to a single XanoScript file to validate */
18
- file_path?: string;
19
- /** Array of file paths for batch validation */
20
- file_paths?: string[];
21
- /** Directory to validate (validates all .xs files recursively) */
22
- directory?: string;
23
- /** Glob pattern to filter files when using directory (default: "**\/*.xs") */
24
- pattern?: string;
25
- }
15
+ /**
16
+ * Arguments for `validateXanoscript`. Derived from the Zod input shape below
17
+ * (see `validateXanoscriptToolSpec`) so the runtime parser and the static
18
+ * type can never drift.
19
+ */
20
+ export type ValidateXanoscriptArgs = z.infer<typeof validateXanoscriptToolSpec.inputParser>;
26
21
  export declare const SEVERITY: {
27
22
  readonly ERROR: 1;
28
23
  readonly WARNING: 2;
@@ -113,57 +108,15 @@ export declare function validateXanoscript(args: ValidateXanoscriptArgs): Valida
113
108
  * Returns ToolResult format for consistent error handling.
114
109
  */
115
110
  export declare function validateXanoscriptTool(args: ValidateXanoscriptArgs): ToolResult;
116
- export declare const validateXanoscriptToolDefinition: {
117
- name: string;
118
- annotations: {
119
- readOnlyHint: boolean;
120
- destructiveHint: boolean;
121
- idempotentHint: boolean;
122
- openWorldHint: boolean;
123
- };
124
- description: string;
125
- inputSchema: {
126
- type: string;
127
- properties: {
128
- code: {
129
- type: string;
130
- description: string;
131
- };
132
- file_path: {
133
- type: string;
134
- description: string;
135
- };
136
- file_paths: {
137
- type: string;
138
- items: {
139
- type: string;
140
- };
141
- description: string;
142
- };
143
- directory: {
144
- type: string;
145
- description: string;
146
- };
147
- pattern: {
148
- type: string;
149
- description: string;
150
- };
151
- };
152
- required: never[];
153
- };
154
- outputSchema: {
155
- type: string;
156
- properties: {
157
- valid: {
158
- type: string;
159
- description: string;
160
- };
161
- message: {
162
- type: string;
163
- description: string;
164
- };
165
- };
166
- required: string[];
167
- };
168
- };
111
+ export declare const validateXanoscriptToolSpec: import("./define_tool.js").BuiltTool<{
112
+ code: z.ZodOptional<z.ZodString>;
113
+ file_path: z.ZodOptional<z.ZodString>;
114
+ file_paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
115
+ directory: z.ZodOptional<z.ZodString>;
116
+ pattern: z.ZodOptional<z.ZodString>;
117
+ }, {
118
+ valid: z.ZodBoolean;
119
+ message: z.ZodString;
120
+ warnings: z.ZodOptional<z.ZodNumber>;
121
+ }>;
169
122
  export { TYPE_ALIASES, RESERVED_VARIABLES };
@@ -15,6 +15,8 @@ import { getSchemeFromContent } from "@xano/xanoscript-language-server/utils.js"
15
15
  import { readFileSync, existsSync, readdirSync } from "fs";
16
16
  import { join, resolve, basename } from "path";
17
17
  import { minimatch } from "minimatch";
18
+ import { z } from "zod";
19
+ import { defineTool } from "./define_tool.js";
18
20
  export const SEVERITY = {
19
21
  ERROR: 1,
20
22
  WARNING: 2,
@@ -399,25 +401,26 @@ export function validateXanoscript(args) {
399
401
  export function validateXanoscriptTool(args) {
400
402
  const result = validateXanoscript(args);
401
403
  if (result.valid) {
404
+ const warnings = countWarnings(result);
402
405
  return {
403
406
  success: true,
404
407
  data: result.message,
405
- structuredContent: { valid: true, message: result.message },
408
+ structuredContent: { valid: true, message: result.message, warnings },
406
409
  };
407
410
  }
408
411
  return { success: false, error: result.message };
409
412
  }
413
+ function countWarnings(result) {
414
+ if ("errors" in result) {
415
+ return result.errors.filter((e) => e.severity === SEVERITY.WARNING).length;
416
+ }
417
+ return result.results.reduce((sum, r) => sum + r.errors.filter((e) => e.severity === SEVERITY.WARNING).length, 0);
418
+ }
410
419
  // =============================================================================
411
420
  // MCP Tool Definition
412
421
  // =============================================================================
413
- export const validateXanoscriptToolDefinition = {
414
- name: "validate_xanoscript",
415
- annotations: {
416
- readOnlyHint: true,
417
- destructiveHint: false,
418
- idempotentHint: true,
419
- openWorldHint: false,
420
- },
422
+ export const validateXanoscriptToolSpec = defineTool({
423
+ name: "xano_validate_xanoscript",
421
424
  description: "Validate XanoScript code for syntax errors. Supports multiple input methods:\n" +
422
425
  "- code: Raw XanoScript code as a string\n" +
423
426
  "- file_path: Path to a single .xs file (easier than escaping code!)\n" +
@@ -425,53 +428,52 @@ export const validateXanoscriptToolDefinition = {
425
428
  "- directory: Validate all .xs files in a directory\n\n" +
426
429
  "Returns errors with line/column positions and helpful suggestions for common mistakes. " +
427
430
  "The language server auto-detects the object type from the code syntax.",
428
- inputSchema: {
429
- type: "object",
430
- properties: {
431
- code: {
432
- type: "string",
433
- description: "The XanoScript code to validate as a string. Use file_path instead if the code contains special characters that are hard to escape. " +
434
- "Example: \"var $name:text = 'hello'\\nreturn $name\"",
435
- },
436
- file_path: {
437
- type: "string",
438
- description: "Path to a single XanoScript file to validate. Easier than passing code directly - avoids escaping issues. " +
439
- "Example: \"function/format.xs\"",
440
- },
441
- file_paths: {
442
- type: "array",
443
- items: { type: "string" },
444
- description: "Array of file paths for batch validation. Returns a summary with per-file results. " +
445
- "Example: [\"api/users/get.xs\", \"api/users/create.xs\", \"function/format.xs\"]",
446
- },
447
- directory: {
448
- type: "string",
449
- description: "Directory path to validate. Validates all .xs files recursively. Use with 'pattern' to filter specific subdirectories or files. " +
450
- "Example: \"api/users\"",
451
- },
452
- pattern: {
453
- type: "string",
454
- description: "Glob pattern to filter files when using 'directory' (default: \"**/*.xs\"). " +
455
- "Examples: \"api/**/*.xs\" to match only API files, \"**/create.xs\" to match all create files.",
456
- },
457
- },
458
- required: [],
431
+ annotations: {
432
+ readOnlyHint: true,
433
+ destructiveHint: false,
434
+ idempotentHint: true,
435
+ openWorldHint: false,
459
436
  },
460
- outputSchema: {
461
- type: "object",
462
- properties: {
463
- valid: {
464
- type: "boolean",
465
- description: "Whether the code passed validation without errors.",
466
- },
467
- message: {
468
- type: "string",
469
- description: "Human-readable validation summary with error details if any.",
470
- },
471
- },
472
- required: ["valid", "message"],
437
+ inputShape: {
438
+ code: z
439
+ .string()
440
+ .optional()
441
+ .describe("The XanoScript code to validate as a string. Use file_path instead if the code contains special characters that are hard to escape. " +
442
+ "Example: \"var $name:text = 'hello'\\nreturn $name\""),
443
+ file_path: z
444
+ .string()
445
+ .optional()
446
+ .describe("Path to a single XanoScript file to validate. Easier than passing code directly - avoids escaping issues. " +
447
+ 'Example: "function/format.xs"'),
448
+ file_paths: z
449
+ .array(z.string())
450
+ .optional()
451
+ .describe("Array of file paths for batch validation. Returns a summary with per-file results. " +
452
+ 'Example: ["api/users/get.xs", "api/users/create.xs", "function/format.xs"]'),
453
+ directory: z
454
+ .string()
455
+ .optional()
456
+ .describe("Directory path to validate. Validates all .xs files recursively. Use with 'pattern' to filter specific subdirectories or files. " +
457
+ 'Example: "api/users"'),
458
+ pattern: z
459
+ .string()
460
+ .optional()
461
+ .describe('Glob pattern to filter files when using \'directory\' (default: "**/*.xs"). ' +
462
+ 'Examples: "api/**/*.xs" to match only API files, "**/create.xs" to match all create files.'),
473
463
  },
474
- };
464
+ outputShape: {
465
+ valid: z
466
+ .boolean()
467
+ .describe("Whether the code passed validation without errors."),
468
+ message: z
469
+ .string()
470
+ .describe("Human-readable validation summary with error details if any."),
471
+ warnings: z
472
+ .number()
473
+ .optional()
474
+ .describe("Number of non-fatal warnings encountered, if any."),
475
+ },
476
+ });
475
477
  // =============================================================================
476
478
  // Utility Exports
477
479
  // =============================================================================