@xano/developer-mcp 1.0.31 → 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +169 -6
- package/dist/index.d.ts +8 -0
- package/dist/index.js +14 -286
- package/dist/lib.d.ts +53 -0
- package/dist/lib.js +71 -0
- package/dist/tools/cli_docs.d.ts +40 -0
- package/dist/tools/cli_docs.js +68 -0
- package/dist/tools/index.d.ts +91 -0
- package/dist/tools/index.js +104 -0
- package/dist/tools/mcp_version.d.ts +45 -0
- package/dist/tools/mcp_version.js +94 -0
- package/dist/tools/meta_api_docs.d.ts +41 -0
- package/dist/tools/meta_api_docs.js +69 -0
- package/dist/tools/run_api_docs.d.ts +46 -0
- package/dist/tools/run_api_docs.js +69 -0
- package/dist/tools/types.d.ts +18 -0
- package/dist/tools/types.js +17 -0
- package/dist/tools/validate_xanoscript.d.ts +68 -0
- package/dist/tools/validate_xanoscript.js +114 -0
- package/dist/tools/xanoscript_docs.d.ts +72 -0
- package/dist/tools/xanoscript_docs.js +129 -0
- package/dist/xanoscript_docs/streaming.md +113 -91
- package/dist/xanoscript_docs/tasks.md +15 -7
- package/package.json +22 -3
|
@@ -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
|
+
};
|