mcpgraph 0.1.30 → 0.1.32
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 +6 -0
- package/dist/config/expression-validator.js +53 -11
- package/dist/config/expression-validator.js.map +1 -1
- package/dist/execution/arg-evaluator.d.ts +16 -0
- package/dist/execution/arg-evaluator.d.ts.map +1 -0
- package/dist/execution/arg-evaluator.js +54 -0
- package/dist/execution/arg-evaluator.js.map +1 -0
- package/dist/execution/nodes/mcp-tool-executor.d.ts.map +1 -1
- package/dist/execution/nodes/mcp-tool-executor.js +3 -14
- package/dist/execution/nodes/mcp-tool-executor.js.map +1 -1
- package/dist/toolkit/expression-testers.d.ts.map +1 -1
- package/dist/toolkit/expression-testers.js +25 -18
- package/dist/toolkit/expression-testers.js.map +1 -1
- package/docs/building.md +3 -10
- package/docs/no-code-code-mode.md +6 -1
- package/docs/toolkit.md +22 -2
- package/examples/file_utils.yaml +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ MCP server that executes directed graphs of MCP server calls.
|
|
|
6
6
|
|
|
7
7
|
> **🎥 Watch the Demo:** Check out the [**mcpGraph Overview and mcpGraphUX Demo**](https://youtu.be/eyC7OzuB6c4) video to see mcpGraph in action and explore the visual debugging capabilities of mcpGraphUX.
|
|
8
8
|
|
|
9
|
+
> **🎥 Watch the Demo:** Check out the [**mcpGraphToolkit Deep Dive**](https://youtu.be/gR7s0MD8Gro) video to see an agent autonomously build, test, and deploy orchestration tools—"Code Mode" without the code.
|
|
10
|
+
|
|
9
11
|
## Overview
|
|
10
12
|
|
|
11
13
|
mcpGraph is an MCP (Model Context Protocol) server that exposes tools defined by declarative YAML configurations. Each tool executes a directed graph of nodes that can call other MCP tools, transform data, and make routing decisions, all without embedding a full programming language.
|
|
@@ -17,6 +19,10 @@ mcpGraph is an MCP (Model Context Protocol) server that exposes tools defined by
|
|
|
17
19
|
- **Observable**: Every transformation and decision is traceable
|
|
18
20
|
- **No Embedded Code**: All logic expressed using standard expression languages ([JSONata](https://jsonata.org/), [JSON Logic](https://jsonlogic.com/))
|
|
19
21
|
|
|
22
|
+
**Related Tools:**
|
|
23
|
+
- **mcpGraphUX**: A visual debugging and development environment for mcpGraph. Visualize graph structures, animate through active nodes during execution, set breakpoints, and inspect node inputs and outputs. See the [mcpGraphUX repository](https://github.com/TeamSparkAI/mcpGraph-ux) for details.
|
|
24
|
+
- **mcpGraphToolkit**: An MCP server that provides tools for building, testing, and managing mcpGraph tools. Use it to discover available MCP servers, test expressions, and create graph tools interactively. See [mcpGraphToolkit Overview](docs/toolkit.md) for details.
|
|
25
|
+
|
|
20
26
|
## Example
|
|
21
27
|
|
|
22
28
|
Here's a simple example that counts files in a directory:
|
|
@@ -26,6 +26,52 @@ export function validateConfigExpressions(config) {
|
|
|
26
26
|
}
|
|
27
27
|
return errors;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Recursively validate argument expressions
|
|
31
|
+
*/
|
|
32
|
+
function validateArgExpressions(args, path = "args") {
|
|
33
|
+
// Expression object: { "expr": "..." }
|
|
34
|
+
if (typeof args === "object" &&
|
|
35
|
+
args !== null &&
|
|
36
|
+
!Array.isArray(args) &&
|
|
37
|
+
Object.keys(args).length === 1 &&
|
|
38
|
+
"expr" in args &&
|
|
39
|
+
typeof args.expr === "string") {
|
|
40
|
+
const expr = args.expr;
|
|
41
|
+
try {
|
|
42
|
+
validateJsonataSyntax(expr);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
46
|
+
throw new Error(`Invalid JSONata syntax in ${path}.expr: ${errorMessage}`);
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// Expression object with other keys: error
|
|
51
|
+
if (typeof args === "object" &&
|
|
52
|
+
args !== null &&
|
|
53
|
+
!Array.isArray(args) &&
|
|
54
|
+
"expr" in args &&
|
|
55
|
+
Object.keys(args).length > 1) {
|
|
56
|
+
throw new Error(`Invalid expression object at ${path}: object with "expr" property must have only that property. ` +
|
|
57
|
+
`Found keys: ${Object.keys(args).join(", ")}`);
|
|
58
|
+
}
|
|
59
|
+
// Array: recurse into elements
|
|
60
|
+
if (Array.isArray(args)) {
|
|
61
|
+
args.forEach((item, index) => {
|
|
62
|
+
validateArgExpressions(item, `${path}[${index}]`);
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// Object: recurse into properties
|
|
67
|
+
if (typeof args === "object" && args !== null) {
|
|
68
|
+
for (const [key, value] of Object.entries(args)) {
|
|
69
|
+
validateArgExpressions(value, `${path}.${key}`);
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// Primitive: no validation needed
|
|
74
|
+
}
|
|
29
75
|
/**
|
|
30
76
|
* Validate expressions in a single node
|
|
31
77
|
*/
|
|
@@ -42,17 +88,13 @@ function validateNodeExpressions(node, config) {
|
|
|
42
88
|
}
|
|
43
89
|
break;
|
|
44
90
|
case "mcp":
|
|
45
|
-
// Validate any JSONata expressions in args
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
53
|
-
throw new Error(`Invalid JSONata syntax in args.${key}: ${errorMessage}`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
91
|
+
// Validate any JSONata expressions in args (recursively)
|
|
92
|
+
try {
|
|
93
|
+
validateArgExpressions(node.args);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
97
|
+
throw new Error(`Invalid JSONata syntax in args: ${errorMessage}`);
|
|
56
98
|
}
|
|
57
99
|
break;
|
|
58
100
|
case "switch":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-validator.js","sourceRoot":"","sources":["../../src/config/expression-validator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAAsB;IAC9D,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,IAAI,CAAC;gBACH,uBAAuB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACxC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC5E,MAAM,CAAC,IAAI,CAAC;oBACV,OAAO,EAAE,YAAY;oBACrB,MAAM,EAAE,IAAI,CAAC,EAAE;iBAChB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAS,
|
|
1
|
+
{"version":3,"file":"expression-validator.js","sourceRoot":"","sources":["../../src/config/expression-validator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAAsB;IAC9D,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,IA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
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility for evaluating MCP node arguments with recursive JSONata expression support
|
|
3
|
+
*/
|
|
4
|
+
import type { NodeExecutionRecord } from "../types/execution.js";
|
|
5
|
+
/**
|
|
6
|
+
* Recursively evaluate argument values, treating objects with single "expr" property as JSONata expressions
|
|
7
|
+
*
|
|
8
|
+
* Evaluation rules:
|
|
9
|
+
* 1. Object with exactly one key "expr" (string) → evaluate as JSONata
|
|
10
|
+
* 2. Object with "expr" and other keys → error (ambiguous)
|
|
11
|
+
* 3. Array → recurse into each element
|
|
12
|
+
* 4. Object (non-expr) → recurse into each property
|
|
13
|
+
* 5. Primitive → pass through as literal
|
|
14
|
+
*/
|
|
15
|
+
export declare function evaluateArgValue(value: unknown, context: Record<string, unknown>, history: NodeExecutionRecord[], currentIndex: number): Promise<unknown>;
|
|
16
|
+
//# sourceMappingURL=arg-evaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arg-evaluator.d.ts","sourceRoot":"","sources":["../../src/execution/arg-evaluator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAIjE;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,EAAE,mBAAmB,EAAE,EAC9B,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,OAAO,CAAC,CA+ClB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility for evaluating MCP node arguments with recursive JSONata expression support
|
|
3
|
+
*/
|
|
4
|
+
import { evaluateJsonata } from "../expressions/jsonata.js";
|
|
5
|
+
import { logger } from "../logger.js";
|
|
6
|
+
/**
|
|
7
|
+
* Recursively evaluate argument values, treating objects with single "expr" property as JSONata expressions
|
|
8
|
+
*
|
|
9
|
+
* Evaluation rules:
|
|
10
|
+
* 1. Object with exactly one key "expr" (string) → evaluate as JSONata
|
|
11
|
+
* 2. Object with "expr" and other keys → error (ambiguous)
|
|
12
|
+
* 3. Array → recurse into each element
|
|
13
|
+
* 4. Object (non-expr) → recurse into each property
|
|
14
|
+
* 5. Primitive → pass through as literal
|
|
15
|
+
*/
|
|
16
|
+
export async function evaluateArgValue(value, context, history, currentIndex) {
|
|
17
|
+
// Expression object: { "expr": "..." }
|
|
18
|
+
if (typeof value === "object" &&
|
|
19
|
+
value !== null &&
|
|
20
|
+
!Array.isArray(value) &&
|
|
21
|
+
"expr" in value) {
|
|
22
|
+
// If expr exists, it must be the only key and must be a string
|
|
23
|
+
if (Object.keys(value).length === 1) {
|
|
24
|
+
const exprValue = value.expr;
|
|
25
|
+
if (typeof exprValue !== "string") {
|
|
26
|
+
throw new Error(`Invalid expression object: "expr" property must be a string, got ${typeof exprValue}`);
|
|
27
|
+
}
|
|
28
|
+
const expr = exprValue;
|
|
29
|
+
const evaluated = await evaluateJsonata(expr, context, history, currentIndex);
|
|
30
|
+
logger.debug(`JSONata "${expr}" evaluated to: ${JSON.stringify(evaluated)}`);
|
|
31
|
+
return evaluated;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
// Expression object with other keys: error
|
|
35
|
+
throw new Error(`Invalid expression object: object with "expr" property must have only that property. ` +
|
|
36
|
+
`Found keys: ${Object.keys(value).join(", ")}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Array: recurse into elements
|
|
40
|
+
if (Array.isArray(value)) {
|
|
41
|
+
return Promise.all(value.map((item) => evaluateArgValue(item, context, history, currentIndex)));
|
|
42
|
+
}
|
|
43
|
+
// Object: recurse into properties
|
|
44
|
+
if (typeof value === "object" && value !== null) {
|
|
45
|
+
const result = {};
|
|
46
|
+
for (const [key, val] of Object.entries(value)) {
|
|
47
|
+
result[key] = await evaluateArgValue(val, context, history, currentIndex);
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
// Primitive: pass through as literal
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=arg-evaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arg-evaluator.js","sourceRoot":"","sources":["../../src/execution/arg-evaluator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAc,EACd,OAAgC,EAChC,OAA8B,EAC9B,YAAoB;IAEpB,uCAAuC;IACvC,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,MAAM,IAAI,KAAK,EACf,CAAC;QACD,+DAA+D;QAC/D,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpC,MAAM,SAAS,GAAI,KAA2B,CAAC,IAAI,CAAC;YACpD,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;gBAClC,MAAM,IAAI,KAAK,CACb,oEAAoE,OAAO,SAAS,EAAE,CACvF,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,GAAG,SAAS,CAAC;YACvB,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;YAC9E,MAAM,CAAC,KAAK,CAAC,YAAY,IAAI,mBAAmB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;YAC7E,OAAO,SAAS,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,2CAA2C;YAC3C,MAAM,IAAI,KAAK,CACb,uFAAuF;gBACvF,eAAe,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC/C,CAAC;QACJ,CAAC;IACH,CAAC;IAED,+BAA+B;IAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC,GAAG,CAChB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAC5E,CAAC;IACJ,CAAC;IAED,kCAAkC;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,MAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/C,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,qCAAqC;IACrC,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-tool-executor.d.ts","sourceRoot":"","sources":["../../../src/execution/nodes/mcp-tool-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp-tool-executor.d.ts","sourceRoot":"","sources":["../../../src/execution/nodes/mcp-tool-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAOpE,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,gBAAgB,EAC/B,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAqFhD"}
|
|
@@ -1,29 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MCP tool node executor
|
|
3
3
|
*/
|
|
4
|
-
import { evaluateJsonata } from "../../expressions/jsonata.js";
|
|
5
4
|
import { logger } from "../../logger.js";
|
|
6
5
|
import { ToolCallMcpError, ToolCallError } from "../../errors/mcp-tool-error.js";
|
|
7
6
|
import { McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
8
7
|
import { extractMcpToolOutput } from "../../mcp/tool-output-extractor.js";
|
|
8
|
+
import { evaluateArgValue } from "../arg-evaluator.js";
|
|
9
9
|
export async function executeMcpToolNode(node, context, clientManager, serverConfig, startTime) {
|
|
10
10
|
logger.debug(`Executing MCP tool node: ${node.id} (${node.server}.${node.tool})`);
|
|
11
11
|
const exprContext = context.getData();
|
|
12
12
|
const history = context.getHistory();
|
|
13
13
|
const currentIndex = history.length; // This will be the index after we add this execution
|
|
14
|
-
// Pre-transform:
|
|
15
|
-
const transformedArgs =
|
|
16
|
-
for (const [key, value] of Object.entries(node.args)) {
|
|
17
|
-
if (typeof value === "string" && value.startsWith("$")) {
|
|
18
|
-
// JSONata expression
|
|
19
|
-
const evaluated = await evaluateJsonata(value, exprContext, history, currentIndex);
|
|
20
|
-
transformedArgs[key] = evaluated;
|
|
21
|
-
logger.debug(`JSONata "${value}" evaluated to: ${JSON.stringify(evaluated)}`);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
transformedArgs[key] = value;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
14
|
+
// Pre-transform: Recursively apply JSONata to format tool arguments
|
|
15
|
+
const transformedArgs = await evaluateArgValue(node.args, exprContext, history, currentIndex);
|
|
27
16
|
logger.debug(`MCP tool args: ${JSON.stringify(transformedArgs, null, 2)}`);
|
|
28
17
|
logger.debug(`Expression context: ${JSON.stringify(exprContext, null, 2)}`);
|
|
29
18
|
// Clear previous stderr for this server at the start of execution
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-tool-executor.js","sourceRoot":"","sources":["../../../src/execution/nodes/mcp-tool-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"mcp-tool-executor.js","sourceRoot":"","sources":["../../../src/execution/nodes/mcp-tool-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAAa,EACb,OAAyB,EACzB,aAA+B,EAC/B,YAA0B,EAC1B,SAAiB;IAEjB,MAAM,CAAC,KAAK,CAAC,4BAA4B,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;IAElF,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IACtC,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,EAAE,CAA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AE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACpE,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE3B,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAE/D,OAAO;QACL,MAAM;QACN,QAAQ,EAAE,IAAI,CAAC,IAAI;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-testers.d.ts","sourceRoot":"","sources":["../../src/toolkit/expression-testers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"expression-testers.d.ts","sourceRoot":"","sources":["../../src/toolkit/expression-testers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAQ7C,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,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,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;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,iBAAiB,CAAC,CA4G5B"}
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { evaluateJsonata, validateJsonataSyntax } from '../expressions/jsonata.js';
|
|
7
7
|
import { evaluateJsonLogic } from '../expressions/json-logic.js';
|
|
8
|
-
import { logger } from '../logger.js';
|
|
9
8
|
import { McpClientManager } from '../mcp/client-manager.js';
|
|
10
9
|
import { ToolCallError } from '../errors/mcp-tool-error.js';
|
|
11
10
|
import { extractMcpToolOutput } from '../mcp/tool-output-extractor.js';
|
|
11
|
+
import { evaluateArgValue } from '../execution/arg-evaluator.js';
|
|
12
12
|
/**
|
|
13
13
|
* Test a JSONata expression with context
|
|
14
14
|
*/
|
|
@@ -62,25 +62,15 @@ export async function testMcpTool(api, serverName, toolName, args, context) {
|
|
|
62
62
|
}
|
|
63
63
|
const serverConfig = config.mcpServers[serverName];
|
|
64
64
|
// Evaluate JSONata expressions in args if context is provided
|
|
65
|
-
const evaluatedArgs = {};
|
|
66
65
|
const exprContext = context || {};
|
|
67
66
|
const history = [];
|
|
68
67
|
const currentIndex = 0;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
logger.debug(`JSONata "${value}" evaluated to: ${JSON.stringify(evaluated)}`);
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
throw new Error(`Failed to evaluate JSONata expression "${value}" in arg "${key}": ${error instanceof Error ? error.message : String(error)}`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
evaluatedArgs[key] = value;
|
|
83
|
-
}
|
|
68
|
+
let evaluatedArgs;
|
|
69
|
+
try {
|
|
70
|
+
evaluatedArgs = await evaluateArgValue(args, exprContext, history, currentIndex);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
throw new Error(`Failed to evaluate JSONata expressions in args: ${error instanceof Error ? error.message : String(error)}`);
|
|
84
74
|
}
|
|
85
75
|
// Get client manager from API (we need to access it, but it's private)
|
|
86
76
|
// Instead, we'll create a temporary client manager for this test
|
|
@@ -111,7 +101,24 @@ export async function testMcpTool(api, serverName, toolName, args, context) {
|
|
|
111
101
|
executionTime,
|
|
112
102
|
};
|
|
113
103
|
// Include evaluated args if any JSONata expressions were used
|
|
114
|
-
|
|
104
|
+
// Check if any args contain expression objects
|
|
105
|
+
function hasExpressionObjects(value) {
|
|
106
|
+
if (typeof value === "object" &&
|
|
107
|
+
value !== null &&
|
|
108
|
+
!Array.isArray(value) &&
|
|
109
|
+
"expr" in value &&
|
|
110
|
+
Object.keys(value).length === 1) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
if (Array.isArray(value)) {
|
|
114
|
+
return value.some(item => hasExpressionObjects(item));
|
|
115
|
+
}
|
|
116
|
+
if (typeof value === "object" && value !== null) {
|
|
117
|
+
return Object.values(value).some(val => hasExpressionObjects(val));
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
if (context && hasExpressionObjects(args)) {
|
|
115
122
|
response.evaluatedArgs = evaluatedArgs;
|
|
116
123
|
}
|
|
117
124
|
return response;
|
|
@@ -1 +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,2BAA2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C,MAAM,KAAK,CAAC,EAC/B,CAAC;oBACD,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;gBACxD,CAAC;gBACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;oBAChD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC;gBACrE,CAAC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;YAED,IAAI,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1C,QAAQ,CAAC,aAAa,GAAG,aAAa,CAAC;YACzC,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC/B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QAE7C,OAAO;YACL,MAAM,EAAE,IAAI;YACZ,aAAa;YACb,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"}
|
package/docs/building.md
CHANGED
|
@@ -163,6 +163,7 @@ Verify: No fetch or filesystem tool installed in agent
|
|
|
163
163
|
Install mcpGraphToolkit in agent
|
|
164
164
|
- place agent.yaml and mcp.json where installed mcpGraphToolkit can see them
|
|
165
165
|
- install
|
|
166
|
+
|
|
166
167
|
Prompt to create new tool
|
|
167
168
|
|
|
168
169
|
Prompt (two steps):
|
|
@@ -175,14 +176,6 @@ Prompt (one-shot, create and use tool):
|
|
|
175
176
|
|
|
176
177
|
Download the text contents of the web page https://world.hey.com/dhh/pay-yourself-first-e86f8147 to a local file, return the filename and size
|
|
177
178
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
First pass had a "graph/node" structure, no input node, malformed graph/output node, dependsOn elements - basically crazytown, second pass was correct
|
|
181
|
-
- Agent detected error and rebuilt it correctly, so that's good
|
|
182
|
-
|
|
183
|
-
Check relative path support in .mcp.json mcpgraphtoolkit config
|
|
184
|
-
|
|
185
|
-
Test Claude-generated graph in UX (debug, validate)
|
|
179
|
+
DevRel prompt:
|
|
186
180
|
|
|
187
|
-
|
|
188
|
-
- Might only make sense of relative paths worked
|
|
181
|
+
What did you struggle with in building that tool and how could the skill.md documentation or the mcpgraphtoolkit tooling be improved to help
|
|
@@ -93,6 +93,8 @@ But that's not what we're talking about. We're talking about a solution where we
|
|
|
93
93
|
|
|
94
94
|
**mcpGraph** is a Domain Specific Language (DSL) for MCP tool orchestration. It uses a declarative configuration—a YAML file—to define an MCP server and a set of tools, where those tools are implemented as directed graphs that can orchestrate other MCP tools (with data transformation and conditional logic support). It's Code Mode without the code.
|
|
95
95
|
|
|
96
|
+
> **🎥 Watch the Demo:** Check out the [**mcpGraph Overview and mcpGraphUX Demo**](https://youtu.be/eyC7OzuB6c4) video to see mcpGraph in action and explore the visual debugging capabilities of mcpGraphUX.
|
|
97
|
+
|
|
96
98
|
### **Core Features:**
|
|
97
99
|
|
|
98
100
|
* **Declarative Config:** Define tools and execution graphs in YAML.
|
|
@@ -248,6 +250,8 @@ Assuming your agent can build and install an MCP server into it's own environmen
|
|
|
248
250
|
|
|
249
251
|
We also wanted a viable end-to-end solution where any agent could create and deploy mcpGraph tools. This means that we not only need to instruct the agent on tool creation, but we need to provide the agent with tooling to understand available MCP servers and to test and deploy mcpGraph tools into its own environment. To that end, we created mcpGraphToolkit, an MCP server that provides a full set of development, test, and deployment tools to an agent. We have a separate [SKILL.md](../skills/mcpGraphToolkit/SKILL.md) file to support agents in using the mcpGraphToolkit.
|
|
250
252
|
|
|
253
|
+
> **🎥 Watch the Demo:** Check out the [**mcpGraphToolkit Deep Dive**](https://youtu.be/gR7s0MD8Gro) video to see an agent autonomously build, test, and deploy orchestration tools—"Code Mode" without the code.
|
|
254
|
+
|
|
251
255
|
The **mpcGraphToolkit** is installed as part of the mcpGraph package, so if you've installed mcpGraph from npm, you already have mcpGraphToolkit available.
|
|
252
256
|
|
|
253
257
|
To use mcpGraphToolkit in your agent:
|
|
@@ -283,9 +287,10 @@ When using **mcpGraphToolkit** you pass an path to your mcpGraph file, as before
|
|
|
283
287
|
- **`deleteGraphTool`**: Delete a tool from the mcpGraph
|
|
284
288
|
|
|
285
289
|
### Tool Execution Tools
|
|
286
|
-
- **`runGraphTool`**: Run an exported tool from the mcpGraph. Can specify existing tool name or run a tool definition supplied in payload. Supports detailed error reporting and optional logging collection.
|
|
290
|
+
- **`runGraphTool`**: Run an exported tool from the mcpGraph. Can specify existing tool name or run a tool definition supplied in payload. Supports detailed error reporting and optional logging collection. Used both to test and run graph tools.
|
|
287
291
|
|
|
288
292
|
### Expression Testing Tools
|
|
293
|
+
- **`testMcpTool`**: Test an MCP tool (especially to confirm output)
|
|
289
294
|
- **`testJSONata`**: Test a JSONata expression with context
|
|
290
295
|
- **`testJSONLogic`**: Test a JSON Logic expression with context
|
|
291
296
|
|
package/docs/toolkit.md
CHANGED
|
@@ -48,7 +48,9 @@ mcpGraphToolkit is an MCP server that provides tools for building, testing, and
|
|
|
48
48
|
|
|
49
49
|
## Tools
|
|
50
50
|
|
|
51
|
-
mcpGraphToolkit provides
|
|
51
|
+
mcpGraphToolkit provides 12 tools organized into the following categories:
|
|
52
|
+
|
|
53
|
+
> **📖 For Agents:** If you're an AI agent using mcpGraphToolkit to build graph tools, see [mcpGraphToolkit SKILL.md](../skills/mcpgraphtoolkit/SKILL.md) for comprehensive guidance on using these tools effectively.
|
|
52
54
|
|
|
53
55
|
### Graph Discovery Tools
|
|
54
56
|
|
|
@@ -156,6 +158,24 @@ Tests a JSON Logic expression with context.
|
|
|
156
158
|
- `result` (any) - evaluation result (boolean for conditions)
|
|
157
159
|
- `error` (object, optional) - error details if failed
|
|
158
160
|
|
|
161
|
+
#### `testMcpTool`
|
|
162
|
+
Tests an MCP tool call directly to understand its output structure and behavior.
|
|
163
|
+
- **Input**:
|
|
164
|
+
- `server` (string) - name of the MCP server
|
|
165
|
+
- `tool` (string) - name of the tool to call
|
|
166
|
+
- `args` (object) - tool arguments (objects with `{ "expr": "..." }` are evaluated as JSONata recursively; if context is provided, expressions in args are evaluated)
|
|
167
|
+
- `context` (object, optional) - context object for JSONata expression evaluation in args
|
|
168
|
+
- **Output**:
|
|
169
|
+
- `output` (any) - tool execution output (matches what would be available in a graph node's execution context)
|
|
170
|
+
- `evaluatedArgs` (object, optional) - evaluated arguments (present if JSONata expressions were used)
|
|
171
|
+
- `executionTime` (number) - execution time in milliseconds
|
|
172
|
+
- `error` (object, optional) - error details if call failed
|
|
173
|
+
- **Behavior**:
|
|
174
|
+
- Calls the MCP tool directly without creating a graph
|
|
175
|
+
- Evaluates JSONata expressions in args if context is provided (using recursive `{ "expr": "..." }` syntax)
|
|
176
|
+
- Returns the same output structure that would be available in a graph node's execution context
|
|
177
|
+
- Useful for understanding tool behavior and output structure before building graph tools
|
|
178
|
+
|
|
159
179
|
## File Structure
|
|
160
180
|
|
|
161
181
|
```
|
|
@@ -265,7 +285,7 @@ The toolkit includes comprehensive test coverage:
|
|
|
265
285
|
|
|
266
286
|
### MCP Client Integration Tests
|
|
267
287
|
- **File**: `tests/toolkit-mcp-server.test.ts`
|
|
268
|
-
- Tests all
|
|
288
|
+
- Tests all 12 toolkit tools via MCP protocol
|
|
269
289
|
- Uses MCP SDK Client to connect to toolkit server via stdio
|
|
270
290
|
- Tests error handling and edge cases
|
|
271
291
|
- Tests logging collection functionality
|
package/examples/file_utils.yaml
CHANGED
|
@@ -55,7 +55,8 @@ tools:
|
|
|
55
55
|
server: "filesystem"
|
|
56
56
|
tool: "list_directory"
|
|
57
57
|
args:
|
|
58
|
-
path:
|
|
58
|
+
path:
|
|
59
|
+
expr: "$.entry.directory"
|
|
59
60
|
next: "count_files_node"
|
|
60
61
|
|
|
61
62
|
# Transform and count files
|
|
@@ -97,7 +98,8 @@ tools:
|
|
|
97
98
|
server: "filesystem"
|
|
98
99
|
tool: "list_directory_with_sizes"
|
|
99
100
|
args:
|
|
100
|
-
path:
|
|
101
|
+
path:
|
|
102
|
+
expr: "$.entry.directory"
|
|
101
103
|
next: "sum_sizes_node"
|
|
102
104
|
|
|
103
105
|
# Transform and sum file sizes
|