mcpgraph 0.1.19 → 0.1.21

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 (52) hide show
  1. package/README.md +69 -48
  2. package/dist/api.d.ts +8 -4
  3. package/dist/api.d.ts.map +1 -1
  4. package/dist/api.js +13 -4
  5. package/dist/api.js.map +1 -1
  6. package/dist/config/expression-validator.d.ts.map +1 -1
  7. package/dist/config/expression-validator.js +12 -10
  8. package/dist/config/expression-validator.js.map +1 -1
  9. package/dist/config/loader.d.ts +8 -2
  10. package/dist/config/loader.d.ts.map +1 -1
  11. package/dist/config/loader.js +16 -2
  12. package/dist/config/loader.js.map +1 -1
  13. package/dist/config/mcp-loader.d.ts +13 -0
  14. package/dist/config/mcp-loader.d.ts.map +1 -0
  15. package/dist/config/mcp-loader.js +47 -0
  16. package/dist/config/mcp-loader.js.map +1 -0
  17. package/dist/config/schema.d.ts +292 -186
  18. package/dist/config/schema.d.ts.map +1 -1
  19. package/dist/config/schema.js +5 -6
  20. package/dist/config/schema.js.map +1 -1
  21. package/dist/errors/mcp-tool-error.d.ts +46 -0
  22. package/dist/errors/mcp-tool-error.d.ts.map +1 -0
  23. package/dist/errors/mcp-tool-error.js +63 -0
  24. package/dist/errors/mcp-tool-error.js.map +1 -0
  25. package/dist/execution/executor.d.ts +2 -2
  26. package/dist/execution/executor.d.ts.map +1 -1
  27. package/dist/execution/executor.js +11 -9
  28. package/dist/execution/executor.js.map +1 -1
  29. package/dist/execution/nodes/mcp-tool-executor.d.ts.map +1 -1
  30. package/dist/execution/nodes/mcp-tool-executor.js +49 -15
  31. package/dist/execution/nodes/mcp-tool-executor.js.map +1 -1
  32. package/dist/graph/validator.d.ts.map +1 -1
  33. package/dist/graph/validator.js +52 -69
  34. package/dist/graph/validator.js.map +1 -1
  35. package/dist/main.js +23 -5
  36. package/dist/main.js.map +1 -1
  37. package/dist/mcp/client-manager.d.ts +12 -0
  38. package/dist/mcp/client-manager.d.ts.map +1 -1
  39. package/dist/mcp/client-manager.js +38 -4
  40. package/dist/mcp/client-manager.js.map +1 -1
  41. package/dist/types/config.d.ts +4 -5
  42. package/dist/types/config.d.ts.map +1 -1
  43. package/docs/building.md +76 -0
  44. package/docs/design.md +55 -43
  45. package/docs/github-pages-setup.md +492 -0
  46. package/docs/introspection-debugging.md +1 -1
  47. package/examples/api-usage.ts +3 -3
  48. package/examples/count_files.yaml +47 -52
  49. package/examples/loop_example.yaml +55 -58
  50. package/examples/switch_example.yaml +48 -55
  51. package/examples/test_minimal.yaml +23 -0
  52. package/package.json +2 -2
@@ -4,7 +4,8 @@ version: "1.0"
4
4
  server:
5
5
  name: "loopExample"
6
6
  version: "1.0.0"
7
- description: "Example with a loop using history functions"
7
+ title: "Loop Example"
8
+ instructions: "This example demonstrates loops and execution history functions like $executionCount() and $nodeExecution()."
8
9
 
9
10
  # Tool Definitions
10
11
  tools:
@@ -24,61 +25,57 @@ tools:
24
25
  sum:
25
26
  type: "number"
26
27
  description: "The sum from 1 to n"
27
-
28
- # Graph Nodes
29
- nodes:
30
- # Entry node: Receives tool arguments
31
- - id: "entry_sum"
32
- type: "entry"
33
- tool: "sum_to_n"
34
- next: "increment_node"
35
-
36
- # Increment counter and add to sum
37
- # Uses $nodeExecution() to get the previous iteration of this node
38
- # First iteration: $executionCount("increment_node") = 0, so we initialize
39
- # Subsequent iterations: $nodeExecution("increment_node", -1) gets the last execution
40
- - id: "increment_node"
41
- type: "transform"
42
- transform:
43
- expr: |
44
- $executionCount("increment_node") = 0
45
- ? {
46
- "counter": 1,
47
- "sum": 1,
48
- "target": $.entry_sum.n
49
- }
50
- : {
51
- "counter": $nodeExecution("increment_node", -1).counter + 1,
52
- "sum": $nodeExecution("increment_node", -1).sum + $nodeExecution("increment_node", -1).counter + 1,
53
- "target": $.entry_sum.n
28
+ nodes:
29
+ # Entry node: Receives tool arguments
30
+ - id: "entry_sum"
31
+ type: "entry"
32
+ next: "increment_node"
33
+
34
+ # Increment counter and add to sum
35
+ # Uses $nodeExecution() to get the previous iteration of this node
36
+ # First iteration: $executionCount("increment_node") = 0, so we initialize
37
+ # Subsequent iterations: $nodeExecution("increment_node", -1) gets the last execution
38
+ - id: "increment_node"
39
+ type: "transform"
40
+ transform:
41
+ expr: |
42
+ $executionCount("increment_node") = 0
43
+ ? {
44
+ "counter": 1,
45
+ "sum": 1,
46
+ "target": $.entry_sum.n
47
+ }
48
+ : {
49
+ "counter": $nodeExecution("increment_node", -1).counter + 1,
50
+ "sum": $nodeExecution("increment_node", -1).sum + $nodeExecution("increment_node", -1).counter + 1,
51
+ "target": $.entry_sum.n
52
+ }
53
+ next: "check_condition"
54
+
55
+ # Check if we should continue looping
56
+ - id: "check_condition"
57
+ type: "switch"
58
+ conditions:
59
+ - rule:
60
+ "<": [{"var": "$.increment_node.counter"}, {"var": "$.increment_node.target"}]
61
+ target: "increment_node"
62
+ - target: "exit_sum"
63
+
64
+ # Exit node: Extracts the sum from increment_node
65
+ # Uses $previousNode() to verify it returns the switch node's output (target node ID)
66
+ # The output matches the tool's outputSchema (just the sum)
67
+ - id: "exit_sum"
68
+ type: "transform"
69
+ transform:
70
+ expr: |
71
+ $previousNode() = "exit_sum" ? {
72
+ "sum": $.increment_node.sum
73
+ } : {
74
+ "sum": 0,
75
+ "error": "previousNode check failed"
54
76
  }
55
- next: "check_condition"
56
-
57
- # Check if we should continue looping
58
- - id: "check_condition"
59
- type: "switch"
60
- conditions:
61
- - rule:
62
- "<": [{"var": "$.increment_node.counter"}, {"var": "$.increment_node.target"}]
63
- target: "increment_node"
64
- - target: "exit_sum"
65
-
66
- # Exit node: Extracts the sum from increment_node
67
- # Uses $previousNode() to verify it returns the switch node's output (target node ID)
68
- # The output matches the tool's outputSchema (just the sum)
69
- - id: "exit_sum"
70
- type: "transform"
71
- transform:
72
- expr: |
73
- $previousNode() = "exit_sum" ? {
74
- "sum": $.increment_node.sum
75
- } : {
76
- "sum": 0,
77
- "error": "previousNode check failed"
78
- }
79
- next: "exit_sum_final"
80
-
81
- # Final exit node
82
- - id: "exit_sum_final"
83
- type: "exit"
84
- tool: "sum_to_n"
77
+ next: "exit_sum_final"
78
+
79
+ # Final exit node
80
+ - id: "exit_sum_final"
81
+ type: "exit"
@@ -4,7 +4,8 @@ version: "1.0"
4
4
  server:
5
5
  name: "switchExample"
6
6
  version: "1.0.0"
7
- description: "Example demonstrating switch node functionality"
7
+ title: "Switch Node Example"
8
+ instructions: "This example demonstrates conditional routing using switch nodes with JSON Logic."
8
9
 
9
10
  # Tool Definitions
10
11
  tools:
@@ -24,57 +25,49 @@ tools:
24
25
  result:
25
26
  type: "string"
26
27
  description: "The routing result"
27
-
28
- # Graph Nodes
29
- nodes:
30
- # Entry node: Receives tool arguments
31
- - id: "entry"
32
- type: "entry"
33
- tool: "test_switch"
34
- next: "switch_node"
35
-
36
- # Switch node: Routes based on value
37
- - id: "switch_node"
38
- type: "switch"
39
- conditions:
40
- - rule:
41
- ">":
42
- - { var: "entry.value" }
43
- - 10
44
- target: "high_path"
45
- - rule:
46
- ">":
47
- - { var: "entry.value" }
48
- - 0
49
- target: "low_path"
50
- - target: "zero_path"
51
-
52
- # High path (> 10)
53
- - id: "high_path"
54
- type: "transform"
55
- transform:
56
- expr: |
57
- { "result": "high" }
58
- next: "exit"
59
-
60
- # Low path (> 0 but <= 10)
61
- - id: "low_path"
62
- type: "transform"
63
- transform:
64
- expr: |
65
- { "result": "low" }
66
- next: "exit"
67
-
68
- # Zero/negative path (default)
69
- - id: "zero_path"
70
- type: "transform"
71
- transform:
72
- expr: |
73
- { "result": "zero_or_negative" }
74
- next: "exit"
75
-
76
- # Exit node: Returns the result
77
- - id: "exit"
78
- type: "exit"
79
- tool: "test_switch"
80
-
28
+ nodes:
29
+ # Entry node: Receives tool arguments
30
+ - id: "entry"
31
+ type: "entry"
32
+ next: "switch_node"
33
+
34
+ # Switch node: Routes based on value
35
+ - id: "switch_node"
36
+ type: "switch"
37
+ conditions:
38
+ - rule:
39
+ ">":
40
+ - { var: "entry.value" }
41
+ - 10
42
+ target: "high_path"
43
+ - rule:
44
+ ">":
45
+ - { var: "entry.value" }
46
+ - 0
47
+ target: "low_path"
48
+ - target: "zero_path"
49
+
50
+ # High path (> 10)
51
+ - id: "high_path"
52
+ type: "transform"
53
+ transform:
54
+ expr: '{ "result": "high" }'
55
+ next: "exit"
56
+
57
+ # Low path (> 0 but <= 10)
58
+ - id: "low_path"
59
+ type: "transform"
60
+ transform:
61
+ expr: '{ "result": "low" }'
62
+ next: "exit"
63
+
64
+ # Zero/negative path (default)
65
+ - id: "zero_path"
66
+ type: "transform"
67
+ transform:
68
+ expr: '{ "result": "zero_or_negative" }'
69
+ next: "exit"
70
+
71
+ # Exit node: Returns the result
72
+ - id: "exit"
73
+ type: "exit"
@@ -0,0 +1,23 @@
1
+ version: "1.0"
2
+
3
+ # MCP Server Metadata - minimal config for testing defaults
4
+ # No title (should default to name)
5
+ # No instructions (should be undefined)
6
+ server:
7
+ name: "testMinimal"
8
+ version: "1.0.0"
9
+
10
+ # Tool Definitions
11
+ tools:
12
+ - name: "test_tool"
13
+ description: "Test tool"
14
+ inputSchema:
15
+ type: "object"
16
+ outputSchema:
17
+ type: "object"
18
+ nodes:
19
+ - id: "entry"
20
+ type: "entry"
21
+ next: "exit"
22
+ - id: "exit"
23
+ type: "exit"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcpgraph",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "description": "MCP server that executes directed graphs of MCP server calls",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",
@@ -28,7 +28,7 @@
28
28
  "start": "node dist/main.js",
29
29
  "dev": "tsx src/main.ts",
30
30
  "watch": "tsc --watch",
31
- "test": "tsx --test tests/*.test.ts",
31
+ "test": "tsx --test --test-timeout=30000 tests/*.test.ts",
32
32
  "prepublishOnly": "npm run build"
33
33
  },
34
34
  "keywords": [