@xano/developer-mcp 1.0.20 → 1.0.22
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 +100 -19
- package/dist/index.js +4 -227
- package/dist/meta_api_docs/format.d.ts +16 -1
- package/dist/meta_api_docs/format.js +24 -6
- package/dist/meta_api_docs/format.test.d.ts +1 -0
- package/dist/meta_api_docs/format.test.js +274 -0
- package/dist/meta_api_docs/index.test.d.ts +1 -0
- package/dist/meta_api_docs/index.test.js +128 -0
- package/dist/meta_api_docs/types.test.d.ts +1 -0
- package/dist/meta_api_docs/types.test.js +132 -0
- package/dist/run_api_docs/format.d.ts +1 -0
- package/dist/run_api_docs/format.js +3 -170
- package/dist/run_api_docs/format.test.d.ts +1 -0
- package/dist/run_api_docs/format.test.js +86 -0
- package/dist/run_api_docs/index.test.d.ts +1 -0
- package/dist/run_api_docs/index.test.js +127 -0
- package/dist/templates/init-workspace.js +4 -4
- package/dist/templates/xanoscript-index.d.ts +3 -1
- package/dist/templates/xanoscript-index.js +54 -51
- package/dist/xanoscript.d.ts +41 -0
- package/dist/xanoscript.js +261 -0
- package/dist/xanoscript.test.d.ts +1 -0
- package/dist/xanoscript.test.js +303 -0
- package/dist/xanoscript_docs/README.md +53 -37
- package/dist/xanoscript_docs/agents.md +1 -1
- package/dist/xanoscript_docs/apis.md +6 -3
- package/dist/xanoscript_docs/branch.md +239 -0
- package/dist/xanoscript_docs/functions.md +6 -6
- package/dist/xanoscript_docs/integrations.md +43 -1
- package/dist/xanoscript_docs/middleware.md +321 -0
- package/dist/xanoscript_docs/performance.md +1 -1
- package/dist/xanoscript_docs/realtime.md +113 -1
- package/dist/xanoscript_docs/tasks.md +2 -2
- package/dist/xanoscript_docs/tools.md +3 -3
- package/dist/xanoscript_docs/types.md +25 -8
- package/dist/xanoscript_docs/workspace.md +209 -0
- package/dist/xanoscript_docs_auto/README.md +119 -0
- package/dist/xanoscript_docs_auto/agents.md +446 -0
- package/dist/xanoscript_docs_auto/apis.md +517 -0
- package/dist/xanoscript_docs_auto/control-flow.md +543 -0
- package/dist/xanoscript_docs_auto/database.md +551 -0
- package/dist/xanoscript_docs_auto/debugging.md +527 -0
- package/dist/xanoscript_docs_auto/filters.md +464 -0
- package/dist/xanoscript_docs_auto/functions.md +431 -0
- package/dist/xanoscript_docs_auto/integrations.md +657 -0
- package/dist/xanoscript_docs_auto/mcp-servers.md +408 -0
- package/dist/xanoscript_docs_auto/operators.md +368 -0
- package/dist/xanoscript_docs_auto/syntax.md +287 -0
- package/dist/xanoscript_docs_auto/tables.md +447 -0
- package/dist/xanoscript_docs_auto/tasks.md +479 -0
- package/dist/xanoscript_docs_auto/testing.md +574 -0
- package/dist/xanoscript_docs_auto/tools.md +485 -0
- package/dist/xanoscript_docs_auto/triggers.md +595 -0
- package/dist/xanoscript_docs_auto/types.md +323 -0
- package/dist/xanoscript_docs_auto/variables.md +462 -0
- package/dist/xanoscript_docs_auto/version.json +5 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -355,31 +355,40 @@ The server also exposes XanoScript documentation as MCP resources for direct acc
|
|
|
355
355
|
| `build` | `tsc` | Compile TypeScript to JavaScript |
|
|
356
356
|
| `start` | `node dist/index.js` | Run the MCP server |
|
|
357
357
|
| `dev` | `tsc && node dist/index.js` | Build and run in development |
|
|
358
|
+
| `test` | `vitest run` | Run unit tests |
|
|
359
|
+
| `test:watch` | `vitest` | Run tests in watch mode |
|
|
360
|
+
| `test:coverage` | `vitest run --coverage` | Run tests with coverage report |
|
|
358
361
|
|
|
359
362
|
## Project Structure
|
|
360
363
|
|
|
361
364
|
```
|
|
362
365
|
xano-developer-mcp/
|
|
363
366
|
├── src/
|
|
364
|
-
│ ├── index.ts
|
|
365
|
-
│ ├── xanoscript.
|
|
366
|
-
│ ├──
|
|
367
|
-
│
|
|
368
|
-
│
|
|
369
|
-
│ │ ├──
|
|
370
|
-
│ │
|
|
371
|
-
│ ├──
|
|
372
|
-
│ │ ├──
|
|
373
|
-
│ │ ├── format.ts
|
|
374
|
-
│ │
|
|
375
|
-
│
|
|
376
|
-
│
|
|
377
|
-
│ │ ├──
|
|
378
|
-
│ │ ├──
|
|
379
|
-
│ │
|
|
380
|
-
│
|
|
381
|
-
│
|
|
382
|
-
|
|
367
|
+
│ ├── index.ts # Main MCP server implementation
|
|
368
|
+
│ ├── xanoscript.ts # XanoScript documentation logic
|
|
369
|
+
│ ├── xanoscript.test.ts # Tests for xanoscript module
|
|
370
|
+
│ ├── xanoscript-language-server.d.ts # TypeScript declarations
|
|
371
|
+
│ ├── meta_api_docs/ # Meta API documentation
|
|
372
|
+
│ │ ├── index.ts # API docs tool handler
|
|
373
|
+
│ │ ├── index.test.ts # Tests for index
|
|
374
|
+
│ │ ├── types.ts # Type definitions
|
|
375
|
+
│ │ ├── types.test.ts # Tests for types
|
|
376
|
+
│ │ ├── format.ts # Documentation formatter
|
|
377
|
+
│ │ ├── format.test.ts # Tests for formatter
|
|
378
|
+
│ │ └── topics/ # Individual topic modules
|
|
379
|
+
│ ├── run_api_docs/ # Run API documentation
|
|
380
|
+
│ │ ├── index.ts # Run API tool handler
|
|
381
|
+
│ │ ├── index.test.ts # Tests for index
|
|
382
|
+
│ │ ├── format.ts # Documentation formatter
|
|
383
|
+
│ │ ├── format.test.ts # Tests for formatter
|
|
384
|
+
│ │ └── topics/ # Individual topic modules
|
|
385
|
+
│ └── xanoscript_docs/ # XanoScript language documentation
|
|
386
|
+
│ ├── version.json
|
|
387
|
+
│ ├── README.md
|
|
388
|
+
│ ├── syntax.md
|
|
389
|
+
│ └── ...
|
|
390
|
+
├── dist/ # Compiled JavaScript output
|
|
391
|
+
├── vitest.config.ts # Test configuration
|
|
383
392
|
├── package.json
|
|
384
393
|
└── tsconfig.json
|
|
385
394
|
```
|
|
@@ -392,6 +401,15 @@ xano-developer-mcp/
|
|
|
392
401
|
| `@xano/xanoscript-language-server` | ^11.6.3 | XanoScript parser and validation |
|
|
393
402
|
| `minimatch` | ^10.1.2 | Glob pattern matching for context-aware docs |
|
|
394
403
|
|
|
404
|
+
### Dev Dependencies
|
|
405
|
+
|
|
406
|
+
| Package | Version | Purpose |
|
|
407
|
+
|---------|---------|---------|
|
|
408
|
+
| `typescript` | ^5.9.0 | TypeScript compiler |
|
|
409
|
+
| `vitest` | ^3.0.0 | Fast unit test framework |
|
|
410
|
+
| `@types/node` | ^22.0.0 | Node.js type definitions |
|
|
411
|
+
| `@types/minimatch` | ^5.1.2 | Minimatch type definitions |
|
|
412
|
+
|
|
395
413
|
## How It Works
|
|
396
414
|
|
|
397
415
|
```
|
|
@@ -444,6 +462,69 @@ Compiles TypeScript to JavaScript in the `dist/` directory.
|
|
|
444
462
|
- Supports parameterized output (detail levels, schema inclusion)
|
|
445
463
|
- Better for AI consumption due to context efficiency
|
|
446
464
|
|
|
465
|
+
## Testing
|
|
466
|
+
|
|
467
|
+
The project uses [Vitest](https://vitest.dev/) as its test framework with comprehensive unit tests.
|
|
468
|
+
|
|
469
|
+
### Running Tests
|
|
470
|
+
|
|
471
|
+
```bash
|
|
472
|
+
# Run all tests
|
|
473
|
+
npm test
|
|
474
|
+
|
|
475
|
+
# Run tests in watch mode (re-runs on file changes)
|
|
476
|
+
npm run test:watch
|
|
477
|
+
|
|
478
|
+
# Run tests with coverage report
|
|
479
|
+
npm run test:coverage
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
### Test Coverage
|
|
483
|
+
|
|
484
|
+
| Module | Test File | Description |
|
|
485
|
+
|--------|-----------|-------------|
|
|
486
|
+
| `xanoscript.ts` | `xanoscript.test.ts` | Core XanoScript documentation logic including file path matching and quick reference extraction |
|
|
487
|
+
| `meta_api_docs/index.ts` | `meta_api_docs/index.test.ts` | Meta API documentation handler and topic management |
|
|
488
|
+
| `meta_api_docs/format.ts` | `meta_api_docs/format.test.ts` | Documentation formatting for endpoints, examples, and patterns |
|
|
489
|
+
| `meta_api_docs/types.ts` | `meta_api_docs/types.test.ts` | Type structure validation |
|
|
490
|
+
| `run_api_docs/index.ts` | `run_api_docs/index.test.ts` | Run API documentation handler |
|
|
491
|
+
| `run_api_docs/format.ts` | `run_api_docs/format.test.ts` | Run API formatting with correct base URL |
|
|
492
|
+
|
|
493
|
+
### Test Structure
|
|
494
|
+
|
|
495
|
+
Tests are co-located with source files using the `.test.ts` suffix:
|
|
496
|
+
|
|
497
|
+
```
|
|
498
|
+
src/
|
|
499
|
+
├── xanoscript.ts
|
|
500
|
+
├── xanoscript.test.ts # Tests for xanoscript.ts
|
|
501
|
+
├── meta_api_docs/
|
|
502
|
+
│ ├── index.ts
|
|
503
|
+
│ ├── index.test.ts # Tests for index.ts
|
|
504
|
+
│ ├── format.ts
|
|
505
|
+
│ ├── format.test.ts # Tests for format.ts
|
|
506
|
+
│ └── ...
|
|
507
|
+
└── run_api_docs/
|
|
508
|
+
├── index.ts
|
|
509
|
+
├── index.test.ts # Tests for index.ts
|
|
510
|
+
└── ...
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### Writing Tests
|
|
514
|
+
|
|
515
|
+
Tests use Vitest's API which is compatible with Jest:
|
|
516
|
+
|
|
517
|
+
```typescript
|
|
518
|
+
import { describe, it, expect } from "vitest";
|
|
519
|
+
import { myFunction } from "./myModule.js";
|
|
520
|
+
|
|
521
|
+
describe("myFunction", () => {
|
|
522
|
+
it("should return expected result", () => {
|
|
523
|
+
expect(myFunction("input")).toBe("expected");
|
|
524
|
+
});
|
|
525
|
+
});
|
|
526
|
+
```
|
|
527
|
+
|
|
447
528
|
## License
|
|
448
529
|
|
|
449
530
|
See [LICENSE](LICENSE) for details.
|
package/dist/index.js
CHANGED
|
@@ -5,11 +5,11 @@ import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSche
|
|
|
5
5
|
import { readFileSync } from "fs";
|
|
6
6
|
import { fileURLToPath } from "url";
|
|
7
7
|
import { dirname, join } from "path";
|
|
8
|
-
import { minimatch } from "minimatch";
|
|
9
8
|
import { xanoscriptParser } from "@xano/xanoscript-language-server/parser/parser.js";
|
|
10
9
|
import { getSchemeFromContent } from "@xano/xanoscript-language-server/utils.js";
|
|
11
10
|
import { metaApiDocsToolDefinition, handleMetaApiDocs } from "./meta_api_docs/index.js";
|
|
12
11
|
import { runApiDocsToolDefinition, handleRunApiDocs } from "./run_api_docs/index.js";
|
|
12
|
+
import { XANOSCRIPT_DOCS_V2, readXanoscriptDocsV2, getXanoscriptDocsVersion, getTopicDescriptions, } from "./xanoscript.js";
|
|
13
13
|
const __filename = fileURLToPath(import.meta.url);
|
|
14
14
|
const __dirname = dirname(__filename);
|
|
15
15
|
const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
|
|
@@ -18,123 +18,6 @@ if (process.argv.includes("--version") || process.argv.includes("-v")) {
|
|
|
18
18
|
console.log(SERVER_VERSION);
|
|
19
19
|
process.exit(0);
|
|
20
20
|
}
|
|
21
|
-
const XANOSCRIPT_DOCS_V2 = {
|
|
22
|
-
readme: {
|
|
23
|
-
file: "README.md",
|
|
24
|
-
applyTo: [],
|
|
25
|
-
description: "XanoScript overview, workspace structure, and quick reference",
|
|
26
|
-
},
|
|
27
|
-
syntax: {
|
|
28
|
-
file: "syntax.md",
|
|
29
|
-
applyTo: ["**/*.xs"],
|
|
30
|
-
description: "Expressions, operators, and filters for all XanoScript code",
|
|
31
|
-
},
|
|
32
|
-
types: {
|
|
33
|
-
file: "types.md",
|
|
34
|
-
applyTo: ["functions/**/*.xs", "apis/**/*.xs", "tools/**/*.xs", "agents/**/*.xs"],
|
|
35
|
-
description: "Data types, input blocks, and validation",
|
|
36
|
-
},
|
|
37
|
-
tables: {
|
|
38
|
-
file: "tables.md",
|
|
39
|
-
applyTo: ["tables/*.xs"],
|
|
40
|
-
description: "Database schema definitions with indexes and relationships",
|
|
41
|
-
},
|
|
42
|
-
functions: {
|
|
43
|
-
file: "functions.md",
|
|
44
|
-
applyTo: ["functions/**/*.xs"],
|
|
45
|
-
description: "Reusable function stacks with inputs and responses",
|
|
46
|
-
},
|
|
47
|
-
apis: {
|
|
48
|
-
file: "apis.md",
|
|
49
|
-
applyTo: ["apis/**/*.xs"],
|
|
50
|
-
description: "HTTP endpoint definitions with authentication and CRUD patterns",
|
|
51
|
-
},
|
|
52
|
-
tasks: {
|
|
53
|
-
file: "tasks.md",
|
|
54
|
-
applyTo: ["tasks/*.xs"],
|
|
55
|
-
description: "Scheduled and cron jobs",
|
|
56
|
-
},
|
|
57
|
-
triggers: {
|
|
58
|
-
file: "triggers.md",
|
|
59
|
-
applyTo: ["triggers/**/*.xs"],
|
|
60
|
-
description: "Event-driven handlers (table, realtime, workspace, agent, MCP)",
|
|
61
|
-
},
|
|
62
|
-
database: {
|
|
63
|
-
file: "database.md",
|
|
64
|
-
applyTo: ["functions/**/*.xs", "apis/**/*.xs", "tasks/*.xs", "tools/**/*.xs"],
|
|
65
|
-
description: "All db.* operations: query, get, add, edit, patch, delete",
|
|
66
|
-
},
|
|
67
|
-
agents: {
|
|
68
|
-
file: "agents.md",
|
|
69
|
-
applyTo: ["agents/**/*.xs"],
|
|
70
|
-
description: "AI agent configuration with LLM providers and tools",
|
|
71
|
-
},
|
|
72
|
-
tools: {
|
|
73
|
-
file: "tools.md",
|
|
74
|
-
applyTo: ["tools/**/*.xs"],
|
|
75
|
-
description: "AI tools for agents and MCP servers",
|
|
76
|
-
},
|
|
77
|
-
"mcp-servers": {
|
|
78
|
-
file: "mcp-servers.md",
|
|
79
|
-
applyTo: ["mcp_servers/**/*.xs"],
|
|
80
|
-
description: "MCP server definitions exposing tools",
|
|
81
|
-
},
|
|
82
|
-
testing: {
|
|
83
|
-
file: "testing.md",
|
|
84
|
-
applyTo: ["functions/**/*.xs", "apis/**/*.xs"],
|
|
85
|
-
description: "Unit tests, mocks, and assertions",
|
|
86
|
-
},
|
|
87
|
-
integrations: {
|
|
88
|
-
file: "integrations.md",
|
|
89
|
-
applyTo: ["functions/**/*.xs", "apis/**/*.xs", "tasks/*.xs"],
|
|
90
|
-
description: "Cloud storage, Redis, security, and external APIs",
|
|
91
|
-
},
|
|
92
|
-
frontend: {
|
|
93
|
-
file: "frontend.md",
|
|
94
|
-
applyTo: ["static/**/*"],
|
|
95
|
-
description: "Static frontend development and deployment",
|
|
96
|
-
},
|
|
97
|
-
run: {
|
|
98
|
-
file: "run.md",
|
|
99
|
-
applyTo: ["run/**/*.xs"],
|
|
100
|
-
description: "Run job and service configurations for the Xano Job Runner",
|
|
101
|
-
},
|
|
102
|
-
addons: {
|
|
103
|
-
file: "addons.md",
|
|
104
|
-
applyTo: ["addons/*.xs", "functions/**/*.xs", "apis/**/*.xs"],
|
|
105
|
-
description: "Reusable subqueries for fetching related data",
|
|
106
|
-
},
|
|
107
|
-
debugging: {
|
|
108
|
-
file: "debugging.md",
|
|
109
|
-
applyTo: ["**/*.xs"],
|
|
110
|
-
description: "Logging, inspecting, and debugging XanoScript execution",
|
|
111
|
-
},
|
|
112
|
-
performance: {
|
|
113
|
-
file: "performance.md",
|
|
114
|
-
applyTo: ["functions/**/*.xs", "apis/**/*.xs"],
|
|
115
|
-
description: "Performance optimization best practices",
|
|
116
|
-
},
|
|
117
|
-
realtime: {
|
|
118
|
-
file: "realtime.md",
|
|
119
|
-
applyTo: ["functions/**/*.xs", "apis/**/*.xs", "triggers/**/*.xs"],
|
|
120
|
-
description: "Real-time channels and events for push updates",
|
|
121
|
-
},
|
|
122
|
-
schema: {
|
|
123
|
-
file: "schema.md",
|
|
124
|
-
applyTo: ["functions/**/*.xs", "apis/**/*.xs"],
|
|
125
|
-
description: "Runtime schema parsing and validation",
|
|
126
|
-
},
|
|
127
|
-
security: {
|
|
128
|
-
file: "security.md",
|
|
129
|
-
applyTo: ["functions/**/*.xs", "apis/**/*.xs"],
|
|
130
|
-
description: "Security best practices for authentication and authorization",
|
|
131
|
-
},
|
|
132
|
-
streaming: {
|
|
133
|
-
file: "streaming.md",
|
|
134
|
-
applyTo: ["functions/**/*.xs", "apis/**/*.xs"],
|
|
135
|
-
description: "Streaming data from files, requests, and responses",
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
21
|
// =============================================================================
|
|
139
22
|
// Path Resolution
|
|
140
23
|
// =============================================================================
|
|
@@ -156,109 +39,6 @@ function getXanoscriptDocsPath() {
|
|
|
156
39
|
}
|
|
157
40
|
const XANOSCRIPT_DOCS_PATH = getXanoscriptDocsPath();
|
|
158
41
|
// =============================================================================
|
|
159
|
-
// Documentation Helpers
|
|
160
|
-
// =============================================================================
|
|
161
|
-
function getXanoscriptDocsVersion() {
|
|
162
|
-
try {
|
|
163
|
-
const versionFile = readFileSync(join(XANOSCRIPT_DOCS_PATH, "version.json"), "utf-8");
|
|
164
|
-
return JSON.parse(versionFile).version || "unknown";
|
|
165
|
-
}
|
|
166
|
-
catch {
|
|
167
|
-
return "unknown";
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
// =============================================================================
|
|
171
|
-
// XanoScript Documentation v2 Functions
|
|
172
|
-
// =============================================================================
|
|
173
|
-
/**
|
|
174
|
-
* Get list of topics that apply to a given file path based on applyTo patterns
|
|
175
|
-
*/
|
|
176
|
-
function getDocsForFilePath(filePath) {
|
|
177
|
-
const matches = [];
|
|
178
|
-
for (const [topic, config] of Object.entries(XANOSCRIPT_DOCS_V2)) {
|
|
179
|
-
if (topic === "readme")
|
|
180
|
-
continue; // Don't auto-include readme
|
|
181
|
-
for (const pattern of config.applyTo) {
|
|
182
|
-
if (minimatch(filePath, pattern)) {
|
|
183
|
-
matches.push(topic);
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
// Always include syntax as foundation (if not already matched)
|
|
189
|
-
if (!matches.includes("syntax")) {
|
|
190
|
-
matches.unshift("syntax");
|
|
191
|
-
}
|
|
192
|
-
return matches;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Extract just the Quick Reference section from a doc
|
|
196
|
-
*/
|
|
197
|
-
function extractQuickReference(content, topic) {
|
|
198
|
-
const lines = content.split("\n");
|
|
199
|
-
const startIdx = lines.findIndex((l) => l.startsWith("## Quick Reference"));
|
|
200
|
-
if (startIdx === -1) {
|
|
201
|
-
// Fallback: return first 50 lines or up to first ## section
|
|
202
|
-
const firstSection = lines.findIndex((l, i) => i > 0 && l.startsWith("## "));
|
|
203
|
-
return lines.slice(0, firstSection > 0 ? firstSection : 50).join("\n");
|
|
204
|
-
}
|
|
205
|
-
// Find the next ## section after Quick Reference
|
|
206
|
-
let endIdx = lines.findIndex((l, i) => i > startIdx && l.startsWith("## "));
|
|
207
|
-
if (endIdx === -1)
|
|
208
|
-
endIdx = lines.length;
|
|
209
|
-
// Include topic header for context
|
|
210
|
-
const header = `# ${topic}\n\n`;
|
|
211
|
-
return header + lines.slice(startIdx, endIdx).join("\n");
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Read XanoScript documentation with new v2 structure
|
|
215
|
-
*/
|
|
216
|
-
function readXanoscriptDocsV2(args) {
|
|
217
|
-
const mode = args?.mode || "full";
|
|
218
|
-
const version = getXanoscriptDocsVersion();
|
|
219
|
-
try {
|
|
220
|
-
// Default: return README
|
|
221
|
-
if (!args?.topic && !args?.file_path) {
|
|
222
|
-
const readme = readFileSync(join(XANOSCRIPT_DOCS_PATH, "README.md"), "utf-8");
|
|
223
|
-
return `${readme}\n\n---\nDocumentation version: ${version}`;
|
|
224
|
-
}
|
|
225
|
-
// Context-aware: return docs matching file pattern
|
|
226
|
-
if (args?.file_path) {
|
|
227
|
-
const topics = getDocsForFilePath(args.file_path);
|
|
228
|
-
if (topics.length === 0) {
|
|
229
|
-
return `No documentation found for file pattern: ${args.file_path}\n\nAvailable topics: ${Object.keys(XANOSCRIPT_DOCS_V2).join(", ")}`;
|
|
230
|
-
}
|
|
231
|
-
const docs = topics.map((t) => {
|
|
232
|
-
const config = XANOSCRIPT_DOCS_V2[t];
|
|
233
|
-
const content = readFileSync(join(XANOSCRIPT_DOCS_PATH, config.file), "utf-8");
|
|
234
|
-
return mode === "quick_reference"
|
|
235
|
-
? extractQuickReference(content, t)
|
|
236
|
-
: content;
|
|
237
|
-
});
|
|
238
|
-
const header = `# XanoScript Documentation for: ${args.file_path}\n\nMatched topics: ${topics.join(", ")}\nMode: ${mode}\nVersion: ${version}\n\n---\n\n`;
|
|
239
|
-
return header + docs.join("\n\n---\n\n");
|
|
240
|
-
}
|
|
241
|
-
// Topic-based: return specific doc
|
|
242
|
-
if (args?.topic) {
|
|
243
|
-
const config = XANOSCRIPT_DOCS_V2[args.topic];
|
|
244
|
-
if (!config) {
|
|
245
|
-
const availableTopics = Object.keys(XANOSCRIPT_DOCS_V2).join(", ");
|
|
246
|
-
return `Error: Unknown topic "${args.topic}".\n\nAvailable topics: ${availableTopics}`;
|
|
247
|
-
}
|
|
248
|
-
const content = readFileSync(join(XANOSCRIPT_DOCS_PATH, config.file), "utf-8");
|
|
249
|
-
const doc = mode === "quick_reference"
|
|
250
|
-
? extractQuickReference(content, args.topic)
|
|
251
|
-
: content;
|
|
252
|
-
return `${doc}\n\n---\nDocumentation version: ${version}`;
|
|
253
|
-
}
|
|
254
|
-
return "Error: Invalid parameters";
|
|
255
|
-
}
|
|
256
|
-
catch (error) {
|
|
257
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
258
|
-
return `Error reading XanoScript documentation: ${errorMessage}`;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
// =============================================================================
|
|
262
42
|
// MCP Server Setup
|
|
263
43
|
// =============================================================================
|
|
264
44
|
const server = new Server({
|
|
@@ -295,7 +75,7 @@ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
|
295
75
|
throw new Error(`Unknown topic: ${topic}. Available: ${Object.keys(XANOSCRIPT_DOCS_V2).join(", ")}`);
|
|
296
76
|
}
|
|
297
77
|
const content = readFileSync(join(XANOSCRIPT_DOCS_PATH, config.file), "utf-8");
|
|
298
|
-
const version = getXanoscriptDocsVersion();
|
|
78
|
+
const version = getXanoscriptDocsVersion(XANOSCRIPT_DOCS_PATH);
|
|
299
79
|
return {
|
|
300
80
|
contents: [
|
|
301
81
|
{
|
|
@@ -337,10 +117,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
337
117
|
properties: {
|
|
338
118
|
topic: {
|
|
339
119
|
type: "string",
|
|
340
|
-
description: "Documentation topic. Available: " +
|
|
341
|
-
Object.entries(XANOSCRIPT_DOCS_V2)
|
|
342
|
-
.map(([k, v]) => `${k} (${v.description.split(".")[0]})`)
|
|
343
|
-
.join(", "),
|
|
120
|
+
description: "Documentation topic. Available: " + getTopicDescriptions(),
|
|
344
121
|
},
|
|
345
122
|
file_path: {
|
|
346
123
|
type: "string",
|
|
@@ -447,7 +224,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
447
224
|
}
|
|
448
225
|
if (request.params.name === "xanoscript_docs") {
|
|
449
226
|
const args = request.params.arguments;
|
|
450
|
-
const documentation = readXanoscriptDocsV2(args);
|
|
227
|
+
const documentation = readXanoscriptDocsV2(XANOSCRIPT_DOCS_PATH, args);
|
|
451
228
|
return {
|
|
452
229
|
content: [
|
|
453
230
|
{
|
|
@@ -2,4 +2,19 @@
|
|
|
2
2
|
* Formatting utilities for API documentation output
|
|
3
3
|
*/
|
|
4
4
|
import type { TopicDoc, DetailLevel } from "./types.js";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for documentation formatting
|
|
7
|
+
*/
|
|
8
|
+
export interface FormatConfig {
|
|
9
|
+
baseUrlInfo: string;
|
|
10
|
+
toolName: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Default config for Meta API
|
|
14
|
+
*/
|
|
15
|
+
export declare const META_API_CONFIG: FormatConfig;
|
|
16
|
+
/**
|
|
17
|
+
* Config for Run API
|
|
18
|
+
*/
|
|
19
|
+
export declare const RUN_API_CONFIG: FormatConfig;
|
|
20
|
+
export declare function formatDocumentation(doc: TopicDoc, detailLevel?: DetailLevel, includeSchemas?: boolean, config?: FormatConfig): string;
|
|
@@ -2,14 +2,32 @@
|
|
|
2
2
|
* Formatting utilities for API documentation output
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Default config for Meta API
|
|
6
6
|
*/
|
|
7
|
-
const
|
|
7
|
+
export const META_API_CONFIG = {
|
|
8
|
+
baseUrlInfo: `## Base URL
|
|
8
9
|
\`\`\`
|
|
9
10
|
https://<your-instance-subdomain>.xano.io/api:meta/<endpoint>
|
|
10
11
|
\`\`\`
|
|
11
12
|
Authorization: \`Bearer <your-access-token>\`
|
|
12
|
-
|
|
13
|
+
`,
|
|
14
|
+
toolName: "meta_api_docs",
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Config for Run API
|
|
18
|
+
*/
|
|
19
|
+
export const RUN_API_CONFIG = {
|
|
20
|
+
baseUrlInfo: `## Base URL
|
|
21
|
+
\`\`\`
|
|
22
|
+
https://app.dev.xano.com/api:run/<endpoint>
|
|
23
|
+
\`\`\`
|
|
24
|
+
|
|
25
|
+
**Important:** This is a fixed URL - NOT your Xano instance URL. All Run API requests go to this central endpoint.
|
|
26
|
+
|
|
27
|
+
Authorization: \`Bearer <your-access-token>\`
|
|
28
|
+
`,
|
|
29
|
+
toolName: "run_api_docs",
|
|
30
|
+
};
|
|
13
31
|
function formatParameter(param) {
|
|
14
32
|
const required = param.required ? " (required)" : "";
|
|
15
33
|
const defaultVal = param.default !== undefined ? ` [default: ${param.default}]` : "";
|
|
@@ -109,7 +127,7 @@ function formatPattern(pattern) {
|
|
|
109
127
|
}
|
|
110
128
|
return lines.join("\n");
|
|
111
129
|
}
|
|
112
|
-
export function formatDocumentation(doc, detailLevel = "detailed", includeSchemas = true) {
|
|
130
|
+
export function formatDocumentation(doc, detailLevel = "detailed", includeSchemas = true, config = META_API_CONFIG) {
|
|
113
131
|
const sections = [];
|
|
114
132
|
// Header
|
|
115
133
|
sections.push(`# ${doc.title}`);
|
|
@@ -124,7 +142,7 @@ export function formatDocumentation(doc, detailLevel = "detailed", includeSchema
|
|
|
124
142
|
// Include base URL info if topic has endpoints or patterns (workflows)
|
|
125
143
|
if (doc.endpoints?.length || doc.patterns?.length) {
|
|
126
144
|
sections.push("");
|
|
127
|
-
sections.push(
|
|
145
|
+
sections.push(config.baseUrlInfo);
|
|
128
146
|
}
|
|
129
147
|
// Endpoints
|
|
130
148
|
if (doc.endpoints?.length) {
|
|
@@ -165,7 +183,7 @@ export function formatDocumentation(doc, detailLevel = "detailed", includeSchema
|
|
|
165
183
|
if (doc.related_topics?.length) {
|
|
166
184
|
sections.push("");
|
|
167
185
|
sections.push("## Related Topics");
|
|
168
|
-
sections.push(`Use \`
|
|
186
|
+
sections.push(`Use \`${config.toolName}\` with topic: ${doc.related_topics.join(", ")}`);
|
|
169
187
|
}
|
|
170
188
|
return sections.join("\n");
|
|
171
189
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|