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.
- package/README.md +69 -48
- package/dist/api.d.ts +8 -4
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +13 -4
- package/dist/api.js.map +1 -1
- package/dist/config/expression-validator.d.ts.map +1 -1
- package/dist/config/expression-validator.js +12 -10
- package/dist/config/expression-validator.js.map +1 -1
- package/dist/config/loader.d.ts +8 -2
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +16 -2
- package/dist/config/loader.js.map +1 -1
- package/dist/config/mcp-loader.d.ts +13 -0
- package/dist/config/mcp-loader.d.ts.map +1 -0
- package/dist/config/mcp-loader.js +47 -0
- package/dist/config/mcp-loader.js.map +1 -0
- package/dist/config/schema.d.ts +292 -186
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +5 -6
- package/dist/config/schema.js.map +1 -1
- package/dist/errors/mcp-tool-error.d.ts +46 -0
- package/dist/errors/mcp-tool-error.d.ts.map +1 -0
- package/dist/errors/mcp-tool-error.js +63 -0
- package/dist/errors/mcp-tool-error.js.map +1 -0
- package/dist/execution/executor.d.ts +2 -2
- package/dist/execution/executor.d.ts.map +1 -1
- package/dist/execution/executor.js +11 -9
- package/dist/execution/executor.js.map +1 -1
- package/dist/execution/nodes/mcp-tool-executor.d.ts.map +1 -1
- package/dist/execution/nodes/mcp-tool-executor.js +49 -15
- package/dist/execution/nodes/mcp-tool-executor.js.map +1 -1
- package/dist/graph/validator.d.ts.map +1 -1
- package/dist/graph/validator.js +52 -69
- package/dist/graph/validator.js.map +1 -1
- package/dist/main.js +23 -5
- package/dist/main.js.map +1 -1
- package/dist/mcp/client-manager.d.ts +12 -0
- package/dist/mcp/client-manager.d.ts.map +1 -1
- package/dist/mcp/client-manager.js +38 -4
- package/dist/mcp/client-manager.js.map +1 -1
- package/dist/types/config.d.ts +4 -5
- package/dist/types/config.d.ts.map +1 -1
- package/docs/building.md +76 -0
- package/docs/design.md +55 -43
- package/docs/github-pages-setup.md +492 -0
- package/docs/introspection-debugging.md +1 -1
- package/examples/api-usage.ts +3 -3
- package/examples/count_files.yaml +47 -52
- package/examples/loop_example.yaml +55 -58
- package/examples/switch_example.yaml +48 -55
- package/examples/test_minimal.yaml +23 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-manager.d.ts","sourceRoot":"","sources":["../../src/mcp/client-manager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAQnE,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAsB;;
|
|
1
|
+
{"version":3,"file":"client-manager.d.ts","sourceRoot":"","sources":["../../src/mcp/client-manager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAQnE,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,aAAa,CAA4B;;IAO3C,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;IA8B1E,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IAInC;;;OAGG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;YAInB,eAAe;CAoG9B"}
|
|
@@ -8,15 +8,18 @@ import { StreamableHTTPClientTransport, } from "@modelcontextprotocol/sdk/client
|
|
|
8
8
|
import { logger } from "../logger.js";
|
|
9
9
|
export class McpClientManager {
|
|
10
10
|
clients;
|
|
11
|
+
stderrBuffers;
|
|
11
12
|
constructor() {
|
|
12
13
|
this.clients = new Map();
|
|
14
|
+
this.stderrBuffers = new WeakMap();
|
|
13
15
|
}
|
|
14
16
|
async getClient(serverName, serverConfig) {
|
|
15
17
|
if (this.clients.has(serverName)) {
|
|
16
18
|
return this.clients.get(serverName);
|
|
17
19
|
}
|
|
18
20
|
logger.info(`Creating MCP client for server: ${serverName} (type: ${getServerType(serverConfig)})`);
|
|
19
|
-
|
|
21
|
+
// Create transport and set up stderr capture
|
|
22
|
+
const { transport, stderrBuffer } = await this.createTransport(serverConfig);
|
|
20
23
|
const client = new Client({
|
|
21
24
|
name: `mcpgraph-${serverName}`,
|
|
22
25
|
version: "0.1.0",
|
|
@@ -24,6 +27,8 @@ export class McpClientManager {
|
|
|
24
27
|
capabilities: {},
|
|
25
28
|
});
|
|
26
29
|
await client.connect(transport);
|
|
30
|
+
// Associate stderr buffer with this client instance
|
|
31
|
+
this.stderrBuffers.set(client, stderrBuffer);
|
|
27
32
|
this.clients.set(serverName, client);
|
|
28
33
|
return client;
|
|
29
34
|
}
|
|
@@ -33,6 +38,22 @@ export class McpClientManager {
|
|
|
33
38
|
await client.close();
|
|
34
39
|
}
|
|
35
40
|
this.clients.clear();
|
|
41
|
+
// WeakMap doesn't need explicit clearing - it auto-cleans when clients are GC'd
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get captured stderr output for a client
|
|
45
|
+
* @param client - The MCP client instance
|
|
46
|
+
* @returns Array of stderr lines, or empty array if none
|
|
47
|
+
*/
|
|
48
|
+
getStderr(client) {
|
|
49
|
+
return this.stderrBuffers.get(client) || [];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Clear stderr buffer for a client (typically before a call to prepare for fresh output)
|
|
53
|
+
* @param client - The MCP client instance
|
|
54
|
+
*/
|
|
55
|
+
clearStderr(client) {
|
|
56
|
+
this.stderrBuffers.set(client, []);
|
|
36
57
|
}
|
|
37
58
|
async createTransport(serverConfig) {
|
|
38
59
|
// Default to stdio if type is not specified
|
|
@@ -43,11 +64,24 @@ export class McpClientManager {
|
|
|
43
64
|
command: stdioConfig.command,
|
|
44
65
|
args: stdioConfig.args,
|
|
45
66
|
env: process.env,
|
|
67
|
+
stderr: 'pipe',
|
|
46
68
|
};
|
|
47
69
|
if (stdioConfig.cwd) {
|
|
48
70
|
transportOptions.cwd = stdioConfig.cwd;
|
|
49
71
|
}
|
|
50
|
-
|
|
72
|
+
const transport = new StdioClientTransport(transportOptions);
|
|
73
|
+
// Create stderr buffer that will be associated with the client after creation
|
|
74
|
+
const stderrBuffer = [];
|
|
75
|
+
// Capture stderr output
|
|
76
|
+
if (transport.stderr) {
|
|
77
|
+
transport.stderr.on('data', (data) => {
|
|
78
|
+
const logEntry = data.toString().trim();
|
|
79
|
+
if (logEntry) {
|
|
80
|
+
stderrBuffer.push(logEntry);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return { transport, stderrBuffer };
|
|
51
85
|
}
|
|
52
86
|
else if (configType === "sse") {
|
|
53
87
|
const sseConfig = serverConfig;
|
|
@@ -72,7 +106,7 @@ export class McpClientManager {
|
|
|
72
106
|
if (sseConfig.eventSourceInit) {
|
|
73
107
|
options.eventSourceInit = sseConfig.eventSourceInit;
|
|
74
108
|
}
|
|
75
|
-
return new SSEClientTransport(new URL(sseConfig.url), options);
|
|
109
|
+
return { transport: new SSEClientTransport(new URL(sseConfig.url), options), stderrBuffer: [] };
|
|
76
110
|
}
|
|
77
111
|
else if (configType === "streamableHttp") {
|
|
78
112
|
const httpConfig = serverConfig;
|
|
@@ -94,7 +128,7 @@ export class McpClientManager {
|
|
|
94
128
|
headers: existingHeaders,
|
|
95
129
|
};
|
|
96
130
|
}
|
|
97
|
-
return new StreamableHTTPClientTransport(new URL(httpConfig.url), options);
|
|
131
|
+
return { transport: new StreamableHTTPClientTransport(new URL(httpConfig.url), options), stderrBuffer: [] };
|
|
98
132
|
}
|
|
99
133
|
else {
|
|
100
134
|
throw new Error(`Unsupported server transport type: ${configType}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-manager.js","sourceRoot":"","sources":["../../src/mcp/client-manager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAkC,MAAM,yCAAyC,CAAC;AAC7G,OAAO,EACL,6BAA6B,GAE9B,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAQtC,MAAM,OAAO,gBAAgB;IACnB,OAAO,CAAsB;
|
|
1
|
+
{"version":3,"file":"client-manager.js","sourceRoot":"","sources":["../../src/mcp/client-manager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAkC,MAAM,yCAAyC,CAAC;AAC7G,OAAO,EACL,6BAA6B,GAE9B,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAQtC,MAAM,OAAO,gBAAgB;IACnB,OAAO,CAAsB;IAC7B,aAAa,CAA4B;IAEjD;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,IAAI,OAAO,EAAE,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,UAAkB,EAAE,YAA0B;QAC5D,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC;QACvC,CA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gBAElB,yCAAyC;gBACzC,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;oBACvB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;wBAC9D,eAAe,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;oBAClC,CAAC;gBACH,CAAC;gBAED,OAAO,CAAC,WAAW,GAAG;oBACpB,GAAG,mBAAmB;oBACtB,OAAO,EAAE,eAAe;iBACV,CAAC;YACnB,CAAC;YAED,OAAO,EAAE,SAAS,EAAE,IAAI,6BAA6B,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;QAC9G,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,sCAAsC,UAAU,EAAE,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;CACF;AAED,SAAS,aAAa,CAAC,YAA0B;IAC/C,IAAI,CAAC,CAAC,MAAM,IAAI,YAAY,CAAC,IAAI,YAAY,CAAC,IAAI,KAAK,SAAS,IAAI,YAAY,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAClG,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,YAAY,CAAC,IAAI,CAAC;AAC3B,CAAC"}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -8,15 +8,15 @@ export interface ExecutionLimits {
|
|
|
8
8
|
export interface McpGraphConfig {
|
|
9
9
|
version: string;
|
|
10
10
|
server: ServerMetadata;
|
|
11
|
-
|
|
11
|
+
mcpServers?: Record<string, ServerConfig>;
|
|
12
12
|
executionLimits?: ExecutionLimits;
|
|
13
13
|
tools: ToolDefinition[];
|
|
14
|
-
nodes: NodeDefinition[];
|
|
15
14
|
}
|
|
16
15
|
export interface ServerMetadata {
|
|
17
16
|
name: string;
|
|
18
17
|
version: string;
|
|
19
|
-
|
|
18
|
+
title?: string;
|
|
19
|
+
instructions?: string;
|
|
20
20
|
}
|
|
21
21
|
export type ServerConfig = StdioServerConfig | SseServerConfig | StreamableHttpServerConfig;
|
|
22
22
|
export interface StdioServerConfig {
|
|
@@ -43,6 +43,7 @@ export interface ToolDefinition {
|
|
|
43
43
|
description: string;
|
|
44
44
|
inputSchema: JsonSchema;
|
|
45
45
|
outputSchema: JsonSchema;
|
|
46
|
+
nodes: NodeDefinition[];
|
|
46
47
|
}
|
|
47
48
|
export interface JsonSchema {
|
|
48
49
|
type: string;
|
|
@@ -62,12 +63,10 @@ export interface BaseNode {
|
|
|
62
63
|
}
|
|
63
64
|
export interface EntryNode extends BaseNode {
|
|
64
65
|
type: "entry";
|
|
65
|
-
tool: string;
|
|
66
66
|
next: string;
|
|
67
67
|
}
|
|
68
68
|
export interface ExitNode extends BaseNode {
|
|
69
69
|
type: "exit";
|
|
70
|
-
tool: string;
|
|
71
70
|
}
|
|
72
71
|
export interface McpNode extends BaseNode {
|
|
73
72
|
type: "mcp";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,eAAe;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,cAAc,CAAC;IACvB,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,eAAe;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAA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C9B,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC"}
|
package/docs/building.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
NOTE: This file is design notes only - do not implement anything here unless specifically asked
|
|
2
|
+
|
|
3
|
+
# Building mcpGraphs
|
|
4
|
+
|
|
5
|
+
To build an agent graph you need:
|
|
6
|
+
|
|
7
|
+
Basic knowledge of the mcpGraph file structure
|
|
8
|
+
- Assumes understanding of standard MCP data structures: MCP server metadata, tool description, mcpServers config
|
|
9
|
+
|
|
10
|
+
Understanding of graph structure, flow, nodes, and node types/details
|
|
11
|
+
- Including JSONata and JSON logic (both genrally, and as used in various nodes)
|
|
12
|
+
|
|
13
|
+
All relevant MCP servers and their configurations
|
|
14
|
+
- Including all tools provided with tool definitions
|
|
15
|
+
|
|
16
|
+
Testing tools
|
|
17
|
+
- In agent dev of our own examples, used primarily log output (which included error details)
|
|
18
|
+
- We have a full runtime harness with debugging, etc, that we could expose if needed
|
|
19
|
+
|
|
20
|
+
## SKILL.md
|
|
21
|
+
|
|
22
|
+
We can provide file / data structure defintion and context in a skill
|
|
23
|
+
|
|
24
|
+
If we provide tooling (add, run, etc), we can describe that in the skill as well (what it is and how to use it)
|
|
25
|
+
- It will also be in the tooling tool descriptions
|
|
26
|
+
|
|
27
|
+
## mcpGraphBuilder
|
|
28
|
+
|
|
29
|
+
Get all mcp servers and their configurations, and all tools they provide (search, progressive disclosure?)
|
|
30
|
+
- To support agents building graphs so they understand what tools they have and can access server config (which they usually couldn't)
|
|
31
|
+
|
|
32
|
+
Run a graph
|
|
33
|
+
- Would structured logging be enough to validate/debug (show each node, with context, output)
|
|
34
|
+
|
|
35
|
+
Do we want to use this to manage a set of graphs?
|
|
36
|
+
- Get tools (find tool)
|
|
37
|
+
- Run tool (debugging? log output, step, etc?)
|
|
38
|
+
- Add tool (fully implemented and tested tool, add by yaml file)
|
|
39
|
+
- Edit/remove tool?
|
|
40
|
+
|
|
41
|
+
For add/edit, this implies we can serialize them somehow
|
|
42
|
+
- Do we manage a directory of graph files with a shared mcp.json?
|
|
43
|
+
- Assumes we have write access to a directory
|
|
44
|
+
- Do we just use a single graph file with mcpServers defined inline and manage all of our tools/graphs in that file?
|
|
45
|
+
- Assumes we have write access to our graph file
|
|
46
|
+
|
|
47
|
+
If we're managing the tools as a set of graphs under this mcpGraph builder/manager, we're not really using the "server" part of the graph
|
|
48
|
+
- Are the name/title/instructions relevant, can we just ignore them and assume the tool description (and contents) will suffice?
|
|
49
|
+
- Would we want customizable metadata (esp instructions) for the builder/manager
|
|
50
|
+
- Maybe to distinguish them from each other, focus on set domain/tools available
|
|
51
|
+
|
|
52
|
+
## Issues
|
|
53
|
+
|
|
54
|
+
Do we want to expose the mcpServers config to the graphs themselves?
|
|
55
|
+
|
|
56
|
+
What if we had a master mcpServers (mcp.json) that had all mcpServer configs used by any graph (basically everything the agent has access to)
|
|
57
|
+
- Graph builder has access to all servers (without access to their config details)
|
|
58
|
+
- Graphs have access to the servers they need (without access to their config details)
|
|
59
|
+
- Pass path to mcp.json as arg
|
|
60
|
+
- For config details that are secret, this makes sense, but for others, maybe less so (like a directory path or other kind of scope)
|
|
61
|
+
|
|
62
|
+
What about MCP servers that require a secret or OAuth (where the agent can talk to the MCP server)
|
|
63
|
+
- How can we talk to that MCP server securely without doing an agent tool call (which would defeat our purpose)
|
|
64
|
+
- This is where being an agent gateway (especially a "smart" on that is managing tool disclosure/aggregation/etc) would be handy
|
|
65
|
+
|
|
66
|
+
mcpGraphBuilder
|
|
67
|
+
- m / --mcp is path to mcp.json with all tools
|
|
68
|
+
- d / --dir is directory where graphs live?
|
|
69
|
+
|
|
70
|
+
mcpGraph
|
|
71
|
+
- -g / --graph specifies the graph configuration file to use
|
|
72
|
+
- -m / --mcp if provided, parse mcpServers from referenced mcp.json file (jsonc support?), add to graph
|
|
73
|
+
- If mcpServers provided in graph, add them (overiding any passed-in MCP server with the same name)
|
|
74
|
+
|
|
75
|
+
Maybe it's one MCP server that requires either --dir ("builder" mode) or --graph ("runner" mode)
|
|
76
|
+
|
package/docs/design.md
CHANGED
|
@@ -55,12 +55,28 @@ To avoid embedding a full programming language while maintaining declarative, ob
|
|
|
55
55
|
|
|
56
56
|
**Resources:** [JSONata Documentation](https://jsonata.org/)
|
|
57
57
|
|
|
58
|
-
**YAML Example:**
|
|
58
|
+
**YAML Example (simple expression - single-quoted string):**
|
|
59
|
+
```yaml
|
|
60
|
+
transform:
|
|
61
|
+
expr: '{ "result": "high" }'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**YAML Example (complex expression - block scalar):**
|
|
59
65
|
```yaml
|
|
60
66
|
transform:
|
|
61
|
-
expr:
|
|
67
|
+
expr: |
|
|
68
|
+
$executionCount("increment_node") = 0
|
|
69
|
+
? { "counter": 1, "sum": 1, "target": $.entry_sum.n }
|
|
70
|
+
: { "counter": $nodeExecution("increment_node", -1).counter + 1, ... }
|
|
62
71
|
```
|
|
63
72
|
|
|
73
|
+
**Note on Expression Format:**
|
|
74
|
+
The `expr` field is a string containing a JSONata expression. In YAML, you can use either:
|
|
75
|
+
- **Single-quoted strings** (`'...'`) for simple, single-line expressions. This keeps the expression on one line and avoids the need for block scalars.
|
|
76
|
+
- **Block scalars** (`|`) for complex, multi-line expressions. This improves readability for expressions with conditional logic, nested objects, or multiple operations.
|
|
77
|
+
|
|
78
|
+
Both forms work identically - the expression is evaluated as a string by JSONata. Use single quotes for simple expressions and block scalars for complex ones to improve readability.
|
|
79
|
+
|
|
64
80
|
### Routing Decisions: JSON Logic
|
|
65
81
|
|
|
66
82
|
**Why JSON Logic:**
|
|
@@ -123,7 +139,7 @@ Graph definitions should feel like Kubernetes manifests or GitHub Actions - decl
|
|
|
123
139
|
|
|
124
140
|
The YAML configuration centers around MCP server and tool definitions:
|
|
125
141
|
|
|
126
|
-
1. **MCP Server Metadata**: Defines the MCP server information (name, version,
|
|
142
|
+
1. **MCP Server Metadata**: Defines the MCP server information (name required, version required, title optional defaults to name, instructions optional)
|
|
127
143
|
2. **Execution Limits** (optional): Guardrails to prevent infinite loops in cyclical graphs:
|
|
128
144
|
- **`maxNodeExecutions`** (optional): Maximum total node executions across the entire graph. Default: `1000`. If execution reaches this limit, an error is thrown.
|
|
129
145
|
- **`maxExecutionTimeMs`** (optional): Maximum wall-clock time for graph execution in milliseconds. Default: `300000` (5 minutes). If execution exceeds this time, an error is thrown.
|
|
@@ -156,13 +172,23 @@ version: "1.0"
|
|
|
156
172
|
server:
|
|
157
173
|
name: "fileUtils"
|
|
158
174
|
version: "1.0.0"
|
|
159
|
-
|
|
175
|
+
title: "File utilities"
|
|
176
|
+
instructions: "This server provides file utility tools for counting files in directories."
|
|
160
177
|
|
|
161
178
|
# Optional: Execution limits to prevent infinite loops
|
|
162
179
|
executionLimits:
|
|
163
180
|
maxNodeExecutions: 1000 # Maximum total node executions (default: 1000)
|
|
164
181
|
maxExecutionTimeMs: 300000 # Maximum execution time in milliseconds (default: 300000 = 5 minutes)
|
|
165
182
|
|
|
183
|
+
# MCP Servers used by the graph
|
|
184
|
+
mcpServers:
|
|
185
|
+
filesystem:
|
|
186
|
+
command: "npx"
|
|
187
|
+
args:
|
|
188
|
+
- "-y"
|
|
189
|
+
- "@modelcontextprotocol/server-filesystem"
|
|
190
|
+
- "./tests/counting"
|
|
191
|
+
|
|
166
192
|
# Tool Definitions
|
|
167
193
|
tools:
|
|
168
194
|
- name: "count_files"
|
|
@@ -181,45 +207,31 @@ tools:
|
|
|
181
207
|
count:
|
|
182
208
|
type: "number"
|
|
183
209
|
description: "The number of files in the directory"
|
|
184
|
-
|
|
185
|
-
#
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
- "
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
next: "count_files_node"
|
|
210
|
-
|
|
211
|
-
# Transform and count files
|
|
212
|
-
- id: "count_files_node"
|
|
213
|
-
type: "transform"
|
|
214
|
-
transform:
|
|
215
|
-
expr: |
|
|
216
|
-
{ "count": $count($split($.list_directory_node, "\n")) }
|
|
217
|
-
next: "exit_count_files"
|
|
218
|
-
|
|
219
|
-
# Exit node: Returns the count
|
|
220
|
-
- id: "exit_count_files"
|
|
221
|
-
type: "exit"
|
|
222
|
-
tool: "count_files"
|
|
210
|
+
nodes:
|
|
211
|
+
# Entry node: Receives tool arguments
|
|
212
|
+
- id: "entry"
|
|
213
|
+
type: "entry"
|
|
214
|
+
next: "list_directory_node"
|
|
215
|
+
|
|
216
|
+
# List directory contents
|
|
217
|
+
- id: "list_directory_node"
|
|
218
|
+
type: "mcp"
|
|
219
|
+
server: "filesystem"
|
|
220
|
+
tool: "list_directory"
|
|
221
|
+
args:
|
|
222
|
+
path: "$.entry.directory"
|
|
223
|
+
next: "count_files_node"
|
|
224
|
+
|
|
225
|
+
# Transform and count files
|
|
226
|
+
- id: "count_files_node"
|
|
227
|
+
type: "transform"
|
|
228
|
+
transform:
|
|
229
|
+
expr: '{ "count": $count($split($.list_directory_node.content, "\n")) }'
|
|
230
|
+
next: "exit"
|
|
231
|
+
|
|
232
|
+
# Exit node: Returns the count
|
|
233
|
+
- id: "exit"
|
|
234
|
+
type: "exit"
|
|
223
235
|
```
|
|
224
236
|
|
|
225
237
|
## Key Design Principles
|