mcpgraph 0.1.12 → 0.1.13
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 +2 -2
- package/dist/execution/context.d.ts.map +1 -1
- package/dist/execution/context.js +2 -6
- package/dist/execution/context.js.map +1 -1
- package/dist/expressions/context.d.ts +0 -1
- package/dist/expressions/context.d.ts.map +1 -1
- package/dist/expressions/context.js.map +1 -1
- package/docs/design.md +2 -2
- package/docs/implementation.md +6 -6
- package/examples/count_files.yaml +2 -2
- package/examples/switch_example.yaml +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ nodes:
|
|
|
68
68
|
server: "filesystem"
|
|
69
69
|
tool: "list_directory"
|
|
70
70
|
args:
|
|
71
|
-
path: "$.
|
|
71
|
+
path: "$.entry_count_files.directory"
|
|
72
72
|
next: "count_files_node"
|
|
73
73
|
|
|
74
74
|
# Transform and count files
|
|
@@ -76,7 +76,7 @@ nodes:
|
|
|
76
76
|
type: "transform"
|
|
77
77
|
transform:
|
|
78
78
|
expr: |
|
|
79
|
-
{ "count": $count($split(list_directory_node, "\n")) }
|
|
79
|
+
{ "count": $count($split($.list_directory_node, "\n")) }
|
|
80
80
|
next: "exit_count_files"
|
|
81
81
|
|
|
82
82
|
# Exit node: Returns the count
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/execution/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,OAAO,CAAwB;gBAE3B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/execution/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,OAAO,CAAwB;gBAE3B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAM9C,OAAO,IAAI,WAAW;IAItB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAQpD,UAAU,CACR,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,KAAK,GACZ,IAAI;IAaP,UAAU,IAAI,mBAAmB,EAAE;CAGpC"}
|
|
@@ -5,12 +5,8 @@ export class ExecutionContext {
|
|
|
5
5
|
data;
|
|
6
6
|
history;
|
|
7
7
|
constructor(toolInput) {
|
|
8
|
-
// Initialize context
|
|
9
|
-
this.data = {
|
|
10
|
-
input: toolInput,
|
|
11
|
-
// Also make input properties directly accessible for convenience
|
|
12
|
-
...toolInput,
|
|
13
|
-
};
|
|
8
|
+
// Initialize empty context - tool input will be stored by entry node
|
|
9
|
+
this.data = {};
|
|
14
10
|
this.history = [];
|
|
15
11
|
}
|
|
16
12
|
getData() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/execution/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,OAAO,gBAAgB;IACnB,IAAI,CAAc;IAClB,OAAO,CAAwB;IAEvC,YAAY,SAAkC;QAC5C,
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/execution/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,OAAO,gBAAgB;IACnB,IAAI,CAAc;IAClB,OAAO,CAAwB;IAEvC,YAAY,SAAkC;QAC5C,qEAAqE;QACrE,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,aAAa,CAAC,MAAc,EAAE,MAAe;QAC3C,iDAAiD;QACjD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;QAC3B,iDAAiD;QACjD,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAC1B,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED,UAAU,CACR,MAAc,EACd,QAAgB,EAChB,KAAc,EACd,MAAe,EACf,SAAiB,EACjB,OAAe,EACf,KAAa;QAEb,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAChB,MAAM;YACN,QAAQ;YACR,KAAK;YACL,MAAM;YACN,SAAS;YACT,OAAO;YACP,QAAQ,EAAE,OAAO,GAAG,SAAS;YAC7B,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Expression evaluation context builder
|
|
3
3
|
*/
|
|
4
4
|
export interface ExecutionContext {
|
|
5
|
-
input: Record<string, unknown>;
|
|
6
5
|
[key: string]: unknown;
|
|
7
6
|
}
|
|
8
7
|
export declare function buildContext(toolInput: Record<string, unknown>, nodeOutputs?: Record<string, unknown>): ExecutionContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/expressions/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,gBAAgB;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/expressions/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,gBAAgB;IAG/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACxC,gBAAgB,CAKlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/expressions/context.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/expressions/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,MAAM,UAAU,YAAY,CAC1B,SAAkC,EAClC,cAAuC,EAAE;IAEzC,OAAO;QACL,KAAK,EAAE,SAAS;QAChB,GAAG,WAAW;KACf,CAAC;AACJ,CAAC"}
|
package/docs/design.md
CHANGED
|
@@ -184,7 +184,7 @@ nodes:
|
|
|
184
184
|
server: "filesystem"
|
|
185
185
|
tool: "list_directory"
|
|
186
186
|
args:
|
|
187
|
-
path: "$.
|
|
187
|
+
path: "$.entry_count_files.directory"
|
|
188
188
|
next: "count_files_node"
|
|
189
189
|
|
|
190
190
|
# Transform and count files
|
|
@@ -192,7 +192,7 @@ nodes:
|
|
|
192
192
|
type: "transform"
|
|
193
193
|
transform:
|
|
194
194
|
expr: |
|
|
195
|
-
{ "count": $count($split(list_directory_node, "\n")) }
|
|
195
|
+
{ "count": $count($split($.list_directory_node, "\n")) }
|
|
196
196
|
next: "exit_count_files"
|
|
197
197
|
|
|
198
198
|
# Exit node: Returns the count
|
package/docs/implementation.md
CHANGED
|
@@ -123,7 +123,7 @@ Graph structure validation:
|
|
|
123
123
|
JSONata library wrapper:
|
|
124
124
|
- Expression evaluation with context data
|
|
125
125
|
- Error handling
|
|
126
|
-
- Support for JSONata references (e.g., `$.
|
|
126
|
+
- Support for JSONata references (e.g., `$.entry_count_files.directory` for tool input, `$.list_directory_node` for node outputs)
|
|
127
127
|
|
|
128
128
|
### 4.2 JSON Logic Integration
|
|
129
129
|
|
|
@@ -192,7 +192,7 @@ Switch node execution:
|
|
|
192
192
|
Entry node execution:
|
|
193
193
|
- Receive tool arguments from MCP client
|
|
194
194
|
- Initialize execution context with tool arguments
|
|
195
|
-
- Make tool arguments available to subsequent nodes (e.g., `$.
|
|
195
|
+
- Make tool arguments available to subsequent nodes via entry node output (e.g., `$.entry_count_files.directory`)
|
|
196
196
|
- Pass execution to next node
|
|
197
197
|
|
|
198
198
|
### 5.6 Exit Node Executor
|
|
@@ -212,10 +212,10 @@ Exit node execution:
|
|
|
212
212
|
|
|
213
213
|
Execution state management:
|
|
214
214
|
- Current node tracking
|
|
215
|
-
- Data context (
|
|
215
|
+
- Data context (node outputs stored by node ID, e.g., `$.entry_node_id.*`, `$.mcp_node_id.*`)
|
|
216
216
|
- Execution history
|
|
217
217
|
- Error state
|
|
218
|
-
- Data access for expressions
|
|
218
|
+
- Data access for expressions (all data referenced by node ID)
|
|
219
219
|
|
|
220
220
|
### 6.2 Graph Executor
|
|
221
221
|
|
|
@@ -348,9 +348,9 @@ README updated with:
|
|
|
348
348
|
|
|
349
349
|
1. **Custom Execution Engine**: A custom execution loop was implemented to provide full control over execution flow, enable observability (execution history), and support future debugging/introspection features.
|
|
350
350
|
|
|
351
|
-
2. **Expression Evaluation**: All expressions (JSONata, JSON Logic) are evaluated with a consistent context
|
|
351
|
+
2. **Expression Evaluation**: All expressions (JSONata, JSON Logic) are evaluated with a consistent context where all data is referenced by node ID. Tool input is stored as the entry node's output (e.g., `$.entry_count_files.directory`), and each node's output is stored by its node ID (e.g., `$.list_directory_node`).
|
|
352
352
|
|
|
353
|
-
3. **Data Flow**: Data flows through nodes as a JSON object
|
|
353
|
+
3. **Data Flow**: Data flows through nodes as a JSON object where each node's output is stored by its node ID. Each node can read from previous nodes (by their node IDs) and write its own output (stored by its node ID).
|
|
354
354
|
|
|
355
355
|
4. **Error Handling**: Errors at any node are caught, logged, and propagated. Basic error handling works; custom error types would be an enhancement.
|
|
356
356
|
|
|
@@ -57,7 +57,7 @@ nodes:
|
|
|
57
57
|
server: "filesystem"
|
|
58
58
|
tool: "list_directory"
|
|
59
59
|
args:
|
|
60
|
-
path: "$.
|
|
60
|
+
path: "$.entry_count_files.directory"
|
|
61
61
|
next: "count_files_node"
|
|
62
62
|
|
|
63
63
|
# Transform and count files
|
|
@@ -65,7 +65,7 @@ nodes:
|
|
|
65
65
|
type: "transform"
|
|
66
66
|
transform:
|
|
67
67
|
expr: |
|
|
68
|
-
{ "count": $count($split(list_directory_node, "\n")) }
|
|
68
|
+
{ "count": $count($split($.list_directory_node, "\n")) }
|
|
69
69
|
next: "exit_count_files"
|
|
70
70
|
|
|
71
71
|
# Exit node: Returns the count
|
|
@@ -39,12 +39,12 @@ nodes:
|
|
|
39
39
|
conditions:
|
|
40
40
|
- rule:
|
|
41
41
|
">":
|
|
42
|
-
- { var: "value" }
|
|
42
|
+
- { var: "entry.value" }
|
|
43
43
|
- 10
|
|
44
44
|
target: "high_path"
|
|
45
45
|
- rule:
|
|
46
46
|
">":
|
|
47
|
-
- { var: "value" }
|
|
47
|
+
- { var: "entry.value" }
|
|
48
48
|
- 0
|
|
49
49
|
target: "low_path"
|
|
50
50
|
- target: "zero_path"
|