@qodalis/cli-server-node 1.0.0-beta.5 → 1.0.0-beta.7

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 (119) hide show
  1. package/README.md +397 -19
  2. package/dist/package.json +77 -0
  3. package/dist/src/auth/cli-server-auth-gate.d.ts +33 -0
  4. package/dist/src/auth/cli-server-auth-gate.d.ts.map +1 -0
  5. package/dist/src/auth/cli-server-auth-gate.js +121 -0
  6. package/dist/src/auth/cli-server-auth-gate.js.map +1 -0
  7. package/dist/src/auth/cli-server-auth.d.ts +149 -0
  8. package/dist/src/auth/cli-server-auth.d.ts.map +1 -0
  9. package/dist/src/auth/cli-server-auth.js +143 -0
  10. package/dist/src/auth/cli-server-auth.js.map +1 -0
  11. package/dist/src/auth/index.d.ts +4 -0
  12. package/dist/src/auth/index.d.ts.map +1 -0
  13. package/dist/src/auth/index.js +19 -0
  14. package/dist/src/auth/index.js.map +1 -0
  15. package/dist/src/auth/ws-upgrade-auth.d.ts +30 -0
  16. package/dist/src/auth/ws-upgrade-auth.d.ts.map +1 -0
  17. package/dist/src/auth/ws-upgrade-auth.js +49 -0
  18. package/dist/src/auth/ws-upgrade-auth.js.map +1 -0
  19. package/dist/src/controllers/cli-controller.d.ts +2 -1
  20. package/dist/src/controllers/cli-controller.d.ts.map +1 -1
  21. package/dist/src/controllers/cli-controller.js +7 -2
  22. package/dist/src/controllers/cli-controller.js.map +1 -1
  23. package/dist/src/controllers/cli-version-controller.d.ts +12 -1
  24. package/dist/src/controllers/cli-version-controller.d.ts.map +1 -1
  25. package/dist/src/controllers/cli-version-controller.js +7 -2
  26. package/dist/src/controllers/cli-version-controller.js.map +1 -1
  27. package/dist/src/create-cli-server.d.ts +71 -1
  28. package/dist/src/create-cli-server.d.ts.map +1 -1
  29. package/dist/src/create-cli-server.js +146 -10
  30. package/dist/src/create-cli-server.js.map +1 -1
  31. package/dist/src/extensions/cli-builder.d.ts +10 -0
  32. package/dist/src/extensions/cli-builder.d.ts.map +1 -1
  33. package/dist/src/extensions/cli-builder.js +14 -0
  34. package/dist/src/extensions/cli-builder.js.map +1 -1
  35. package/dist/src/index.d.ts +4 -2
  36. package/dist/src/index.d.ts.map +1 -1
  37. package/dist/src/index.js +36 -1
  38. package/dist/src/index.js.map +1 -1
  39. package/dist/src/mcp/index.d.ts +10 -0
  40. package/dist/src/mcp/index.d.ts.map +1 -0
  41. package/dist/src/mcp/index.js +34 -0
  42. package/dist/src/mcp/index.js.map +1 -0
  43. package/dist/src/mcp/mcp-controller.d.ts +54 -0
  44. package/dist/src/mcp/mcp-controller.d.ts.map +1 -0
  45. package/dist/src/mcp/mcp-controller.js +358 -0
  46. package/dist/src/mcp/mcp-controller.js.map +1 -0
  47. package/dist/src/mcp/mcp-render.d.ts +10 -0
  48. package/dist/src/mcp/mcp-render.d.ts.map +1 -0
  49. package/dist/src/mcp/mcp-render.js +66 -0
  50. package/dist/src/mcp/mcp-render.js.map +1 -0
  51. package/dist/src/mcp/mcp-schema.d.ts +8 -0
  52. package/dist/src/mcp/mcp-schema.d.ts.map +1 -0
  53. package/dist/src/mcp/mcp-schema.js +64 -0
  54. package/dist/src/mcp/mcp-schema.js.map +1 -0
  55. package/dist/src/mcp/mcp-types.d.ts +70 -0
  56. package/dist/src/mcp/mcp-types.d.ts.map +1 -0
  57. package/dist/src/mcp/mcp-types.js +21 -0
  58. package/dist/src/mcp/mcp-types.js.map +1 -0
  59. package/dist/src/mcp/providers/commands-provider.d.ts +26 -0
  60. package/dist/src/mcp/providers/commands-provider.d.ts.map +1 -0
  61. package/dist/src/mcp/providers/commands-provider.js +142 -0
  62. package/dist/src/mcp/providers/commands-provider.js.map +1 -0
  63. package/dist/src/mcp/providers/data-explorer-provider.d.ts +15 -0
  64. package/dist/src/mcp/providers/data-explorer-provider.d.ts.map +1 -0
  65. package/dist/src/mcp/providers/data-explorer-provider.js +83 -0
  66. package/dist/src/mcp/providers/data-explorer-provider.js.map +1 -0
  67. package/dist/src/mcp/providers/filesystem-provider.d.ts +15 -0
  68. package/dist/src/mcp/providers/filesystem-provider.d.ts.map +1 -0
  69. package/dist/src/mcp/providers/filesystem-provider.js +166 -0
  70. package/dist/src/mcp/providers/filesystem-provider.js.map +1 -0
  71. package/dist/src/mcp/providers/jobs-provider.d.ts +23 -0
  72. package/dist/src/mcp/providers/jobs-provider.d.ts.map +1 -0
  73. package/dist/src/mcp/providers/jobs-provider.js +121 -0
  74. package/dist/src/mcp/providers/jobs-provider.js.map +1 -0
  75. package/dist/src/mcp/providers/server-provider.d.ts +19 -0
  76. package/dist/src/mcp/providers/server-provider.d.ts.map +1 -0
  77. package/dist/src/mcp/providers/server-provider.js +73 -0
  78. package/dist/src/mcp/providers/server-provider.js.map +1 -0
  79. package/dist/src/processors/cli-base64-command-processor.d.ts.map +1 -1
  80. package/dist/src/processors/cli-base64-command-processor.js +2 -0
  81. package/dist/src/processors/cli-base64-command-processor.js.map +1 -1
  82. package/dist/src/processors/cli-hash-command-processor.d.ts +1 -0
  83. package/dist/src/processors/cli-hash-command-processor.d.ts.map +1 -1
  84. package/dist/src/processors/cli-hash-command-processor.js +1 -0
  85. package/dist/src/processors/cli-hash-command-processor.js.map +1 -1
  86. package/dist/src/processors/cli-http-command-processor.d.ts.map +1 -1
  87. package/dist/src/processors/cli-http-command-processor.js +2 -0
  88. package/dist/src/processors/cli-http-command-processor.js.map +1 -1
  89. package/dist/src/server.js +12 -0
  90. package/dist/src/server.js.map +1 -1
  91. package/dist/src/services/cli-event-socket-manager.d.ts +37 -1
  92. package/dist/src/services/cli-event-socket-manager.d.ts.map +1 -1
  93. package/dist/src/services/cli-event-socket-manager.js +126 -28
  94. package/dist/src/services/cli-event-socket-manager.js.map +1 -1
  95. package/dist/src/services/cli-log-socket-manager.d.ts +15 -1
  96. package/dist/src/services/cli-log-socket-manager.d.ts.map +1 -1
  97. package/dist/src/services/cli-log-socket-manager.js +53 -13
  98. package/dist/src/services/cli-log-socket-manager.js.map +1 -1
  99. package/dist/src/services/cli-shell-options.d.ts +107 -0
  100. package/dist/src/services/cli-shell-options.d.ts.map +1 -0
  101. package/dist/src/services/cli-shell-options.js +139 -0
  102. package/dist/src/services/cli-shell-options.js.map +1 -0
  103. package/dist/src/services/cli-shell-session-manager.d.ts +83 -10
  104. package/dist/src/services/cli-shell-session-manager.d.ts.map +1 -1
  105. package/dist/src/services/cli-shell-session-manager.js +474 -85
  106. package/dist/src/services/cli-shell-session-manager.js.map +1 -1
  107. package/dist/src/services/index.d.ts +2 -1
  108. package/dist/src/services/index.d.ts.map +1 -1
  109. package/dist/src/services/index.js +5 -1
  110. package/dist/src/services/index.js.map +1 -1
  111. package/dist/src/services/process-tree.d.ts +38 -0
  112. package/dist/src/services/process-tree.d.ts.map +1 -0
  113. package/dist/src/services/process-tree.js +249 -0
  114. package/dist/src/services/process-tree.js.map +1 -0
  115. package/dist/src/services/session-bound-sockets.d.ts +45 -0
  116. package/dist/src/services/session-bound-sockets.d.ts.map +1 -0
  117. package/dist/src/services/session-bound-sockets.js +129 -0
  118. package/dist/src/services/session-bound-sockets.js.map +1 -0
  119. package/package.json +1 -1
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateMcpArguments = validateMcpArguments;
4
+ function typeMatches(type, value) {
5
+ switch (type) {
6
+ case 'string':
7
+ return typeof value === 'string';
8
+ case 'number':
9
+ return typeof value === 'number' && Number.isFinite(value);
10
+ case 'integer':
11
+ return typeof value === 'number' && Number.isInteger(value);
12
+ case 'boolean':
13
+ return typeof value === 'boolean';
14
+ case 'object':
15
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
16
+ case 'array':
17
+ return Array.isArray(value);
18
+ default:
19
+ return true;
20
+ }
21
+ }
22
+ const TYPE_LABEL = {
23
+ string: 'a string',
24
+ number: 'a number',
25
+ integer: 'an integer',
26
+ boolean: 'a boolean',
27
+ object: 'an object',
28
+ array: 'an array',
29
+ };
30
+ function checkProperty(key, prop, value) {
31
+ if (!typeMatches(prop.type, value)) {
32
+ if (prop.type === 'array' && prop.items?.type)
33
+ return `argument '${key}' must be an array of ${prop.items.type}s`;
34
+ return `argument '${key}' must be ${TYPE_LABEL[prop.type] ?? prop.type}`;
35
+ }
36
+ if (prop.type === 'array' && prop.items?.type && value.some((v) => !typeMatches(prop.items.type, v))) {
37
+ return `argument '${key}' must be an array of ${prop.items.type}s`;
38
+ }
39
+ return undefined;
40
+ }
41
+ /**
42
+ * Validates tool arguments against an input schema (types of the declared
43
+ * properties, array item types, unknown properties, required properties).
44
+ * Returns the reason when invalid. `null` counts as absent.
45
+ */
46
+ function validateMcpArguments(schema, args) {
47
+ const properties = schema.properties ?? {};
48
+ for (const [key, value] of Object.entries(args)) {
49
+ const prop = Object.prototype.hasOwnProperty.call(properties, key) ? properties[key] : undefined;
50
+ if (!prop)
51
+ return `unknown argument '${key}'`;
52
+ if (value === null || value === undefined)
53
+ continue;
54
+ const reason = checkProperty(key, prop, value);
55
+ if (reason)
56
+ return reason;
57
+ }
58
+ for (const key of schema.required ?? []) {
59
+ if (args[key] === undefined || args[key] === null)
60
+ return `missing required argument '${key}'`;
61
+ }
62
+ return undefined;
63
+ }
64
+ //# sourceMappingURL=mcp-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-schema.js","sourceRoot":"","sources":["../../../src/mcp/mcp-schema.ts"],"names":[],"mappings":";;AA8CA,oDAaC;AAzDD,SAAS,WAAW,CAAC,IAAwB,EAAE,KAAc;IACzD,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,QAAQ;YACT,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;QACrC,KAAK,QAAQ;YACT,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC/D,KAAK,SAAS;YACV,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,C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C;AACrB,CAAC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,MAAsB,EAAE,IAA6B;IACtF,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACjG,IAAI,CAAC,IAAI;YAAE,OAAO,qBAAqB,GAAG,GAAG,CAAC;QAC9C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QACpD,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC/C,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;IAC9B,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC;QACtC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI;YAAE,OAAO,8BAA8B,GAAG,GAAG,CAAC;IACnG,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC"}
@@ -0,0 +1,70 @@
1
+ import type { Request } from 'express';
2
+ import type { CliServerAuthContext } from '../auth/cli-server-auth';
3
+ /** JSON Schema of a property in a tool's input schema (the subset validated by the server). */
4
+ export interface McpPropertySchema {
5
+ type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
6
+ items?: {
7
+ type: 'string' | 'number' | 'integer' | 'boolean';
8
+ };
9
+ description?: string;
10
+ default?: unknown;
11
+ [keyword: string]: unknown;
12
+ }
13
+ /** JSON Schema of a tool's arguments: always an object without additional properties. */
14
+ export interface McpInputSchema {
15
+ type: 'object';
16
+ properties: Record<string, McpPropertySchema>;
17
+ required: string[];
18
+ additionalProperties: false;
19
+ }
20
+ /** MCP tool annotations (hints for clients). */
21
+ export interface McpToolAnnotations {
22
+ readOnlyHint?: boolean;
23
+ destructiveHint?: boolean;
24
+ idempotentHint?: boolean;
25
+ }
26
+ /** Context of a tool call. */
27
+ export interface McpToolCallContext {
28
+ /** The caller (when an auth provider protects the server). */
29
+ auth?: CliServerAuthContext;
30
+ /** Aborted when the client disconnects. */
31
+ signal: AbortSignal;
32
+ /** The HTTP request carrying the call. */
33
+ request: Request;
34
+ }
35
+ /** Result of a tool call: `text` becomes the text content, `structured` the `structuredContent`. */
36
+ export interface McpToolResult {
37
+ text: string;
38
+ structured?: Record<string, unknown>;
39
+ isError: boolean;
40
+ }
41
+ /** A tool exposed by the MCP endpoint. */
42
+ export interface McpTool {
43
+ /** `[a-z0-9_-]`, at most 64 characters. */
44
+ name: string;
45
+ description: string;
46
+ inputSchema: McpInputSchema;
47
+ /** Checked for `tools/list` and `tools/call` when an auth provider protects the server. */
48
+ requiredPermissions: string[];
49
+ annotations?: McpToolAnnotations;
50
+ /** Called with arguments already validated against `inputSchema`. */
51
+ call(args: Record<string, unknown>, context: McpToolCallContext): Promise<McpToolResult>;
52
+ }
53
+ /**
54
+ * Supplies MCP tools. Providers are asked for their tools on every request, so
55
+ * registrations, enabled features and permissions are always current.
56
+ */
57
+ export interface McpToolProvider {
58
+ /** Provider name (used in logs). */
59
+ readonly name: string;
60
+ getTools(): McpTool[] | Promise<McpTool[]>;
61
+ }
62
+ /** MCP tool name rule: `[a-z0-9_-]`, 1-64 characters. */
63
+ export declare const MCP_TOOL_NAME_RE: RegExp;
64
+ /** Builds an input schema from properties and required names. */
65
+ export declare function mcpObjectSchema(properties?: Record<string, McpPropertySchema>, required?: string[]): McpInputSchema;
66
+ /** Error result with a message. */
67
+ export declare function mcpError(message: string): McpToolResult;
68
+ /** Success result with a structured object rendered as pretty JSON text. */
69
+ export declare function mcpJson(value: Record<string, unknown>, text?: string): McpToolResult;
70
+ //# sourceMappingURL=mcp-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-types.d.ts","sourceRoot":"","sources":["../../../src/mcp/mcp-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAEpE,+FAA+F;AAC/F,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;IACvE,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAA;KAAE,CAAC;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B;AAED,yFAAyF;AACzF,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC9C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,oBAAoB,EAAE,KAAK,CAAC;CAC/B;AAED,gDAAgD;AAChD,MAAM,WAAW,kBAAkB;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,8BAA8B;AAC9B,MAAM,WAAW,kBAAkB;IAC/B,8DAA8D;IAC9D,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,2CAA2C;IAC3C,MAAM,EAAE,WAAW,CAAC;IACpB,0CAA0C;IAC1C,OA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", { value: true });
3
+ exports.MCP_TOOL_NAME_RE = void 0;
4
+ exports.mcpObjectSchema = mcpObjectSchema;
5
+ exports.mcpError = mcpError;
6
+ exports.mcpJson = mcpJson;
7
+ /** MCP tool name rule: `[a-z0-9_-]`, 1-64 characters. */
8
+ exports.MCP_TOOL_NAME_RE = /^[a-z0-9_-]{1,64}$/;
9
+ /** Builds an input schema from properties and required names. */
10
+ function mcpObjectSchema(properties = {}, required = []) {
11
+ return { type: 'object', properties, required, additionalProperties: false };
12
+ }
13
+ /** Error result with a message. */
14
+ function mcpError(message) {
15
+ return { text: message, isError: true };
16
+ }
17
+ /** Success result with a structured object rendered as pretty JSON text. */
18
+ function mcpJson(value, text) {
19
+ return { text: text ?? JSON.stringify(value, null, 2), structured: value, isError: false };
20
+ }
21
+ //# sourceMappingURL=mcp-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-types.js","sourceRoot":"","sources":["../../../src/mcp/mcp-types.ts"],"names":[],"mappings":";;;AAuEA,0CAEC;AAGD,4BAEC;AAGD,0BAEC;AAhBD,yDAAyD;AAC5C,QAAA,gBAAgB,GAAG,oBAAoB,CAAC;AAErD,iEAAiE;AACjE,SAAgB,eAAe,CAAC,aAAgD,EAAE,EAAE,WAAqB,EAAE;IACvG,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;AACjF,CAAC;AAED,mCAAmC;AACnC,SAAgB,QAAQ,CAAC,OAAe;IACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC5C,CAAC;AAED,4EAA4E;AAC5E,SAAgB,OAAO,CAAC,KAA8B,EAAE,IAAa;IACjE,OAAO,EAAE,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC/F,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { CliProcessCommand, ICliCommandProcessor } from '../../abstractions';
2
+ import { ICliCommandRegistry } from '../../services/cli-command-registry';
3
+ import { ICliCommandExecutorService } from '../../services/cli-command-executor-service';
4
+ import { McpInputSchema, McpTool, McpToolProvider } from '../mcp-types';
5
+ /** Maximum MCP tool name length. */
6
+ export declare const MCP_TOOL_NAME_MAX_LENGTH = 64;
7
+ /** Tool name of a command path: joined with `_`, lower-cased, `[^a-z0-9_-]` → `-`, max 64 characters. */
8
+ export declare function mcpToolName(path: string[]): string;
9
+ /** Input schema of a processor: one property per parameter, plus `value` (positional input) when it takes a value. */
10
+ export declare function commandInputSchema(processor: ICliCommandProcessor): McpInputSchema;
11
+ /** The command the CLI would send (`value` becomes the positional input when the command takes one). */
12
+ export declare function buildCliCommand(path: string[], positional: boolean, args: Record<string, unknown>): CliProcessCommand;
13
+ /**
14
+ * One tool per command: every root processor and sub-processor that has no
15
+ * sub-processors, declares parameters or takes a value. Calls run through the
16
+ * same executor as `/execute`.
17
+ */
18
+ export declare class CommandsMcpToolProvider implements McpToolProvider {
19
+ private readonly registry;
20
+ private readonly executor;
21
+ readonly name = "commands";
22
+ constructor(registry: ICliCommandRegistry, executor: ICliCommandExecutorService);
23
+ getTools(): McpTool[];
24
+ private toTool;
25
+ }
26
+ //# sourceMappingURL=commands-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands-provider.d.ts","sourceRoot":"","sources":["../../../../src/mcp/providers/commands-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AAEzF,OAAO,EAAE,cAAc,EAAqB,OAAO,EAAE,eAAe,EAAmB,MAAM,cAAc,CAAC;AAE5G,oCAAoC;AACpC,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C,yGAAyG;AACzG,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAMlD;AAoBD,sHAAsH;AACtH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,oBAAoB,GAAG,cAAc,CAgBlF;AAMD,wGAAwG;AACxG,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,iBAAiB,CA0BrH;AAED;;;;GAIG;AACH,qBAAa,uBAAwB,YAAW,eAAe;IAIvD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAJ7B,QAAQ,CAAC,IAAI,cAAc;gBAGN,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,0BAA0B;IAGzD,QAAQ,IAAI,OAAO,EAAE;IAmBrB,OAAO,CAAC,MAAM;CAajB"}
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommandsMcpToolProvider = exports.MCP_TOOL_NAME_MAX_LENGTH = void 0;
4
+ exports.mcpToolName = mcpToolName;
5
+ exports.commandInputSchema = commandInputSchema;
6
+ exports.buildCliCommand = buildCliCommand;
7
+ const cli_server_auth_1 = require("../../auth/cli-server-auth");
8
+ const mcp_render_1 = require("../mcp-render");
9
+ const mcp_types_1 = require("../mcp-types");
10
+ /** Maximum MCP tool name length. */
11
+ exports.MCP_TOOL_NAME_MAX_LENGTH = 64;
12
+ /** Tool name of a command path: joined with `_`, lower-cased, `[^a-z0-9_-]` → `-`, max 64 characters. */
13
+ function mcpToolName(path) {
14
+ return path
15
+ .join('_')
16
+ .toLowerCase()
17
+ .replace(/[^a-z0-9_-]/g, '-')
18
+ .slice(0, exports.MCP_TOOL_NAME_MAX_LENGTH);
19
+ }
20
+ function propertyType(type) {
21
+ switch ((type ?? '').toLowerCase()) {
22
+ case 'number':
23
+ return { type: 'number' };
24
+ case 'boolean':
25
+ return { type: 'boolean' };
26
+ case 'array':
27
+ return { type: 'array', items: { type: 'string' } };
28
+ default:
29
+ return { type: 'string' };
30
+ }
31
+ }
32
+ /** True when the processor takes a positional value (`valueRequired` or `acceptsValue`). */
33
+ function takesValue(processor) {
34
+ return !!processor.valueRequired || !!processor.acceptsValue;
35
+ }
36
+ /** Input schema of a processor: one property per parameter, plus `value` (positional input) when it takes a value. */
37
+ function commandInputSchema(processor) {
38
+ const properties = {};
39
+ const required = [];
40
+ for (const param of processor.parameters ?? []) {
41
+ if (!param?.name || Object.prototype.hasOwnProperty.call(properties, param.name))
42
+ continue;
43
+ const prop = propertyType(param.type);
44
+ if (param.description)
45
+ prop.description = param.description;
46
+ if (param.defaultValue !== undefined && param.defaultValue !== null)
47
+ prop.default = param.defaultValue;
48
+ properties[param.name] = prop;
49
+ if (param.required)
50
+ required.push(param.name);
51
+ }
52
+ if (takesValue(processor) && !Object.prototype.hasOwnProperty.call(properties, 'value')) {
53
+ properties.value = { type: 'string', description: 'The positional input of the command' };
54
+ if (processor.valueRequired)
55
+ required.push('value');
56
+ }
57
+ return (0, mcp_types_1.mcpObjectSchema)(properties, required);
58
+ }
59
+ function quote(value) {
60
+ return /^[^\s"'=]+$/.test(value) ? value : JSON.stringify(value);
61
+ }
62
+ /** The command the CLI would send (`value` becomes the positional input when the command takes one). */
63
+ function buildCliCommand(path, positional, args) {
64
+ const params = {};
65
+ for (const [key, v] of Object.entries(args)) {
66
+ if (v !== null && v !== undefined)
67
+ params[key] = v;
68
+ }
69
+ let value;
70
+ if (positional && typeof params.value === 'string') {
71
+ value = params.value;
72
+ delete params.value;
73
+ }
74
+ const parts = [...path];
75
+ if (value !== undefined)
76
+ parts.push(quote(value));
77
+ for (const [key, v] of Object.entries(params)) {
78
+ if (typeof v === 'boolean') {
79
+ parts.push(v ? `--${key}` : `--${key}=false`);
80
+ }
81
+ else {
82
+ parts.push(`--${key}=${quote(Array.isArray(v) ? v.join(',') : String(v))}`);
83
+ }
84
+ }
85
+ return {
86
+ command: path[0],
87
+ chainCommands: path.slice(1),
88
+ rawCommand: parts.join(' '),
89
+ ...(value !== undefined ? { value } : {}),
90
+ args: params,
91
+ };
92
+ }
93
+ /**
94
+ * One tool per command: every root processor and sub-processor that has no
95
+ * sub-processors, declares parameters or takes a value. Calls run through the
96
+ * same executor as `/execute`.
97
+ */
98
+ class CommandsMcpToolProvider {
99
+ registry;
100
+ executor;
101
+ name = 'commands';
102
+ constructor(registry, executor) {
103
+ this.registry = registry;
104
+ this.executor = executor;
105
+ }
106
+ getTools() {
107
+ const tools = [];
108
+ const walk = (processor, path, permissions) => {
109
+ const chainPermissions = [...permissions, ...(processor.requiredPermissions ?? [])];
110
+ const children = processor.processors ?? [];
111
+ if (children.length === 0 || (processor.parameters?.length ?? 0) > 0 || takesValue(processor)) {
112
+ const name = mcpToolName(path);
113
+ if (name)
114
+ tools.push(this.toTool(processor, name, [...path], chainPermissions));
115
+ }
116
+ for (const child of children) {
117
+ if (child?.command)
118
+ walk(child, [...path, child.command], chainPermissions);
119
+ }
120
+ };
121
+ for (const root of this.registry.processors) {
122
+ if (root?.command)
123
+ walk(root, [root.command], []);
124
+ }
125
+ return tools;
126
+ }
127
+ toTool(processor, name, path, permissions) {
128
+ const positional = takesValue(processor) && !(processor.parameters ?? []).some((p) => p?.name === 'value');
129
+ return {
130
+ name,
131
+ description: processor.description || `Run '${path.join(' ')}'`,
132
+ inputSchema: commandInputSchema(processor),
133
+ requiredPermissions: [cli_server_auth_1.CliServerPermissions.CommandsExecute, ...permissions],
134
+ call: async (args, context) => {
135
+ const response = await this.executor.executeAsync(buildCliCommand(path, positional, args), context.signal);
136
+ return (0, mcp_render_1.commandResult)(response);
137
+ },
138
+ };
139
+ }
140
+ }
141
+ exports.CommandsMcpToolProvider = CommandsMcpToolProvider;
142
+ //# sourceMappingURL=commands-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands-provider.js","sourceRoot":"","sources":["../../../../src/mcp/providers/commands-provider.ts"],"names":[],"mappings":";;;AAWA,kCAMC;AAqBD,gDAgBC;AAOD,0CA0BC;AAtFD,gEAAuE;AAGvE,8CAA8C;AAC9C,4CAA4G;AAE5G,oCAAoC;AACvB,QAAA,wBAAwB,GAAG,EAAE,CAAC;AAE3C,yGAAyG;AACzG,SAAgB,WAAW,CAAC,IAAc;IACtC,OAAO,IAAI;SACN,IAAI,CAAC,GAAG,CAAC;SACT,WAAW,EAAE;SACb,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC;SAC5B,KAAK,CAAC,CAAC,EAAE,gCAAwB,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,YAAY,CAAC,IAAwB;IAC1C,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;QACjC,KAAK,QAAQ;YACT,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC9B,KAAK,SAAS;YACV,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC/B,KAAK,OAAO;YACR,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC;QACxD;YACI,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAClC,CAAC;AACL,CAAC;AAED,4FAA4F;AAC5F,SAAS,UAAU,CAAC,SAA+B;IAC/C,OAAO,CAAC,CAAC,SAAS,CAAC,aAAa,IAAI,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC;AACjE,CAAC;AAED,sHAAsH;AACtH,SAAgB,kBAAkB,CAAC,SAA+B;IAC9D,MAAM,UAAU,GAAsC,EAAE,CAAC;IACzD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,KAAK,MAAM,KAAK,IAAI,SAA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';
2
+ import { McpTool, McpToolProvider } from '../mcp-types';
3
+ /**
4
+ * Data explorer tools over the same registry and executor (timeouts, row
5
+ * limits) as `/api/qcli/data-explorer`: `data_sources`, `data_schema`,
6
+ * `data_query` (`data:query`).
7
+ */
8
+ export declare class DataExplorerMcpToolProvider implements McpToolProvider {
9
+ private readonly registry;
10
+ private readonly executor;
11
+ readonly name = "data-explorer";
12
+ constructor(registry: DataExplorerRegistry, executor: DataExplorerExecutor);
13
+ getTools(): McpTool[];
14
+ }
15
+ //# sourceMappingURL=data-explorer-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-explorer-provider.d.ts","sourceRoot":"","sources":["../../../../src/mcp/providers/data-explorer-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAGtG,OAAO,EAAE,OAAO,EAAE,eAAe,EAAsC,MAAM,cAAc,CAAC;AAE5F;;;;GAIG;AACH,qBAAa,2BAA4B,YAAW,eAAe;IAI3D,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAJ7B,QAAQ,CAAC,IAAI,mBAAmB;gBAGX,QAAQ,EAAE,oBAAoB,EAC9B,QAAQ,EAAE,oBAAoB;IAGnD,QAAQ,IAAI,OAAO,EAAE;CA4DxB"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataExplorerMcpToolProvider = void 0;
4
+ const cli_server_auth_1 = require("../../auth/cli-server-auth");
5
+ const mcp_render_1 = require("../mcp-render");
6
+ const mcp_types_1 = require("../mcp-types");
7
+ /**
8
+ * Data explorer tools over the same registry and executor (timeouts, row
9
+ * limits) as `/api/qcli/data-explorer`: `data_sources`, `data_schema`,
10
+ * `data_query` (`data:query`).
11
+ */
12
+ class DataExplorerMcpToolProvider {
13
+ registry;
14
+ executor;
15
+ name = 'data-explorer';
16
+ constructor(registry, executor) {
17
+ this.registry = registry;
18
+ this.executor = executor;
19
+ }
20
+ getTools() {
21
+ const sourceProp = { source: { type: 'string', description: 'Data source name (see data_sources)' } };
22
+ return [
23
+ {
24
+ name: 'data_sources',
25
+ description: 'List the registered data sources',
26
+ inputSchema: (0, mcp_types_1.mcpObjectSchema)(),
27
+ requiredPermissions: [cli_server_auth_1.CliServerPermissions.DataQuery],
28
+ annotations: { readOnlyHint: true },
29
+ call: async () => {
30
+ const sources = this.registry.getSources();
31
+ const text = sources.map((s) => `${s.name} (${s.language})${s.description ? ` - ${s.description}` : ''}`).join('\n');
32
+ return (0, mcp_types_1.mcpJson)({ sources }, text);
33
+ },
34
+ },
35
+ {
36
+ name: 'data_schema',
37
+ description: 'Schema (tables/collections and columns) of a data source',
38
+ inputSchema: (0, mcp_types_1.mcpObjectSchema)(sourceProp, ['source']),
39
+ requiredPermissions: [cli_server_auth_1.CliServerPermissions.DataQuery],
40
+ annotations: { readOnlyHint: true },
41
+ call: async (args) => {
42
+ const source = args.source;
43
+ const entry = this.registry.get(source);
44
+ if (!entry)
45
+ return (0, mcp_types_1.mcpError)(`Unknown data source: '${source}'`);
46
+ if (!entry.provider.getSchemaAsync)
47
+ return (0, mcp_types_1.mcpError)('Schema introspection is not supported by this data source.');
48
+ try {
49
+ const schema = await entry.provider.getSchemaAsync(entry.options);
50
+ return (0, mcp_types_1.mcpJson)({ ...schema });
51
+ }
52
+ catch (err) {
53
+ return (0, mcp_types_1.mcpError)(err?.message ?? String(err));
54
+ }
55
+ },
56
+ },
57
+ {
58
+ name: 'data_query',
59
+ description: 'Run a query against a data source',
60
+ inputSchema: (0, mcp_types_1.mcpObjectSchema)({
61
+ ...sourceProp,
62
+ query: { type: 'string', description: 'Query in the source language' },
63
+ parameters: { type: 'object', description: 'Query parameters' },
64
+ }, ['source', 'query']),
65
+ requiredPermissions: [cli_server_auth_1.CliServerPermissions.DataQuery],
66
+ call: async (args) => {
67
+ const result = await this.executor.executeAsync({
68
+ source: args.source,
69
+ query: args.query,
70
+ parameters: args.parameters ?? {},
71
+ });
72
+ if (!result.success)
73
+ return (0, mcp_types_1.mcpError)(result.error ?? 'Query failed');
74
+ const table = (0, mcp_render_1.renderRows)(result.columns, result.rows);
75
+ const footer = `(${result.rowCount} row${result.rowCount === 1 ? '' : 's'}${result.truncated ? ', truncated' : ''})`;
76
+ return (0, mcp_types_1.mcpJson)({ ...result }, table ? `${table}\n${footer}` : footer);
77
+ },
78
+ },
79
+ ];
80
+ }
81
+ }
82
+ exports.DataExplorerMcpToolProvider = DataExplorerMcpToolProvider;
83
+ //# sourceMappingURL=data-explorer-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-explorer-provider.js","sourceRoot":"","sources":["../../../../src/mcp/providers/data-explorer-provider.ts"],"names":[],"mappings":";;;AACA,gEAAuE;AACvE,8CAA2C;AAC3C,4CAA4F;AAE5F;;;;GAIG;AACH,MAAa,2BAA2B;IAIf;IACA;IAJZ,IAAI,GAAG,eAAe,CAAC;IAEhC,YACqB,QAA8B,EAC9B,QAA8B;QAD9B,aAAQ,GAAR,QAAQ,CAAsB;QAC9B,aAAQ,GAAR,QAAQ,CAAsB;IAChD,CAAC;IAEJ,QAAQ;QACJ,MAAM,UAAU,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAiB,EAAE,WAAW,EAAE,qCAAqC,EAAE,EAAE,CAAC;QAC/G,OAAO;YACH;gBACI,IAAI,EAAE,cAAc;gBACpB,WAAW,EAAE,kCAAkC;gBAC/C,WAAW,EAAE,IAAA,2BAAe,GAAE;gBAC9B,mBAAmB,EAAE,CAAC,sCAAC,CAAC,SAAS,CAAC;gBAClC,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE;gBACnC,IAAI,EAAE,KAAK,IAAI,EAAE;oBACb,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;oBAC3C,MAAM,IAAI,GAAG,OAAO,CA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AAK,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;gBAClH,CAAC;aACJ;SACJ,CAAC;IACN,CAAC;CACJ;AApED,kEAoEC"}
@@ -0,0 +1,15 @@
1
+ import { IFileStorageProvider } from '@qodalis/cli-server-plugin-filesystem';
2
+ import { McpTool, McpToolProvider } from '../mcp-types';
3
+ export declare const FS_READ_DEFAULT_MAX_BYTES = 262144;
4
+ /**
5
+ * Filesystem tools over the same storage provider (and path checks) as
6
+ * `/api/qcli/fs`: `fs_list`, `fs_stat`, `fs_read` (`files:read`), `fs_write`,
7
+ * `fs_mkdir`, `fs_delete` (`files:write`).
8
+ */
9
+ export declare class FilesystemMcpToolProvider implements McpToolProvider {
10
+ private readonly provider;
11
+ readonly name = "filesystem";
12
+ constructor(provider: IFileStorageProvider);
13
+ getTools(): McpTool[];
14
+ }
15
+ //# sourceMappingURL=filesystem-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem-provider.d.ts","sourceRoot":"","sources":["../../../../src/mcp/providers/filesystem-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,OAAO,EAAE,OAAO,EAAE,eAAe,EAAsC,MAAM,cAAc,CAAC;AAE5F,eAAO,MAAM,yBAAyB,SAAU,CAAC;AA+CjD;;;;GAIG;AACH,qBAAa,yBAA0B,YAAW,eAAe;IAGjD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,QAAQ,CAAC,IAAI,gBAAgB;gBAEA,QAAQ,EAAE,oBAAoB;IAE3D,QAAQ,IAAI,OAAO,EAAE;CA+GxB"}