@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
package/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
 
16
16
  </div>
17
17
 
18
- An MCP server that gives AI assistants superpowers for developing on [Xano](https://xano.com) — complete with documentation, code validation, and workflow guides.
18
+ An MCP server and standalone library that gives AI assistants superpowers for developing on [Xano](https://xano.com) — complete with documentation, code validation, and workflow guides. Use it as an MCP server or import the tools directly in your own applications.
19
19
 
20
20
  > 💡 **What's Xano?** The fastest way to build a scalable backend for your app — no code required. Build APIs, manage databases, and deploy instantly.
21
21
 
@@ -145,6 +145,159 @@ claude mcp add xano-developer node /path/to/xano-developer-mcp/dist/index.js
145
145
  }
146
146
  ```
147
147
 
148
+ ## Library Usage
149
+
150
+ In addition to using this package as an MCP server, you can import and use the tools directly in your own applications.
151
+
152
+ ### Installation
153
+
154
+ ```bash
155
+ npm install @xano/developer-mcp
156
+ ```
157
+
158
+ ### Importing Tools
159
+
160
+ ```typescript
161
+ import {
162
+ validateXanoscript,
163
+ xanoscriptDocs,
164
+ metaApiDocs,
165
+ runApiDocs,
166
+ cliDocs,
167
+ mcpVersion
168
+ } from '@xano/developer-mcp';
169
+ ```
170
+
171
+ ### Validate XanoScript Code
172
+
173
+ ```typescript
174
+ import { validateXanoscript } from '@xano/developer-mcp';
175
+
176
+ const result = validateXanoscript({ code: 'var:result = 1 + 2' });
177
+
178
+ if (result.valid) {
179
+ console.log('Code is valid!');
180
+ } else {
181
+ console.log('Validation errors:');
182
+ result.errors.forEach(error => {
183
+ console.log(` Line ${error.range.start.line + 1}: ${error.message}`);
184
+ });
185
+ }
186
+ ```
187
+
188
+ ### Get XanoScript Documentation
189
+
190
+ ```typescript
191
+ import { xanoscriptDocs } from '@xano/developer-mcp';
192
+
193
+ // Get overview (README)
194
+ const overview = xanoscriptDocs();
195
+ console.log(overview.documentation);
196
+
197
+ // Get specific topic
198
+ const syntaxDocs = xanoscriptDocs({ topic: 'syntax' });
199
+
200
+ // Get context-aware docs for a file path
201
+ const apiDocs = xanoscriptDocs({ file_path: 'api/users/create_post.xs' });
202
+
203
+ // Get compact quick reference
204
+ const quickRef = xanoscriptDocs({ topic: 'database', mode: 'quick_reference' });
205
+ ```
206
+
207
+ ### Get Meta API Documentation
208
+
209
+ ```typescript
210
+ import { metaApiDocs } from '@xano/developer-mcp';
211
+
212
+ // Get overview
213
+ const overview = metaApiDocs({ topic: 'start' });
214
+
215
+ // Get detailed documentation with examples
216
+ const workspaceDocs = metaApiDocs({
217
+ topic: 'workspace',
218
+ detail_level: 'examples',
219
+ include_schemas: true
220
+ });
221
+
222
+ console.log(workspaceDocs.documentation);
223
+ ```
224
+
225
+ ### Get Run API Documentation
226
+
227
+ ```typescript
228
+ import { runApiDocs } from '@xano/developer-mcp';
229
+
230
+ const sessionDocs = runApiDocs({
231
+ topic: 'session',
232
+ detail_level: 'detailed'
233
+ });
234
+
235
+ console.log(sessionDocs.documentation);
236
+ ```
237
+
238
+ ### Get CLI Documentation
239
+
240
+ ```typescript
241
+ import { cliDocs } from '@xano/developer-mcp';
242
+
243
+ const cliSetup = cliDocs({ topic: 'start' });
244
+ console.log(cliSetup.documentation);
245
+ ```
246
+
247
+ ### Get Package Version
248
+
249
+ ```typescript
250
+ import { mcpVersion } from '@xano/developer-mcp';
251
+
252
+ const { version } = mcpVersion();
253
+ console.log(`Using version ${version}`);
254
+ ```
255
+
256
+ ### Available Exports
257
+
258
+ | Export | Description |
259
+ |--------|-------------|
260
+ | `validateXanoscript` | Validate XanoScript code and get detailed error information |
261
+ | `xanoscriptDocs` | Get XanoScript language documentation |
262
+ | `metaApiDocs` | Get Meta API documentation |
263
+ | `runApiDocs` | Get Run API documentation |
264
+ | `cliDocs` | Get CLI documentation |
265
+ | `mcpVersion` | Get the package version |
266
+ | `toolDefinitions` | MCP tool definitions (for building custom MCP servers) |
267
+ | `handleTool` | Tool dispatcher function (for building custom MCP servers) |
268
+
269
+ ### TypeScript Support
270
+
271
+ Full TypeScript support with exported types:
272
+
273
+ ```typescript
274
+ import type {
275
+ ValidateXanoscriptArgs,
276
+ ValidationResult,
277
+ ParserDiagnostic,
278
+ XanoscriptDocsArgs,
279
+ MetaApiDocsArgs,
280
+ RunApiDocsArgs,
281
+ CliDocsArgs,
282
+ ToolResult
283
+ } from '@xano/developer-mcp';
284
+ ```
285
+
286
+ ### Package Entry Points
287
+
288
+ The package provides multiple entry points:
289
+
290
+ ```typescript
291
+ // Main library entry (recommended)
292
+ import { validateXanoscript } from '@xano/developer-mcp';
293
+
294
+ // Tools module directly
295
+ import { validateXanoscript } from '@xano/developer-mcp/tools';
296
+
297
+ // Server module (for extending the MCP server)
298
+ import '@xano/developer-mcp/server';
299
+ ```
300
+
148
301
  ## Available Tools
149
302
 
150
303
  ### 1. `validate_xanoscript`
@@ -173,7 +326,7 @@ Retrieves XanoScript programming language documentation with context-aware suppo
173
326
  | Parameter | Type | Required | Description |
174
327
  |-----------|------|----------|-------------|
175
328
  | `topic` | string | No | Specific documentation topic to retrieve |
176
- | `file_path` | string | No | File path being edited for context-aware docs (e.g., `apis/users/create.xs`) |
329
+ | `file_path` | string | No | File path being edited for context-aware docs (e.g., `api/users/create_post.xs`) |
177
330
  | `mode` | string | No | `full` (default) or `quick_reference` for compact syntax cheatsheet |
178
331
 
179
332
  **Available Topics:**
@@ -213,7 +366,7 @@ xanoscript_docs()
213
366
  xanoscript_docs({ topic: "functions" })
214
367
 
215
368
  // Context-aware: get all docs relevant to file being edited
216
- xanoscript_docs({ file_path: "apis/users/create.xs" })
369
+ xanoscript_docs({ file_path: "api/users/create_post.xs" })
217
370
 
218
371
  // Compact quick reference (uses less context)
219
372
  xanoscript_docs({ topic: "database", mode: "quick_reference" })
@@ -407,12 +560,22 @@ The server also exposes XanoScript documentation as MCP resources for direct acc
407
560
  ```
408
561
  xano-developer-mcp/
409
562
  ├── src/
410
- │ ├── index.ts # Main MCP server implementation
563
+ │ ├── index.ts # MCP server entry point
564
+ │ ├── lib.ts # Library entry point (for npm imports)
411
565
  │ ├── xanoscript.ts # XanoScript documentation logic
412
566
  │ ├── xanoscript.test.ts # Tests for xanoscript module
413
567
  │ ├── xanoscript-language-server.d.ts # TypeScript declarations
568
+ │ ├── tools/ # Standalone tool modules
569
+ │ │ ├── index.ts # Unified tool exports
570
+ │ │ ├── types.ts # Common types (ToolResult)
571
+ │ │ ├── validate_xanoscript.ts # XanoScript validation tool
572
+ │ │ ├── xanoscript_docs.ts # XanoScript docs tool
573
+ │ │ ├── mcp_version.ts # Version tool
574
+ │ │ ├── meta_api_docs.ts # Meta API docs tool wrapper
575
+ │ │ ├── run_api_docs.ts # Run API docs tool wrapper
576
+ │ │ └── cli_docs.ts # CLI docs tool wrapper
414
577
  │ ├── meta_api_docs/ # Meta API documentation
415
- │ │ ├── index.ts # API docs tool handler
578
+ │ │ ├── index.ts # API docs handler
416
579
  │ │ ├── index.test.ts # Tests for index
417
580
  │ │ ├── types.ts # Type definitions
418
581
  │ │ ├── types.test.ts # Tests for types
@@ -420,13 +583,13 @@ xano-developer-mcp/
420
583
  │ │ ├── format.test.ts # Tests for formatter
421
584
  │ │ └── topics/ # Individual topic modules
422
585
  │ ├── run_api_docs/ # Run API documentation
423
- │ │ ├── index.ts # Run API tool handler
586
+ │ │ ├── index.ts # Run API handler
424
587
  │ │ ├── index.test.ts # Tests for index
425
588
  │ │ ├── format.ts # Documentation formatter
426
589
  │ │ ├── format.test.ts # Tests for formatter
427
590
  │ │ └── topics/ # Individual topic modules
428
591
  │ ├── cli_docs/ # Xano CLI documentation
429
- │ │ ├── index.ts # CLI docs tool handler
592
+ │ │ ├── index.ts # CLI docs handler
430
593
  │ │ ├── types.ts # Type definitions
431
594
  │ │ ├── format.ts # Documentation formatter
432
595
  │ │ └── topics/ # Individual topic modules
@@ -486,7 +649,7 @@ Xano Developer MCP Server
486
649
 
487
650
  ## Authentication
488
651
 
489
- The MCP server itself does not require authentication. However, when using the documented APIs to interact with actual Xano services, you will need appropriate Xano Headless API credentials.
652
+ The MCP server and library functions do not require authentication. However, when using the documented APIs (Meta API, Run API) to interact with actual Xano services, you will need appropriate Xano API credentials. See the `meta_api_docs` and `run_api_docs` tools for authentication details.
490
653
 
491
654
  ## Development
492
655
 
@@ -504,7 +667,7 @@ Compiles TypeScript to JavaScript in the `dist/` directory.
504
667
  - Markdown files for XanoScript language reference
505
668
  - Configured in `src/index.ts` via `XANOSCRIPT_DOCS_V2` with:
506
669
  - **file**: The markdown file containing the documentation
507
- - **applyTo**: Glob patterns for context-aware matching (e.g., `apis/**/*.xs`)
670
+ - **applyTo**: Glob patterns for context-aware matching (e.g., `api/**/*.xs`)
508
671
  - **description**: Human-readable description of the topic
509
672
 
510
673
  **Meta API Documentation** (`src/meta_api_docs/`):
@@ -17,16 +17,59 @@ function: refresh_token
17
17
  ...
18
18
  \`\`\`
19
19
 
20
- When you pull, the CLI splits these into individual \`.xs\` files organized by type.`,
20
+ When you pull, the CLI splits these into individual \`.xs\` files organized by type.
21
+
22
+ ## Directory Structure
23
+
24
+ After \`workspace:pull\`, files are organized using snake_case naming:
25
+
26
+ \`\`\`
27
+ ./xano-code/
28
+ ├── workspace/
29
+ │ ├── my_workspace.xs # Workspace configuration
30
+ │ └── trigger/
31
+ │ └── on_deploy.xs # Workspace triggers
32
+ ├── api/
33
+ │ └── users/ # API group folder (snake_case)
34
+ │ ├── api_group.xs # API group definition
35
+ │ ├── get_all.xs # GET /users
36
+ │ ├── get_one_get.xs # GET /users/:id
37
+ │ ├── create_post.xs # POST /users
38
+ │ └── nested/
39
+ │ └── profile_get.xs # GET /users/nested/profile
40
+ ├── function/
41
+ │ └── validate_token.xs # Reusable functions
42
+ ├── task/
43
+ │ └── daily_cleanup.xs # Scheduled tasks
44
+ ├── table/
45
+ │ ├── users.xs # Table schema
46
+ │ └── trigger/
47
+ │ └── on_user_create.xs # Table triggers
48
+ ├── agent/
49
+ │ ├── support_bot.xs # AI agents
50
+ │ └── trigger/
51
+ │ └── on_message.xs # Agent triggers
52
+ └── mcp_server/
53
+ ├── my_server.xs # MCP server definitions
54
+ └── trigger/
55
+ └── on_connect.xs # MCP server triggers
56
+ \`\`\``,
21
57
  ai_hints: `**Key concepts:**
22
58
  - \`pull\` downloads workspace code and splits into organized .xs files
23
59
  - \`push\` combines .xs files and uploads to Xano
24
- - Files are organized by type: functions/, apis/, tasks/, etc.
60
+ - Files use snake_case naming for folders and filenames
61
+ - API endpoints are nested under their API group folder
25
62
 
26
63
  **Typical workflow:**
27
64
  1. \`xano workspace:pull ./xano-code\` - download
28
- 2. Edit .xs files with your editor/IDE
29
- 3. \`xano workspace:push ./xano-code\` - deploy
65
+ 2. Navigate to \`api/{group}/\` for API endpoints, \`function/\` for functions, etc.
66
+ 3. Edit .xs files with your editor/IDE
67
+ 4. \`xano workspace:push ./xano-code\` - deploy
68
+
69
+ **File naming:**
70
+ - All folders and files use snake_case (e.g., \`my_function.xs\`, \`user_profile/\`)
71
+ - API endpoints include verb suffix (e.g., \`create_post.xs\`, \`get_one_get.xs\`)
72
+ - Triggers are nested under \`{type}/trigger/\` folders
30
73
 
31
74
  **Version control:**
32
75
  - The pulled directory structure is git-friendly
@@ -159,13 +202,14 @@ When you pull, the CLI splits these into individual \`.xs\` files organized by t
159
202
  description: "Edit Xano code locally with your preferred tools",
160
203
  steps: [
161
204
  "Pull workspace: `xano workspace:pull ./code`",
162
- "Edit .xs files in your IDE",
205
+ "Navigate to organized folders: `api/{group}/`, `function/`, `table/`, etc.",
206
+ "Edit .xs files in your IDE (files use snake_case naming)",
163
207
  "Validate changes: Use xanoscript_docs MCP tool",
164
208
  "Push changes: `xano workspace:push ./code`",
165
209
  "Test in Xano dashboard or via API"
166
210
  ],
167
211
  example: `xano workspace:pull ./my-app
168
- # Edit files...
212
+ # Files organized: api/users/create_post.xs, function/validate_token.xs, etc.
169
213
  xano workspace:push ./my-app`
170
214
  },
171
215
  {
package/dist/index.d.ts CHANGED
@@ -1,2 +1,10 @@
1
1
  #!/usr/bin/env node
2
+ /**
3
+ * Xano Developer MCP Server
4
+ *
5
+ * This is the MCP server entry point. For library usage, import from the package root:
6
+ * ```ts
7
+ * import { validateXanoscript, xanoscriptDocs } from '@xano/developer-mcp';
8
+ * ```
9
+ */
2
10
  export {};
package/dist/index.js CHANGED
@@ -1,16 +1,20 @@
1
1
  #!/usr/bin/env node
2
+ /**
3
+ * Xano Developer MCP Server
4
+ *
5
+ * This is the MCP server entry point. For library usage, import from the package root:
6
+ * ```ts
7
+ * import { validateXanoscript, xanoscriptDocs } from '@xano/developer-mcp';
8
+ * ```
9
+ */
2
10
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
11
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
12
  import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
5
13
  import { readFileSync } from "fs";
6
14
  import { fileURLToPath } from "url";
7
15
  import { dirname, join } from "path";
8
- import { xanoscriptParser } from "@xano/xanoscript-language-server/parser/parser.js";
9
- import { getSchemeFromContent } from "@xano/xanoscript-language-server/utils.js";
10
- import { metaApiDocsToolDefinition, handleMetaApiDocs } from "./meta_api_docs/index.js";
11
- import { runApiDocsToolDefinition, handleRunApiDocs } from "./run_api_docs/index.js";
12
- import { cliDocsToolDefinition, handleCliDocs } from "./cli_docs/index.js";
13
- import { XANOSCRIPT_DOCS_V2, readXanoscriptDocsV2, getXanoscriptDocsVersion, getTopicDescriptions, } from "./xanoscript.js";
16
+ import { XANOSCRIPT_DOCS_V2, getXanoscriptDocsVersion } from "./xanoscript.js";
17
+ import { toolDefinitions, handleTool, toMcpResponse, } from "./tools/index.js";
14
18
  const __filename = fileURLToPath(import.meta.url);
15
19
  const __dirname = dirname(__filename);
16
20
  const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
@@ -91,288 +95,12 @@ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
91
95
  // Tool Handlers
92
96
  // =============================================================================
93
97
  server.setRequestHandler(ListToolsRequestSchema, async () => {
94
- return {
95
- tools: [
96
- {
97
- name: "validate_xanoscript",
98
- 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.",
99
- inputSchema: {
100
- type: "object",
101
- properties: {
102
- code: {
103
- type: "string",
104
- description: "The XanoScript code to validate",
105
- },
106
- },
107
- required: ["code"],
108
- },
109
- },
110
- {
111
- name: "xanoscript_docs",
112
- description: "Get XanoScript programming language documentation for AI code generation. " +
113
- "Call without parameters for overview (README). " +
114
- "Use 'topic' for specific documentation, or 'file_path' for context-aware docs based on the file you're editing. " +
115
- "Use mode='quick_reference' for compact syntax cheatsheet (recommended for context efficiency).",
116
- inputSchema: {
117
- type: "object",
118
- properties: {
119
- topic: {
120
- type: "string",
121
- description: "Documentation topic. Available: " + getTopicDescriptions(),
122
- },
123
- file_path: {
124
- type: "string",
125
- description: "File path being edited (e.g., 'apis/users/create.xs', 'functions/utils/format.xs'). " +
126
- "Returns all relevant docs based on file type using applyTo pattern matching.",
127
- },
128
- mode: {
129
- type: "string",
130
- enum: ["full", "quick_reference"],
131
- description: "full = complete documentation, quick_reference = compact Quick Reference sections only. " +
132
- "Use quick_reference for smaller context window usage.",
133
- },
134
- },
135
- required: [],
136
- },
137
- },
138
- {
139
- name: "mcp_version",
140
- description: "Get the current version of the Xano Developer MCP server. " +
141
- "Returns the version string from package.json.",
142
- inputSchema: {
143
- type: "object",
144
- properties: {},
145
- required: [],
146
- },
147
- },
148
- metaApiDocsToolDefinition,
149
- runApiDocsToolDefinition,
150
- cliDocsToolDefinition,
151
- ],
152
- };
98
+ return { tools: toolDefinitions };
153
99
  });
154
100
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
155
- if (request.params.name === "validate_xanoscript") {
156
- const args = request.params.arguments;
157
- if (!args?.code) {
158
- return {
159
- content: [
160
- {
161
- type: "text",
162
- text: "Error: 'code' parameter is required",
163
- },
164
- ],
165
- isError: true,
166
- };
167
- }
168
- try {
169
- const text = args.code;
170
- const scheme = getSchemeFromContent(text);
171
- const parser = xanoscriptParser(text, scheme);
172
- if (parser.errors.length === 0) {
173
- return {
174
- content: [
175
- {
176
- type: "text",
177
- text: "XanoScript is valid. No syntax errors found.",
178
- },
179
- ],
180
- };
181
- }
182
- const diagnostics = parser.errors.map((error) => {
183
- const startOffset = error.token?.startOffset ?? 0;
184
- const endOffset = error.token?.endOffset ?? 5;
185
- const lines = text.substring(0, startOffset).split("\n");
186
- const line = lines.length - 1;
187
- const character = lines[lines.length - 1].length;
188
- const endLines = text.substring(0, endOffset + 1).split("\n");
189
- const endLine = endLines.length - 1;
190
- const endCharacter = endLines[endLines.length - 1].length;
191
- return {
192
- range: {
193
- start: { line, character },
194
- end: { line: endLine, character: endCharacter },
195
- },
196
- message: error.message,
197
- source: error.name || "XanoScript Parser",
198
- };
199
- });
200
- const errorMessages = diagnostics.map((d, i) => {
201
- const location = `Line ${d.range.start.line + 1}, Column ${d.range.start.character + 1}`;
202
- return `${i + 1}. [${location}] ${d.message}`;
203
- });
204
- return {
205
- content: [
206
- {
207
- type: "text",
208
- text: `Found ${diagnostics.length} error(s):\n\n${errorMessages.join("\n")}`,
209
- },
210
- ],
211
- isError: true,
212
- };
213
- }
214
- catch (error) {
215
- const errorMessage = error instanceof Error ? error.message : String(error);
216
- return {
217
- content: [
218
- {
219
- type: "text",
220
- text: `Validation error: ${errorMessage}`,
221
- },
222
- ],
223
- isError: true,
224
- };
225
- }
226
- }
227
- if (request.params.name === "xanoscript_docs") {
228
- const args = request.params.arguments;
229
- const documentation = readXanoscriptDocsV2(XANOSCRIPT_DOCS_PATH, args);
230
- return {
231
- content: [
232
- {
233
- type: "text",
234
- text: documentation,
235
- },
236
- ],
237
- };
238
- }
239
- if (request.params.name === "mcp_version") {
240
- return {
241
- content: [
242
- {
243
- type: "text",
244
- text: SERVER_VERSION,
245
- },
246
- ],
247
- };
248
- }
249
- if (request.params.name === "meta_api_docs") {
250
- const args = request.params.arguments;
251
- if (!args?.topic) {
252
- return {
253
- content: [
254
- {
255
- type: "text",
256
- text: "Error: 'topic' parameter is required. Use meta_api_docs with topic='start' for overview.",
257
- },
258
- ],
259
- isError: true,
260
- };
261
- }
262
- try {
263
- const documentation = handleMetaApiDocs({
264
- topic: args.topic,
265
- detail_level: args.detail_level,
266
- include_schemas: args.include_schemas,
267
- });
268
- return {
269
- content: [
270
- {
271
- type: "text",
272
- text: documentation,
273
- },
274
- ],
275
- };
276
- }
277
- catch (error) {
278
- const errorMessage = error instanceof Error ? error.message : String(error);
279
- return {
280
- content: [
281
- {
282
- type: "text",
283
- text: `Error retrieving API documentation: ${errorMessage}`,
284
- },
285
- ],
286
- isError: true,
287
- };
288
- }
289
- }
290
- if (request.params.name === "run_api_docs") {
291
- const args = request.params.arguments;
292
- if (!args?.topic) {
293
- return {
294
- content: [
295
- {
296
- type: "text",
297
- text: "Error: 'topic' parameter is required. Use run_api_docs with topic='start' for overview.",
298
- },
299
- ],
300
- isError: true,
301
- };
302
- }
303
- try {
304
- const documentation = handleRunApiDocs(args.topic, args.detail_level, args.include_schemas);
305
- return {
306
- content: [
307
- {
308
- type: "text",
309
- text: documentation,
310
- },
311
- ],
312
- };
313
- }
314
- catch (error) {
315
- const errorMessage = error instanceof Error ? error.message : String(error);
316
- return {
317
- content: [
318
- {
319
- type: "text",
320
- text: `Error retrieving Run API documentation: ${errorMessage}`,
321
- },
322
- ],
323
- isError: true,
324
- };
325
- }
326
- }
327
- if (request.params.name === "cli_docs") {
328
- const args = request.params.arguments;
329
- if (!args?.topic) {
330
- return {
331
- content: [
332
- {
333
- type: "text",
334
- text: "Error: 'topic' parameter is required. Use cli_docs with topic='start' for overview.",
335
- },
336
- ],
337
- isError: true,
338
- };
339
- }
340
- try {
341
- const documentation = handleCliDocs({
342
- topic: args.topic,
343
- detail_level: args.detail_level,
344
- });
345
- return {
346
- content: [
347
- {
348
- type: "text",
349
- text: documentation,
350
- },
351
- ],
352
- };
353
- }
354
- catch (error) {
355
- const errorMessage = error instanceof Error ? error.message : String(error);
356
- return {
357
- content: [
358
- {
359
- type: "text",
360
- text: `Error retrieving CLI documentation: ${errorMessage}`,
361
- },
362
- ],
363
- isError: true,
364
- };
365
- }
366
- }
367
- return {
368
- content: [
369
- {
370
- type: "text",
371
- text: `Unknown tool: ${request.params.name}`,
372
- },
373
- ],
374
- isError: true,
375
- };
101
+ const { name, arguments: args } = request.params;
102
+ const result = handleTool(name, args || {});
103
+ return toMcpResponse(result);
376
104
  });
377
105
  // =============================================================================
378
106
  // Start Server