mcpgraph 0.1.24 → 0.1.25
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 +5 -1
- package/dist/api.d.ts +36 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +88 -0
- package/dist/api.js.map +1 -1
- package/dist/config/loader.js +1 -1
- package/dist/config/loader.js.map +1 -1
- package/dist/config/serializer.d.ts +18 -0
- package/dist/config/serializer.d.ts.map +1 -0
- package/dist/config/serializer.js +64 -0
- package/dist/config/serializer.js.map +1 -0
- package/dist/execution/executor.d.ts.map +1 -1
- package/dist/execution/executor.js +11 -0
- package/dist/execution/executor.js.map +1 -1
- package/dist/logger.d.ts +11 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +35 -0
- package/dist/logger.js.map +1 -1
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -1
- package/dist/toolkit/api.d.ts +35 -0
- package/dist/toolkit/api.d.ts.map +1 -0
- package/dist/toolkit/api.js +552 -0
- package/dist/toolkit/api.js.map +1 -0
- package/dist/toolkit/expression-testers.d.ts +21 -0
- package/dist/toolkit/expression-testers.d.ts.map +1 -0
- package/dist/toolkit/expression-testers.js +48 -0
- package/dist/toolkit/expression-testers.js.map +1 -0
- package/dist/toolkit/mcp-discovery.d.ts +54 -0
- package/dist/toolkit/mcp-discovery.d.ts.map +1 -0
- package/dist/toolkit/mcp-discovery.js +140 -0
- package/dist/toolkit/mcp-discovery.js.map +1 -0
- package/dist/toolkit-main.d.ts +6 -0
- package/dist/toolkit-main.d.ts.map +1 -0
- package/dist/toolkit-main.js +127 -0
- package/dist/toolkit-main.js.map +1 -0
- package/dist/types/execution.d.ts +7 -0
- package/dist/types/execution.d.ts.map +1 -1
- package/docs/building.md +70 -46
- package/docs/design.md +1 -1
- package/docs/images/code-mode-sequence.svg +93 -0
- package/docs/images/count-files-flow.svg +116 -0
- package/docs/images/screenshot.png +0 -0
- package/docs/images/traditional-tool-calling-sequence.svg +79 -0
- package/docs/implementation.md +1 -1
- package/docs/no-code-code-mode.md +305 -0
- package/docs/toolkit.md +281 -0
- package/examples/api-usage.ts +5 -5
- package/examples/file_utils.yaml +130 -0
- package/package.json +3 -2
- package/examples/count_files.yaml +0 -70
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/toolkit/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAMxC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAc;IACzB,OAAO,CAAC,YAAY,CAA6B;gBAErC,GAAG,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAOzD;;OAEG;IACH,MAAM,IAAI,WAAW;IAIrB;;OAEG;IACH,SAAS,IAAI,WAAW,EAAE;IAiW1B;;OAEG;IACG,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IA2LvF;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAM7B"}
|
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolkitApi - Thin wrapper that exposes McpGraphApi methods as MCP tools
|
|
3
|
+
*
|
|
4
|
+
* This class wraps McpGraphApi and provides MCP tool handlers.
|
|
5
|
+
* It does NOT implement core graph functionality - it leverages McpGraphApi.
|
|
6
|
+
*/
|
|
7
|
+
import { McpDiscovery } from './mcp-discovery.js';
|
|
8
|
+
import { testJSONata, testJSONLogic } from './expression-testers.js';
|
|
9
|
+
export class ToolkitApi {
|
|
10
|
+
api;
|
|
11
|
+
mcpDiscovery = null;
|
|
12
|
+
constructor(api, mcpFilePath) {
|
|
13
|
+
this.api = api;
|
|
14
|
+
if (mcpFilePath) {
|
|
15
|
+
this.mcpDiscovery = new McpDiscovery(mcpFilePath);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get the underlying McpGraphApi instance
|
|
20
|
+
*/
|
|
21
|
+
getApi() {
|
|
22
|
+
return this.api;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get list of all toolkit tools
|
|
26
|
+
*/
|
|
27
|
+
listTools() {
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
name: 'getGraphServer',
|
|
31
|
+
description: 'Get full details of the mcpGraph server metadata',
|
|
32
|
+
inputSchema: {
|
|
33
|
+
type: 'object',
|
|
34
|
+
properties: {},
|
|
35
|
+
},
|
|
36
|
+
outputSchema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
name: { type: 'string', description: 'Server name' },
|
|
40
|
+
version: { type: 'string', description: 'Server version' },
|
|
41
|
+
title: { type: 'string', description: 'Server title' },
|
|
42
|
+
instructions: { type: 'string', description: 'Server instructions' },
|
|
43
|
+
},
|
|
44
|
+
required: ['name', 'version'],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'listGraphTools',
|
|
49
|
+
description: 'List all exported tools from the mcpGraph (name and description)',
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: 'object',
|
|
52
|
+
properties: {},
|
|
53
|
+
},
|
|
54
|
+
outputSchema: {
|
|
55
|
+
type: 'object',
|
|
56
|
+
properties: {
|
|
57
|
+
items: {
|
|
58
|
+
type: 'array',
|
|
59
|
+
items: {
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: {
|
|
62
|
+
name: { type: 'string', description: 'Tool name' },
|
|
63
|
+
description: { type: 'string', description: 'Tool description' },
|
|
64
|
+
},
|
|
65
|
+
required: ['name', 'description'],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'getGraphTool',
|
|
73
|
+
description: 'Get full detail of an exported tool from the mcpGraph',
|
|
74
|
+
inputSchema: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
properties: {
|
|
77
|
+
toolName: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: 'Name of the tool to get',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
required: ['toolName'],
|
|
83
|
+
},
|
|
84
|
+
outputSchema: {
|
|
85
|
+
type: 'object',
|
|
86
|
+
description: 'Complete tool definition including name, description, inputSchema, outputSchema, and nodes',
|
|
87
|
+
properties: {},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'listMcpServers',
|
|
92
|
+
description: 'List all available MCP servers (name, title, instructions, version)',
|
|
93
|
+
inputSchema: {
|
|
94
|
+
type: 'object',
|
|
95
|
+
properties: {},
|
|
96
|
+
},
|
|
97
|
+
outputSchema: {
|
|
98
|
+
type: 'object',
|
|
99
|
+
properties: {
|
|
100
|
+
items: {
|
|
101
|
+
type: 'array',
|
|
102
|
+
items: {
|
|
103
|
+
type: 'object',
|
|
104
|
+
properties: {
|
|
105
|
+
name: { type: 'string', description: 'Server name' },
|
|
106
|
+
title: { type: 'string', description: 'Server title' },
|
|
107
|
+
instructions: { type: 'string', description: 'Server instructions' },
|
|
108
|
+
version: { type: 'string', description: 'Server version' },
|
|
109
|
+
},
|
|
110
|
+
required: ['name'],
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'listMcpServerTools',
|
|
118
|
+
description: 'List tools from MCP servers (name/description only), optionally filtered by MCP server name',
|
|
119
|
+
inputSchema: {
|
|
120
|
+
type: 'object',
|
|
121
|
+
properties: {
|
|
122
|
+
serverName: {
|
|
123
|
+
type: 'string',
|
|
124
|
+
description: 'Optional server name to filter by',
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
outputSchema: {
|
|
129
|
+
type: 'object',
|
|
130
|
+
properties: {
|
|
131
|
+
items: {
|
|
132
|
+
type: 'array',
|
|
133
|
+
items: {
|
|
134
|
+
type: 'object',
|
|
135
|
+
properties: {
|
|
136
|
+
name: { type: 'string', description: 'Tool name' },
|
|
137
|
+
description: { type: 'string', description: 'Tool description' },
|
|
138
|
+
server: { type: 'string', description: 'MCP server name' },
|
|
139
|
+
},
|
|
140
|
+
required: ['name', 'description', 'server'],
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: 'getMcpServerTool',
|
|
148
|
+
description: 'Get full MCP server tool details (including input and output schemas)',
|
|
149
|
+
inputSchema: {
|
|
150
|
+
type: 'object',
|
|
151
|
+
properties: {
|
|
152
|
+
serverName: {
|
|
153
|
+
type: 'string',
|
|
154
|
+
description: 'Name of the MCP server',
|
|
155
|
+
},
|
|
156
|
+
toolName: {
|
|
157
|
+
type: 'string',
|
|
158
|
+
description: 'Name of the tool',
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
required: ['serverName', 'toolName'],
|
|
162
|
+
},
|
|
163
|
+
outputSchema: {
|
|
164
|
+
type: 'object',
|
|
165
|
+
properties: {
|
|
166
|
+
name: { type: 'string', description: 'Tool name' },
|
|
167
|
+
description: { type: 'string', description: 'Tool description' },
|
|
168
|
+
inputSchema: { type: 'object', description: 'Tool input schema' },
|
|
169
|
+
outputSchema: { type: 'object', description: 'Tool output schema' },
|
|
170
|
+
},
|
|
171
|
+
required: ['name', 'description', 'inputSchema'],
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: 'addGraphTool',
|
|
176
|
+
description: 'Add a new tool to the mcpGraph',
|
|
177
|
+
inputSchema: {
|
|
178
|
+
type: 'object',
|
|
179
|
+
properties: {
|
|
180
|
+
tool: {
|
|
181
|
+
type: 'object',
|
|
182
|
+
description: 'Complete tool definition',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
required: ['tool'],
|
|
186
|
+
},
|
|
187
|
+
outputSchema: {
|
|
188
|
+
type: 'object',
|
|
189
|
+
properties: {
|
|
190
|
+
success: { type: 'boolean', description: 'Whether the operation succeeded' },
|
|
191
|
+
message: { type: 'string', description: 'Success message' },
|
|
192
|
+
},
|
|
193
|
+
required: ['success', 'message'],
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: 'updateGraphTool',
|
|
198
|
+
description: 'Update an existing tool in the mcpGraph',
|
|
199
|
+
inputSchema: {
|
|
200
|
+
type: 'object',
|
|
201
|
+
properties: {
|
|
202
|
+
toolName: {
|
|
203
|
+
type: 'string',
|
|
204
|
+
description: 'Name of the tool to update',
|
|
205
|
+
},
|
|
206
|
+
tool: {
|
|
207
|
+
type: 'object',
|
|
208
|
+
description: 'Updated tool definition',
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
required: ['toolName', 'tool'],
|
|
212
|
+
},
|
|
213
|
+
outputSchema: {
|
|
214
|
+
type: 'object',
|
|
215
|
+
properties: {
|
|
216
|
+
success: { type: 'boolean', description: 'Whether the operation succeeded' },
|
|
217
|
+
message: { type: 'string', description: 'Success message' },
|
|
218
|
+
},
|
|
219
|
+
required: ['success', 'message'],
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: 'deleteGraphTool',
|
|
224
|
+
description: 'Delete a tool from the mcpGraph',
|
|
225
|
+
inputSchema: {
|
|
226
|
+
type: 'object',
|
|
227
|
+
properties: {
|
|
228
|
+
toolName: {
|
|
229
|
+
type: 'string',
|
|
230
|
+
description: 'Name of the tool to delete',
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
required: ['toolName'],
|
|
234
|
+
},
|
|
235
|
+
outputSchema: {
|
|
236
|
+
type: 'object',
|
|
237
|
+
properties: {
|
|
238
|
+
success: { type: 'boolean', description: 'Whether the operation succeeded' },
|
|
239
|
+
message: { type: 'string', description: 'Success message' },
|
|
240
|
+
},
|
|
241
|
+
required: ['success', 'message'],
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
name: 'runGraphTool',
|
|
246
|
+
description: 'Run an exported tool from the mcpGraph. Can specify existing tool name or run a tool definition supplied in payload.',
|
|
247
|
+
inputSchema: {
|
|
248
|
+
type: 'object',
|
|
249
|
+
properties: {
|
|
250
|
+
toolName: {
|
|
251
|
+
type: 'string',
|
|
252
|
+
description: 'Name of existing tool to run (optional if toolDefinition provided)',
|
|
253
|
+
},
|
|
254
|
+
toolDefinition: {
|
|
255
|
+
type: 'object',
|
|
256
|
+
description: 'Tool definition to run inline (optional if toolName provided)',
|
|
257
|
+
},
|
|
258
|
+
arguments: {
|
|
259
|
+
type: 'object',
|
|
260
|
+
description: 'Tool input arguments',
|
|
261
|
+
},
|
|
262
|
+
logging: {
|
|
263
|
+
type: 'boolean',
|
|
264
|
+
description: 'Include execution logging in response',
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
required: ['arguments'],
|
|
268
|
+
},
|
|
269
|
+
outputSchema: {
|
|
270
|
+
type: 'object',
|
|
271
|
+
properties: {
|
|
272
|
+
result: {
|
|
273
|
+
type: 'object',
|
|
274
|
+
description: 'Tool execution result (type depends on tool)',
|
|
275
|
+
},
|
|
276
|
+
logging: {
|
|
277
|
+
type: 'array',
|
|
278
|
+
description: 'Execution logs (present if logging was enabled)',
|
|
279
|
+
items: {
|
|
280
|
+
type: 'object',
|
|
281
|
+
properties: {
|
|
282
|
+
level: { type: 'string', description: 'Log level' },
|
|
283
|
+
message: { type: 'string', description: 'Log message' },
|
|
284
|
+
timestamp: { type: 'string', description: 'Log timestamp' },
|
|
285
|
+
args: { type: 'array', description: 'Additional log arguments' },
|
|
286
|
+
},
|
|
287
|
+
required: ['level', 'message', 'timestamp'],
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
executionHistory: {
|
|
291
|
+
type: 'array',
|
|
292
|
+
description: 'Execution history for debugging (if available)',
|
|
293
|
+
items: { type: 'object' },
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
required: ['result'],
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name: 'testJSONata',
|
|
301
|
+
description: 'Test a JSONata expression with context',
|
|
302
|
+
inputSchema: {
|
|
303
|
+
type: 'object',
|
|
304
|
+
properties: {
|
|
305
|
+
expression: {
|
|
306
|
+
type: 'string',
|
|
307
|
+
description: 'JSONata expression to test',
|
|
308
|
+
},
|
|
309
|
+
context: {
|
|
310
|
+
type: 'object',
|
|
311
|
+
description: 'Context object for evaluation',
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
required: ['expression', 'context'],
|
|
315
|
+
},
|
|
316
|
+
outputSchema: {
|
|
317
|
+
type: 'object',
|
|
318
|
+
properties: {
|
|
319
|
+
result: {
|
|
320
|
+
type: 'object',
|
|
321
|
+
description: 'Expression evaluation result (type depends on expression)',
|
|
322
|
+
},
|
|
323
|
+
error: {
|
|
324
|
+
type: 'object',
|
|
325
|
+
description: 'Error details (present if evaluation failed)',
|
|
326
|
+
properties: {
|
|
327
|
+
message: { type: 'string', description: 'Error message' },
|
|
328
|
+
details: {
|
|
329
|
+
type: 'object',
|
|
330
|
+
description: 'Additional error details',
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
required: ['message'],
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
name: 'testJSONLogic',
|
|
340
|
+
description: 'Test a JSON Logic expression with context',
|
|
341
|
+
inputSchema: {
|
|
342
|
+
type: 'object',
|
|
343
|
+
properties: {
|
|
344
|
+
expression: {
|
|
345
|
+
type: 'object',
|
|
346
|
+
description: 'JSON Logic expression object',
|
|
347
|
+
},
|
|
348
|
+
context: {
|
|
349
|
+
type: 'object',
|
|
350
|
+
description: 'Context object for evaluation',
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
required: ['expression', 'context'],
|
|
354
|
+
},
|
|
355
|
+
outputSchema: {
|
|
356
|
+
type: 'object',
|
|
357
|
+
properties: {
|
|
358
|
+
result: {
|
|
359
|
+
type: 'boolean',
|
|
360
|
+
description: 'Expression evaluation result (typically boolean for conditions)',
|
|
361
|
+
},
|
|
362
|
+
error: {
|
|
363
|
+
type: 'object',
|
|
364
|
+
description: 'Error details (present if evaluation failed)',
|
|
365
|
+
properties: {
|
|
366
|
+
message: { type: 'string', description: 'Error message' },
|
|
367
|
+
details: {
|
|
368
|
+
type: 'object',
|
|
369
|
+
description: 'Additional error details',
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
required: ['message'],
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
];
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Handle tool call
|
|
381
|
+
*/
|
|
382
|
+
async callTool(toolName, arguments_) {
|
|
383
|
+
switch (toolName) {
|
|
384
|
+
case 'getGraphServer': {
|
|
385
|
+
const serverInfo = this.api.getServerInfo();
|
|
386
|
+
return {
|
|
387
|
+
name: serverInfo.name,
|
|
388
|
+
version: serverInfo.version,
|
|
389
|
+
title: serverInfo.title,
|
|
390
|
+
instructions: serverInfo.instructions,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
case 'listGraphTools': {
|
|
394
|
+
const tools = this.api.listTools();
|
|
395
|
+
return {
|
|
396
|
+
items: tools.map(tool => ({
|
|
397
|
+
name: tool.name,
|
|
398
|
+
description: tool.description,
|
|
399
|
+
})),
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
case 'getGraphTool': {
|
|
403
|
+
const toolName_ = arguments_.toolName;
|
|
404
|
+
if (!toolName_) {
|
|
405
|
+
throw new Error('toolName is required');
|
|
406
|
+
}
|
|
407
|
+
const config = this.api.getConfig();
|
|
408
|
+
const tool = config.tools.find(t => t.name === toolName_);
|
|
409
|
+
if (!tool) {
|
|
410
|
+
throw new Error(`Tool "${toolName_}" not found`);
|
|
411
|
+
}
|
|
412
|
+
return tool;
|
|
413
|
+
}
|
|
414
|
+
case 'listMcpServers': {
|
|
415
|
+
if (!this.mcpDiscovery) {
|
|
416
|
+
throw new Error('MCP file not provided (use -m/--mcp flag)');
|
|
417
|
+
}
|
|
418
|
+
return {
|
|
419
|
+
items: await this.mcpDiscovery.listServers(),
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
case 'listMcpServerTools': {
|
|
423
|
+
if (!this.mcpDiscovery) {
|
|
424
|
+
throw new Error('MCP file not provided (use -m/--mcp flag)');
|
|
425
|
+
}
|
|
426
|
+
const serverName = arguments_.serverName;
|
|
427
|
+
return {
|
|
428
|
+
items: await this.mcpDiscovery.listTools(serverName),
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
case 'getMcpServerTool': {
|
|
432
|
+
if (!this.mcpDiscovery) {
|
|
433
|
+
throw new Error('MCP file not provided (use -m/--mcp flag)');
|
|
434
|
+
}
|
|
435
|
+
const serverName = arguments_.serverName;
|
|
436
|
+
const toolName_ = arguments_.toolName;
|
|
437
|
+
if (!serverName || !toolName_) {
|
|
438
|
+
throw new Error('serverName and toolName are required');
|
|
439
|
+
}
|
|
440
|
+
return await this.mcpDiscovery.getTool(serverName, toolName_);
|
|
441
|
+
}
|
|
442
|
+
case 'addGraphTool': {
|
|
443
|
+
const tool = arguments_.tool;
|
|
444
|
+
if (!tool) {
|
|
445
|
+
throw new Error('tool is required');
|
|
446
|
+
}
|
|
447
|
+
this.api.addTool(tool);
|
|
448
|
+
this.api.save();
|
|
449
|
+
return { success: true, message: `Tool "${tool.name}" added successfully` };
|
|
450
|
+
}
|
|
451
|
+
case 'updateGraphTool': {
|
|
452
|
+
const toolName_ = arguments_.toolName;
|
|
453
|
+
const tool = arguments_.tool;
|
|
454
|
+
if (!toolName_ || !tool) {
|
|
455
|
+
throw new Error('toolName and tool are required');
|
|
456
|
+
}
|
|
457
|
+
this.api.updateTool(toolName_, tool);
|
|
458
|
+
this.api.save();
|
|
459
|
+
return { success: true, message: `Tool "${toolName_}" updated successfully` };
|
|
460
|
+
}
|
|
461
|
+
case 'deleteGraphTool': {
|
|
462
|
+
const toolName_ = arguments_.toolName;
|
|
463
|
+
if (!toolName_) {
|
|
464
|
+
throw new Error('toolName is required');
|
|
465
|
+
}
|
|
466
|
+
this.api.deleteTool(toolName_);
|
|
467
|
+
this.api.save();
|
|
468
|
+
return { success: true, message: `Tool "${toolName_}" deleted successfully` };
|
|
469
|
+
}
|
|
470
|
+
case 'runGraphTool': {
|
|
471
|
+
const toolName_ = arguments_.toolName;
|
|
472
|
+
const toolDefinition = arguments_.toolDefinition;
|
|
473
|
+
const toolArguments = (arguments_.arguments || {});
|
|
474
|
+
const enableLogging = (arguments_.logging === true);
|
|
475
|
+
if (!toolName_ && !toolDefinition) {
|
|
476
|
+
throw new Error('Either toolName or toolDefinition must be provided');
|
|
477
|
+
}
|
|
478
|
+
if (toolName_ && toolDefinition) {
|
|
479
|
+
throw new Error('Cannot specify both toolName and toolDefinition');
|
|
480
|
+
}
|
|
481
|
+
const options = {
|
|
482
|
+
enableLogging,
|
|
483
|
+
};
|
|
484
|
+
let executionResult;
|
|
485
|
+
if (toolName_) {
|
|
486
|
+
const { promise } = this.api.executeTool(toolName_, toolArguments, options);
|
|
487
|
+
executionResult = await promise;
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
executionResult = await this.api.executeToolDefinition(toolDefinition, toolArguments, options);
|
|
491
|
+
}
|
|
492
|
+
const result = {
|
|
493
|
+
result: executionResult.result,
|
|
494
|
+
};
|
|
495
|
+
if (executionResult.logs) {
|
|
496
|
+
result.logging = executionResult.logs;
|
|
497
|
+
}
|
|
498
|
+
if (executionResult.executionHistory) {
|
|
499
|
+
// Include execution history for debugging if available
|
|
500
|
+
result.executionHistory = executionResult.executionHistory;
|
|
501
|
+
}
|
|
502
|
+
return result;
|
|
503
|
+
}
|
|
504
|
+
case 'testJSONata': {
|
|
505
|
+
const expression = arguments_.expression;
|
|
506
|
+
const context = (arguments_.context || {});
|
|
507
|
+
if (!expression) {
|
|
508
|
+
throw new Error('expression is required');
|
|
509
|
+
}
|
|
510
|
+
const testResult = await testJSONata(expression, context);
|
|
511
|
+
if (testResult.error) {
|
|
512
|
+
return {
|
|
513
|
+
result: null,
|
|
514
|
+
error: testResult.error,
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
return {
|
|
518
|
+
result: testResult.result,
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
case 'testJSONLogic': {
|
|
522
|
+
const expression = arguments_.expression;
|
|
523
|
+
const context = (arguments_.context || {});
|
|
524
|
+
if (!expression) {
|
|
525
|
+
throw new Error('expression is required');
|
|
526
|
+
}
|
|
527
|
+
const testResult = await testJSONLogic(expression, context);
|
|
528
|
+
if (testResult.error) {
|
|
529
|
+
return {
|
|
530
|
+
result: null,
|
|
531
|
+
error: testResult.error,
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
return {
|
|
535
|
+
result: testResult.result,
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
default:
|
|
539
|
+
throw new Error(`Tool "${toolName}" not implemented`);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Clean up resources
|
|
544
|
+
*/
|
|
545
|
+
async close() {
|
|
546
|
+
if (this.mcpDiscovery) {
|
|
547
|
+
await this.mcpDiscovery.close();
|
|
548
|
+
}
|
|
549
|
+
await this.api.close();
|
|
550
|
+
}
|
|
551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O;oBACL,MAAM,EAAE,UAAU,CAAC,MAAM;iBAC1B,CAAC;YACJ,CAAC;YAED;gBACE,MAAM,IAAI,KAAK,CAAC,SAAS,QAAQ,mBAAmB,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAClC,CAAC;QACD,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expression testers for JSONata and JSON Logic
|
|
3
|
+
*
|
|
4
|
+
* Provides functionality to test expressions with context
|
|
5
|
+
*/
|
|
6
|
+
export interface ExpressionTestResult {
|
|
7
|
+
result: unknown;
|
|
8
|
+
error?: {
|
|
9
|
+
message: string;
|
|
10
|
+
details?: unknown;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Test a JSONata expression with context
|
|
15
|
+
*/
|
|
16
|
+
export declare function testJSONata(expression: string, context: Record<string, unknown>): Promise<ExpressionTestResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Test a JSON Logic expression with context
|
|
19
|
+
*/
|
|
20
|
+
export declare function testJSONLogic(expression: unknown, context: Record<string, unknown>): Promise<ExpressionTestResult>;
|
|
21
|
+
//# sourceMappingURL=expression-testers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression-testers.d.ts","sourceRoot":"","sources":["../../src/toolkit/expression-testers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,oBAAoB,CAAC,CAkB/B;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,oBAAoB,CAAC,CAe/B"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expression testers for JSONata and JSON Logic
|
|
3
|
+
*
|
|
4
|
+
* Provides functionality to test expressions with context
|
|
5
|
+
*/
|
|
6
|
+
import { evaluateJsonata, validateJsonataSyntax } from '../expressions/jsonata.js';
|
|
7
|
+
import { evaluateJsonLogic } from '../expressions/json-logic.js';
|
|
8
|
+
/**
|
|
9
|
+
* Test a JSONata expression with context
|
|
10
|
+
*/
|
|
11
|
+
export async function testJSONata(expression, context) {
|
|
12
|
+
try {
|
|
13
|
+
// Validate syntax first
|
|
14
|
+
validateJsonataSyntax(expression);
|
|
15
|
+
// Evaluate with context (no history needed for testing)
|
|
16
|
+
const result = await evaluateJsonata(expression, context, [], 0);
|
|
17
|
+
return { result };
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return {
|
|
21
|
+
result: null,
|
|
22
|
+
error: {
|
|
23
|
+
message: error instanceof Error ? error.message : String(error),
|
|
24
|
+
details: error,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Test a JSON Logic expression with context
|
|
31
|
+
*/
|
|
32
|
+
export async function testJSONLogic(expression, context) {
|
|
33
|
+
try {
|
|
34
|
+
// Evaluate JSON Logic with context (no history needed for testing)
|
|
35
|
+
const result = await evaluateJsonLogic(expression, context, [], 0);
|
|
36
|
+
return { result };
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
return {
|
|
40
|
+
result: null,
|
|
41
|
+
error: {
|
|
42
|
+
message: error instanceof Error ? error.message : String(error),
|
|
43
|
+
details: error,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=expression-testers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression-testers.js","sourceRoot":"","sources":["../../src/toolkit/expression-testers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAWjE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,UAAkB,EAClB,OAAgC;IAEhC,IAAI,CAAC;QACH,wBAAwB;QACxB,qBAAqB,CAAC,UAAU,CAAC,CAAC;QAElC,wDAAwD;QACxD,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAEjE,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE;gBACL,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC/D,OAAO,EAAE,KAAK;aACf;SACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAmB,EACnB,OAAgC;IAEhC,IAAI,CAAC;QACH,mEAAmE;QACnE,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAEnE,O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