@qodalis/cli-server-node 1.0.0-beta.6 → 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 (76) hide show
  1. package/README.md +223 -1
  2. package/dist/package.json +77 -0
  3. package/dist/src/auth/cli-server-auth-gate.d.ts +2 -0
  4. package/dist/src/auth/cli-server-auth-gate.d.ts.map +1 -1
  5. package/dist/src/auth/cli-server-auth-gate.js +3 -0
  6. package/dist/src/auth/cli-server-auth-gate.js.map +1 -1
  7. package/dist/src/auth/cli-server-auth.d.ts +2 -0
  8. package/dist/src/auth/cli-server-auth.d.ts.map +1 -1
  9. package/dist/src/auth/cli-server-auth.js.map +1 -1
  10. package/dist/src/create-cli-server.d.ts +26 -0
  11. package/dist/src/create-cli-server.d.ts.map +1 -1
  12. package/dist/src/create-cli-server.js +77 -2
  13. package/dist/src/create-cli-server.js.map +1 -1
  14. package/dist/src/extensions/cli-builder.d.ts +10 -0
  15. package/dist/src/extensions/cli-builder.d.ts.map +1 -1
  16. package/dist/src/extensions/cli-builder.js +14 -0
  17. package/dist/src/extensions/cli-builder.js.map +1 -1
  18. package/dist/src/index.d.ts +2 -1
  19. package/dist/src/index.d.ts.map +1 -1
  20. package/dist/src/index.js +23 -2
  21. package/dist/src/index.js.map +1 -1
  22. package/dist/src/mcp/index.d.ts +10 -0
  23. package/dist/src/mcp/index.d.ts.map +1 -0
  24. package/dist/src/mcp/index.js +34 -0
  25. package/dist/src/mcp/index.js.map +1 -0
  26. package/dist/src/mcp/mcp-controller.d.ts +54 -0
  27. package/dist/src/mcp/mcp-controller.d.ts.map +1 -0
  28. package/dist/src/mcp/mcp-controller.js +358 -0
  29. package/dist/src/mcp/mcp-controller.js.map +1 -0
  30. package/dist/src/mcp/mcp-render.d.ts +10 -0
  31. package/dist/src/mcp/mcp-render.d.ts.map +1 -0
  32. package/dist/src/mcp/mcp-render.js +66 -0
  33. package/dist/src/mcp/mcp-render.js.map +1 -0
  34. package/dist/src/mcp/mcp-schema.d.ts +8 -0
  35. package/dist/src/mcp/mcp-schema.d.ts.map +1 -0
  36. package/dist/src/mcp/mcp-schema.js +64 -0
  37. package/dist/src/mcp/mcp-schema.js.map +1 -0
  38. package/dist/src/mcp/mcp-types.d.ts +70 -0
  39. package/dist/src/mcp/mcp-types.d.ts.map +1 -0
  40. package/dist/src/mcp/mcp-types.js +21 -0
  41. package/dist/src/mcp/mcp-types.js.map +1 -0
  42. package/dist/src/mcp/providers/commands-provider.d.ts +26 -0
  43. package/dist/src/mcp/providers/commands-provider.d.ts.map +1 -0
  44. package/dist/src/mcp/providers/commands-provider.js +142 -0
  45. package/dist/src/mcp/providers/commands-provider.js.map +1 -0
  46. package/dist/src/mcp/providers/data-explorer-provider.d.ts +15 -0
  47. package/dist/src/mcp/providers/data-explorer-provider.d.ts.map +1 -0
  48. package/dist/src/mcp/providers/data-explorer-provider.js +83 -0
  49. package/dist/src/mcp/providers/data-explorer-provider.js.map +1 -0
  50. package/dist/src/mcp/providers/filesystem-provider.d.ts +15 -0
  51. package/dist/src/mcp/providers/filesystem-provider.d.ts.map +1 -0
  52. package/dist/src/mcp/providers/filesystem-provider.js +166 -0
  53. package/dist/src/mcp/providers/filesystem-provider.js.map +1 -0
  54. package/dist/src/mcp/providers/jobs-provider.d.ts +23 -0
  55. package/dist/src/mcp/providers/jobs-provider.d.ts.map +1 -0
  56. package/dist/src/mcp/providers/jobs-provider.js +121 -0
  57. package/dist/src/mcp/providers/jobs-provider.js.map +1 -0
  58. package/dist/src/mcp/providers/server-provider.d.ts +19 -0
  59. package/dist/src/mcp/providers/server-provider.d.ts.map +1 -0
  60. package/dist/src/mcp/providers/server-provider.js +73 -0
  61. package/dist/src/mcp/providers/server-provider.js.map +1 -0
  62. package/dist/src/processors/cli-base64-command-processor.d.ts.map +1 -1
  63. package/dist/src/processors/cli-base64-command-processor.js +2 -0
  64. package/dist/src/processors/cli-base64-command-processor.js.map +1 -1
  65. package/dist/src/processors/cli-hash-command-processor.d.ts +1 -0
  66. package/dist/src/processors/cli-hash-command-processor.d.ts.map +1 -1
  67. package/dist/src/processors/cli-hash-command-processor.js +1 -0
  68. package/dist/src/processors/cli-hash-command-processor.js.map +1 -1
  69. package/dist/src/processors/cli-http-command-processor.d.ts.map +1 -1
  70. package/dist/src/processors/cli-http-command-processor.js +2 -0
  71. package/dist/src/processors/cli-http-command-processor.js.map +1 -1
  72. package/dist/src/services/session-bound-sockets.d.ts +1 -1
  73. package/dist/src/services/session-bound-sockets.d.ts.map +1 -1
  74. package/dist/src/services/session-bound-sockets.js +2 -2
  75. package/dist/src/services/session-bound-sockets.js.map +1 -1
  76. package/package.json +1 -1
@@ -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":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,CAAC,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;YAC1C,IAAI,IAAI,EAAE,OAAO;gBAAE,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QACtD,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAEO,MAAM,CAAC,SAA+B,EAAE,IAAY,EAAE,IAAc,EAAE,WAAqB;QAC/F,MAAM,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC;QAC3G,OAAO;YACH,IAAI;YACJ,WAAW,EAAE,SAAS,CAAC,WAAW,IAAI,QAAQ,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG;YAC/D,WAAW,EAAE,kBAAkB,CAAC,SAAS,CAAC;YAC1C,mBAAmB,EAAE,CAAC,sCAAC,CAAC,eAAe,EAAE,GAAG,WAAW,CAAC;YACxD,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;gBAC1B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;gBAC3G,OAAO,IAAA,0BAAa,EAAC,QAAQ,CAAC,CAAC;YACnC,CAAC;SACJ,CAAC;IACN,CAAC;CACJ;AAxCD,0DAwCC"}
@@ -0,0 +1,15 @@
1
+ import { DataExplorerExecutor, DataExplorerRegistry } from '@qodalis/cli-server-plugin-data-explorer';
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,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,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C;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"}
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FilesystemMcpToolProvider = exports.FS_READ_DEFAULT_MAX_BYTES = void 0;
4
+ const cli_server_auth_1 = require("../../auth/cli-server-auth");
5
+ const mcp_types_1 = require("../mcp-types");
6
+ exports.FS_READ_DEFAULT_MAX_BYTES = 262_144;
7
+ const errorMessage = (err) => err?.message ?? String(err);
8
+ /** Reads at most `maxBytes` from the provider's download stream. */
9
+ async function readBytes(provider, path, maxBytes) {
10
+ const stream = await provider.getDownloadStream(path);
11
+ const chunks = [];
12
+ let total = 0;
13
+ try {
14
+ for await (const chunk of stream) {
15
+ const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
16
+ chunks.push(buf);
17
+ total += buf.length;
18
+ if (total >= maxBytes)
19
+ break;
20
+ }
21
+ }
22
+ finally {
23
+ stream.destroy?.();
24
+ }
25
+ const all = Buffer.concat(chunks);
26
+ return all.length > maxBytes ? all.subarray(0, maxBytes) : all;
27
+ }
28
+ /** Drops an incomplete UTF-8 sequence at the end of a truncated buffer. */
29
+ function trimPartialUtf8(buf) {
30
+ let i = buf.length - 1;
31
+ let continuation = 0;
32
+ while (i >= 0 && continuation < 3 && (buf[i] & 0xc0) === 0x80) {
33
+ i--;
34
+ continuation++;
35
+ }
36
+ if (i < 0)
37
+ return buf;
38
+ const lead = buf[i];
39
+ const expected = lead >= 0xf0 ? 4 : lead >= 0xe0 ? 3 : lead >= 0xc0 ? 2 : 1;
40
+ return expected > continuation + 1 ? buf.subarray(0, i) : buf;
41
+ }
42
+ /** Decodes UTF-8 text; undefined for binary content (NUL bytes or invalid UTF-8). */
43
+ function decodeText(buf) {
44
+ if (buf.includes(0))
45
+ return undefined;
46
+ try {
47
+ return new TextDecoder('utf-8', { fatal: true }).decode(buf);
48
+ }
49
+ catch {
50
+ return undefined;
51
+ }
52
+ }
53
+ /**
54
+ * Filesystem tools over the same storage provider (and path checks) as
55
+ * `/api/qcli/fs`: `fs_list`, `fs_stat`, `fs_read` (`files:read`), `fs_write`,
56
+ * `fs_mkdir`, `fs_delete` (`files:write`).
57
+ */
58
+ class FilesystemMcpToolProvider {
59
+ provider;
60
+ name = 'filesystem';
61
+ constructor(provider) {
62
+ this.provider = provider;
63
+ }
64
+ getTools() {
65
+ const fs = this.provider;
66
+ const pathProp = { path: { type: 'string', description: 'File or directory path' } };
67
+ const run = async (fn) => {
68
+ try {
69
+ return await fn();
70
+ }
71
+ catch (err) {
72
+ return (0, mcp_types_1.mcpError)(errorMessage(err));
73
+ }
74
+ };
75
+ return [
76
+ {
77
+ name: 'fs_list',
78
+ description: 'List the entries of a directory',
79
+ inputSchema: (0, mcp_types_1.mcpObjectSchema)(pathProp, ['path']),
80
+ requiredPermissions: [cli_server_auth_1.CliServerPermissions.FilesRead],
81
+ annotations: { readOnlyHint: true },
82
+ call: (args) => run(async () => {
83
+ const entries = await fs.list(args.path);
84
+ const text = entries.map((e) => `${e.type === 'directory' ? 'd' : '-'} ${e.size}\t${e.modified}\t${e.name}`).join('\n');
85
+ return (0, mcp_types_1.mcpJson)({ entries }, text);
86
+ }),
87
+ },
88
+ {
89
+ name: 'fs_stat',
90
+ description: 'Metadata of a file or directory',
91
+ inputSchema: (0, mcp_types_1.mcpObjectSchema)(pathProp, ['path']),
92
+ requiredPermissions: [cli_server_auth_1.CliServerPermissions.FilesRead],
93
+ annotations: { readOnlyHint: true },
94
+ call: (args) => run(async () => {
95
+ const stat = await fs.stat(args.path);
96
+ const text = Object.entries(stat).map(([k, v]) => `${k}: ${v}`).join('\n');
97
+ return (0, mcp_types_1.mcpJson)({ ...stat }, text);
98
+ }),
99
+ },
100
+ {
101
+ name: 'fs_read',
102
+ description: 'Read a UTF-8 text file (at most maxBytes bytes)',
103
+ inputSchema: (0, mcp_types_1.mcpObjectSchema)({
104
+ ...pathProp,
105
+ maxBytes: { type: 'integer', description: 'Maximum bytes to read', default: exports.FS_READ_DEFAULT_MAX_BYTES },
106
+ }, ['path']),
107
+ requiredPermissions: [cli_server_auth_1.CliServerPermissions.FilesRead],
108
+ annotations: { readOnlyHint: true },
109
+ call: (args) => run(async () => {
110
+ const path = args.path;
111
+ const maxBytes = args.maxBytes ?? exports.FS_READ_DEFAULT_MAX_BYTES;
112
+ if (maxBytes < 1)
113
+ return (0, mcp_types_1.mcpError)('maxBytes must be at least 1');
114
+ const stat = await fs.stat(path);
115
+ if (stat.type === 'directory')
116
+ return (0, mcp_types_1.mcpError)(`${path} is a directory`);
117
+ const raw = await readBytes(fs, path, maxBytes);
118
+ const truncated = stat.size > raw.length;
119
+ const shown = truncated ? trimPartialUtf8(raw) : raw;
120
+ const text = decodeText(shown);
121
+ if (text === undefined)
122
+ return (0, mcp_types_1.mcpError)(`binary file, ${stat.size} bytes`);
123
+ return {
124
+ text: truncated ? `${text}\n[truncated: ${shown.length} of ${stat.size} bytes]` : text,
125
+ isError: false,
126
+ };
127
+ }),
128
+ },
129
+ {
130
+ name: 'fs_write',
131
+ description: 'Create or overwrite a text file',
132
+ inputSchema: (0, mcp_types_1.mcpObjectSchema)({ ...pathProp, content: { type: 'string', description: 'UTF-8 file content' } }, ['path', 'content']),
133
+ requiredPermissions: [cli_server_auth_1.CliServerPermissions.FilesWrite],
134
+ call: (args) => run(async () => {
135
+ const content = args.content;
136
+ await fs.writeFile(args.path, content);
137
+ const bytes = Buffer.byteLength(content, 'utf8');
138
+ return (0, mcp_types_1.mcpJson)({ path: args.path, bytes }, `Wrote ${bytes} bytes to ${args.path}`);
139
+ }),
140
+ },
141
+ {
142
+ name: 'fs_mkdir',
143
+ description: 'Create a directory (and missing parents)',
144
+ inputSchema: (0, mcp_types_1.mcpObjectSchema)(pathProp, ['path']),
145
+ requiredPermissions: [cli_server_auth_1.CliServerPermissions.FilesWrite],
146
+ call: (args) => run(async () => {
147
+ await fs.mkdir(args.path, true);
148
+ return (0, mcp_types_1.mcpJson)({ path: args.path }, `Created ${args.path}`);
149
+ }),
150
+ },
151
+ {
152
+ name: 'fs_delete',
153
+ description: 'Delete a file or directory (recursive for non-empty directories)',
154
+ inputSchema: (0, mcp_types_1.mcpObjectSchema)({ ...pathProp, recursive: { type: 'boolean', description: 'Delete non-empty directories', default: false } }, ['path']),
155
+ requiredPermissions: [cli_server_auth_1.CliServerPermissions.FilesWrite],
156
+ annotations: { destructiveHint: true },
157
+ call: (args) => run(async () => {
158
+ await fs.remove(args.path, args.recursive ?? false);
159
+ return (0, mcp_types_1.mcpJson)({ deleted: args.path }, `Deleted ${args.path}`);
160
+ }),
161
+ },
162
+ ];
163
+ }
164
+ }
165
+ exports.FilesystemMcpToolProvider = FilesystemMcpToolProvider;
166
+ //# sourceMappingURL=filesystem-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem-provider.js","sourceRoot":"","sources":["../../../../src/mcp/providers/filesystem-provider.ts"],"names":[],"mappings":";;;AACA,gEAAuE;AACvE,4CAA4F;AAE/E,QAAA,yBAAyB,GAAG,OAAO,CAAC;AAEjD,MAAM,YAAY,GAAG,CAAC,GAAY,EAAE,EAAE,CAAE,GAAa,EAAE,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;AAE9E,oEAAoE;AACpE,KAAK,UAAU,SAAS,CAAC,QAA8B,EAAE,IAAY,EAAE,QAAgB;IACnF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACtD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,CAAC;QACD,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAChE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACjB,KAAK,IAAI,GAAG,CAAC,MAAM,CAAC;YACpB,IAAI,KAAK,IAAI,QAAQ;gBAAE,MAAM;QACjC,CAAC;IACL,CAAC;YAAS,CAAC;QACN,MAAmC,CAAC,OAAO,EAAE,EAAE,CAAC;IACrD,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO,GAAG,CAAC,MAAM,GAAG,QAAQ,CAAC,C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S,EAAE,WAAW,EAAE,8BAA8B,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAC5G,CAAC,MAAM,CAAC,CACX;gBACD,mBAAmB,EAAE,CAAC,sCAAC,CAAC,UAAU,CAAC;gBACnC,WAAW,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE;gBACtC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CACX,GAAG,CAAC,KAAK,IAAI,EAAE;oBACX,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAc,EAAG,IAAI,CAAC,SAAiC,IAAI,KAAK,CAAC,CAAC;oBACvF,OAAO,IAAA,mBAAO,EAAC,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,WAAW,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;gBACnE,CAAC,CAAC;aACT;SACJ,CAAC;IACN,CAAC;CACJ;AApHD,8DAoHC"}
@@ -0,0 +1,23 @@
1
+ import { CliJobScheduler } from '@qodalis/cli-server-plugin-jobs';
2
+ import { McpTool, McpToolProvider } from '../mcp-types';
3
+ /**
4
+ * Resolves a job by id, or by a unique name (exact, then case-insensitive).
5
+ * Returns the id, or an error message (not found / ambiguous name).
6
+ */
7
+ export declare function resolveJobId(scheduler: CliJobScheduler, idOrName: string): {
8
+ id: string;
9
+ } | {
10
+ error: string;
11
+ };
12
+ /**
13
+ * Jobs tools over the jobs plugin's scheduler: `jobs_list`, `jobs_get`,
14
+ * `jobs_history` (`jobs:read`) and `jobs_trigger|pause|resume|stop|cancel`
15
+ * (`jobs:manage`).
16
+ */
17
+ export declare class JobsMcpToolProvider implements McpToolProvider {
18
+ private readonly scheduler;
19
+ readonly name = "jobs";
20
+ constructor(scheduler: CliJobScheduler);
21
+ getTools(): McpTool[];
22
+ }
23
+ //# sourceMappingURL=jobs-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobs-provider.d.ts","sourceRoot":"","sources":["../../../../src/mcp/providers/jobs-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,OAAO,EAAsB,eAAe,EAAsC,MAAM,cAAc,CAAC;AAIhH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAW7G;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IAG3C,OAAO,CAAC,QAAQ,CAAC,SAAS;IAFtC,QAAQ,CAAC,IAAI,UAAU;gBAEM,SAAS,EAAE,eAAe;IAEvD,QAAQ,IAAI,OAAO,EAAE;CAoFxB"}