mcpgraph 0.1.23 → 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/errors/mcp-tool-error.d.ts.map +1 -1
- package/dist/errors/mcp-tool-error.js +0 -4
- package/dist/errors/mcp-tool-error.js.map +1 -1
- 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 +5 -3
- package/examples/count_files.yaml +0 -70
|
@@ -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,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"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server Discovery for toolkit
|
|
3
|
+
*
|
|
4
|
+
* Provides functionality to discover and introspect MCP servers and their tools
|
|
5
|
+
*/
|
|
6
|
+
export interface McpServerInfo {
|
|
7
|
+
name: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
instructions?: string;
|
|
10
|
+
version?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface McpToolInfo {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
server: string;
|
|
16
|
+
}
|
|
17
|
+
export interface McpToolDetails {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
inputSchema: Record<string, unknown>;
|
|
21
|
+
outputSchema?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
export declare class McpDiscovery {
|
|
24
|
+
private mcpFilePath;
|
|
25
|
+
private clientManager;
|
|
26
|
+
private serverConfigs;
|
|
27
|
+
private clients;
|
|
28
|
+
constructor(mcpFilePath: string | null);
|
|
29
|
+
/**
|
|
30
|
+
* Load MCP servers from mcp.json file
|
|
31
|
+
*/
|
|
32
|
+
loadServers(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* List all available MCP servers
|
|
35
|
+
*/
|
|
36
|
+
listServers(): Promise<McpServerInfo[]>;
|
|
37
|
+
/**
|
|
38
|
+
* List tools from MCP servers
|
|
39
|
+
*/
|
|
40
|
+
listTools(serverName?: string): Promise<McpToolInfo[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Get full details of an MCP server tool
|
|
43
|
+
*/
|
|
44
|
+
getTool(serverName: string, toolName: string): Promise<McpToolDetails>;
|
|
45
|
+
/**
|
|
46
|
+
* Get or create MCP client for a server
|
|
47
|
+
*/
|
|
48
|
+
private getClient;
|
|
49
|
+
/**
|
|
50
|
+
* Clean up all clients
|
|
51
|
+
*/
|
|
52
|
+
close(): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=mcp-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-discovery.d.ts","sourceRoot":"","sources":["../../src/toolkit/mcp-discovery.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,aAAa,CAAmB;IACxC,OAAO,CAAC,aAAa,CAAoC;IACzD,OAAO,CAAC,OAAO,CAAkC;gBAErC,WAAW,EAAE,MAAM,GAAG,IAAI;IAKtC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAalC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IA4B7C;;OAEG;IACG,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IA+B5D;;OAEG;IACG,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAwB5E;;OAEG;YACW,SAAS;IAYvB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAW7B"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server Discovery for toolkit
|
|
3
|
+
*
|
|
4
|
+
* Provides functionality to discover and introspect MCP servers and their tools
|
|
5
|
+
*/
|
|
6
|
+
import { loadMcpServers } from '../config/mcp-loader.js';
|
|
7
|
+
import { McpClientManager } from '../mcp/client-manager.js';
|
|
8
|
+
import { logger } from '../logger.js';
|
|
9
|
+
export class McpDiscovery {
|
|
10
|
+
mcpFilePath;
|
|
11
|
+
clientManager;
|
|
12
|
+
serverConfigs = {};
|
|
13
|
+
clients = new Map();
|
|
14
|
+
constructor(mcpFilePath) {
|
|
15
|
+
this.mcpFilePath = mcpFilePath;
|
|
16
|
+
this.clientManager = new McpClientManager();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Load MCP servers from mcp.json file
|
|
20
|
+
*/
|
|
21
|
+
async loadServers() {
|
|
22
|
+
if (!this.mcpFilePath) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
this.serverConfigs = loadMcpServers(this.mcpFilePath) || {};
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
logger.error(`Failed to load MCP servers: ${error instanceof Error ? error.message : String(error)}`);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* List all available MCP servers
|
|
35
|
+
*/
|
|
36
|
+
async listServers() {
|
|
37
|
+
await this.loadServers();
|
|
38
|
+
const servers = [];
|
|
39
|
+
for (const [serverName, serverConfig] of Object.entries(this.serverConfigs)) {
|
|
40
|
+
try {
|
|
41
|
+
const client = await this.getClient(serverName, serverConfig);
|
|
42
|
+
const serverVersion = client.getServerVersion();
|
|
43
|
+
servers.push({
|
|
44
|
+
name: serverName,
|
|
45
|
+
title: serverVersion?.title,
|
|
46
|
+
instructions: client.getInstructions(),
|
|
47
|
+
version: serverVersion?.version,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
logger.warn(`Failed to get info for server "${serverName}": ${error instanceof Error ? error.message : String(error)}`);
|
|
52
|
+
// Still include server even if we can't get full info
|
|
53
|
+
servers.push({
|
|
54
|
+
name: serverName,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return servers;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* List tools from MCP servers
|
|
62
|
+
*/
|
|
63
|
+
async listTools(serverName) {
|
|
64
|
+
await this.loadServers();
|
|
65
|
+
const tools = [];
|
|
66
|
+
const serversToQuery = serverName
|
|
67
|
+
? (this.serverConfigs[serverName] ? [serverName] : [])
|
|
68
|
+
: Object.keys(this.serverConfigs);
|
|
69
|
+
for (const name of serversToQuery) {
|
|
70
|
+
const serverConfig = this.serverConfigs[name];
|
|
71
|
+
try {
|
|
72
|
+
const client = await this.getClient(name, serverConfig);
|
|
73
|
+
const toolsResult = await client.listTools();
|
|
74
|
+
if (toolsResult.tools) {
|
|
75
|
+
for (const tool of toolsResult.tools) {
|
|
76
|
+
tools.push({
|
|
77
|
+
name: tool.name,
|
|
78
|
+
description: tool.description || '',
|
|
79
|
+
server: name,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
logger.warn(`Failed to list tools for server "${name}": ${error instanceof Error ? error.message : String(error)}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return tools;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get full details of an MCP server tool
|
|
92
|
+
*/
|
|
93
|
+
async getTool(serverName, toolName) {
|
|
94
|
+
await this.loadServers();
|
|
95
|
+
const serverConfig = this.serverConfigs[serverName];
|
|
96
|
+
if (!serverConfig) {
|
|
97
|
+
throw new Error(`Server "${serverName}" not found`);
|
|
98
|
+
}
|
|
99
|
+
const client = await this.getClient(serverName, serverConfig);
|
|
100
|
+
const toolsResult = await client.listTools();
|
|
101
|
+
const tool = toolsResult.tools?.find(t => t.name === toolName);
|
|
102
|
+
if (!tool) {
|
|
103
|
+
throw new Error(`Tool "${toolName}" not found in server "${serverName}"`);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
name: tool.name,
|
|
107
|
+
description: tool.description || '',
|
|
108
|
+
inputSchema: tool.inputSchema,
|
|
109
|
+
outputSchema: tool.outputSchema,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get or create MCP client for a server
|
|
114
|
+
*/
|
|
115
|
+
async getClient(serverName, serverConfig) {
|
|
116
|
+
if (this.clients.has(serverName)) {
|
|
117
|
+
return this.clients.get(serverName);
|
|
118
|
+
}
|
|
119
|
+
// Use clientManager to get or create client
|
|
120
|
+
const client = await this.clientManager.getClient(serverName, serverConfig);
|
|
121
|
+
this.clients.set(serverName, client);
|
|
122
|
+
return client;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Clean up all clients
|
|
126
|
+
*/
|
|
127
|
+
async close() {
|
|
128
|
+
for (const client of this.clients.values()) {
|
|
129
|
+
try {
|
|
130
|
+
await client.close();
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
logger.warn(`Error closing client: ${error instanceof Error ? error.message : String(error)}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
this.clients.clear();
|
|
137
|
+
await this.clientManager.closeAll();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# source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QAAQ,EAAE,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolkit-main.d.ts","sourceRoot":"","sources":["../src/toolkit-main.ts"],"names":[],"mappings":";AACA;;GAEG"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* mcpGraphToolkit - MCP server for building, testing, and running mcpGraph tools
|
|
4
|
+
*/
|
|
5
|
+
import { logger } from './logger.js';
|
|
6
|
+
import { McpGraphApi } from './api.js';
|
|
7
|
+
import { ToolkitApi } from './toolkit/api.js';
|
|
8
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
9
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
10
|
+
import { ListToolsRequestSchema, CallToolRequestSchema, McpError } from '@modelcontextprotocol/sdk/types.js';
|
|
11
|
+
import { parseArgs } from 'node:util';
|
|
12
|
+
import { loadMcpServers } from './config/mcp-loader.js';
|
|
13
|
+
const { values } = parseArgs({
|
|
14
|
+
options: {
|
|
15
|
+
graph: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
short: 'g',
|
|
18
|
+
default: 'config.yaml',
|
|
19
|
+
},
|
|
20
|
+
mcp: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
short: 'm',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
let toolkitApi = null;
|
|
27
|
+
async function main() {
|
|
28
|
+
try {
|
|
29
|
+
const configPath = values.graph || 'config.yaml';
|
|
30
|
+
// Load mcpServers from MCP JSON file if provided
|
|
31
|
+
let mcpServersFromFile;
|
|
32
|
+
if (values.mcp) {
|
|
33
|
+
try {
|
|
34
|
+
mcpServersFromFile = loadMcpServers(values.mcp);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
logger.error(`Failed to load MCP file: ${error instanceof Error ? error.message : String(error)}`);
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Create API instance (loads and validates config, merging mcpServers)
|
|
42
|
+
const api = new McpGraphApi(configPath, mcpServersFromFile);
|
|
43
|
+
toolkitApi = new ToolkitApi(api, values.mcp || null);
|
|
44
|
+
// Initialize MCP server
|
|
45
|
+
const server = new Server({
|
|
46
|
+
name: 'mcpgraphtoolkit',
|
|
47
|
+
version: '1.0.0',
|
|
48
|
+
title: 'mcpGraph Toolkit',
|
|
49
|
+
}, {
|
|
50
|
+
capabilities: {
|
|
51
|
+
tools: {},
|
|
52
|
+
},
|
|
53
|
+
instructions: 'Tools for building, testing, and running mcpGraph tools',
|
|
54
|
+
});
|
|
55
|
+
// Register tools
|
|
56
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
57
|
+
const tools = toolkitApi.listTools().map(tool => {
|
|
58
|
+
const mapped = {
|
|
59
|
+
name: tool.name,
|
|
60
|
+
description: tool.description,
|
|
61
|
+
inputSchema: tool.inputSchema,
|
|
62
|
+
outputSchema: tool.outputSchema,
|
|
63
|
+
};
|
|
64
|
+
// Log if outputSchema is undefined or invalid
|
|
65
|
+
if (tool.outputSchema === undefined) {
|
|
66
|
+
logger.warn(`Tool ${tool.name} has undefined outputSchema`);
|
|
67
|
+
}
|
|
68
|
+
return mapped;
|
|
69
|
+
});
|
|
70
|
+
logger.debug(`Returning ${tools.length} tools from listTools`);
|
|
71
|
+
return { tools };
|
|
72
|
+
});
|
|
73
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
74
|
+
const toolName = request.params.name;
|
|
75
|
+
logger.info(`Toolkit tool called: ${toolName}`);
|
|
76
|
+
try {
|
|
77
|
+
const result = await toolkitApi.callTool(toolName, request.params.arguments || {});
|
|
78
|
+
return {
|
|
79
|
+
content: [
|
|
80
|
+
{
|
|
81
|
+
type: 'text',
|
|
82
|
+
text: JSON.stringify(result),
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
// Convert errors to MCP error responses
|
|
89
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
90
|
+
throw new McpError(-32603, errorMessage, error);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
const transport = new StdioServerTransport();
|
|
94
|
+
await server.connect(transport);
|
|
95
|
+
logger.info('mcpGraphToolkit MCP server running on stdio');
|
|
96
|
+
// Handle cleanup on process termination
|
|
97
|
+
process.on('SIGINT', async () => {
|
|
98
|
+
logger.info('Shutting down...');
|
|
99
|
+
if (toolkitApi) {
|
|
100
|
+
await toolkitApi.close();
|
|
101
|
+
}
|
|
102
|
+
process.exit(0);
|
|
103
|
+
});
|
|
104
|
+
process.on('SIGTERM', async () => {
|
|
105
|
+
logger.info('Shutting down...');
|
|
106
|
+
if (toolkitApi) {
|
|
107
|
+
await toolkitApi.close();
|
|
108
|
+
}
|
|
109
|
+
process.exit(0);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
logger.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
114
|
+
if (error instanceof Error && error.stack) {
|
|
115
|
+
logger.error(error.stack);
|
|
116
|
+
}
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
main().catch(async (error) => {
|
|
121
|
+
logger.error(`Fatal error: ${error instanceof Error ? error.message : String(error)}`);
|
|
122
|
+
if (error instanceof Error && error.stack) {
|
|
123
|
+
logger.error(error.stack);
|
|
124
|
+
}
|
|
125
|
+
process.exit(1);
|
|
126
|
+
});
|
|
127
|
+
//# sourceMappingURL=toolkit-main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolkit-main.js","sourceRoot":"","sources":["../src/toolkit-main.ts"],"names":[],"mappings":";AACA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WA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AC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjF,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAC1C,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IAC3B,MAAM,CAAC,KAAK,CAAC,gBAAgB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACvF,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC1C,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { NodeDefinition } from "./config.js";
|
|
5
5
|
import type { ExecutionContext as ExecutionContextClass } from "../execution/context.js";
|
|
6
6
|
import type { ExecutionContext as DataContext } from "../expressions/context.js";
|
|
7
|
+
import type { LogEntry } from "../logger.js";
|
|
7
8
|
export type ExecutionStatus = "not_started" | "running" | "paused" | "finished" | "error" | "stopped";
|
|
8
9
|
export interface NodeExecutionRecord {
|
|
9
10
|
executionIndex: number;
|
|
@@ -110,6 +111,11 @@ export interface ExecutionOptions {
|
|
|
110
111
|
* When true, execution will pause at the entry node, allowing step-through debugging from the start.
|
|
111
112
|
*/
|
|
112
113
|
startPaused?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Enable log collection during execution.
|
|
116
|
+
* When true, all log entries during execution will be collected and included in ExecutionResult.
|
|
117
|
+
*/
|
|
118
|
+
enableLogging?: boolean;
|
|
113
119
|
}
|
|
114
120
|
export interface ExecutionTelemetry {
|
|
115
121
|
totalDuration: number;
|
|
@@ -121,5 +127,6 @@ export interface ExecutionResult {
|
|
|
121
127
|
result: unknown;
|
|
122
128
|
executionHistory: NodeExecutionRecord[];
|
|
123
129
|
telemetry?: ExecutionTelemetry;
|
|
130
|
+
logs?: LogEntry[];
|
|
124
131
|
}
|
|
125
132
|
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/types/execution.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACzF,OAAO,KAAK,EAAE,gBAAgB,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/types/execution.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACzF,OAAO,KAAK,EAAE,gBAAgB,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,SAAS,GAAG,QA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
|
package/docs/building.md
CHANGED
|
@@ -4,73 +4,97 @@ NOTE: This file is design notes only - do not implement anything here unless spe
|
|
|
4
4
|
|
|
5
5
|
To build an agent graph you need:
|
|
6
6
|
|
|
7
|
+
What an mpcGraph is, what it does, when and why you should use one
|
|
8
|
+
|
|
7
9
|
Basic knowledge of the mcpGraph file structure
|
|
8
10
|
- Assumes understanding of standard MCP data structures: MCP server metadata, tool description, mcpServers config
|
|
9
11
|
|
|
10
12
|
Understanding of graph structure, flow, nodes, and node types/details
|
|
11
13
|
- Including JSONata and JSON logic (both genrally, and as used in various nodes)
|
|
12
14
|
|
|
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
15
|
## SKILL.md
|
|
21
16
|
|
|
22
17
|
We can provide file / data structure defintion and context in a skill
|
|
23
18
|
|
|
24
|
-
|
|
25
|
-
- It
|
|
19
|
+
Probably the main skill will have all of the overview and format stuff
|
|
20
|
+
- It can reference detailed documentation of JSONata and JSON Logic in separate files in the skill that we reference from the main skill
|
|
26
21
|
|
|
27
|
-
|
|
22
|
+
Later: If we provide tooling (mcpGraphBuilder), we can describe that in the skill as well (what it is and how to use it)
|
|
23
|
+
- This information will also be in the mcpGraphBuidler tooling server instructions and tool descriptions
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
- To support agents building graphs so they understand what tools they have and can access server config (which they usually couldn't)
|
|
25
|
+
## Tooling
|
|
31
26
|
|
|
32
|
-
Run
|
|
33
|
-
- Would structured logging be enough to validate/debug (show each node, with context, output)
|
|
27
|
+
Run, manage, and build mcpGraphs - Is this one program with multiple modes, or multiple programs?
|
|
34
28
|
|
|
35
|
-
|
|
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?
|
|
29
|
+
### mcpGraph
|
|
40
30
|
|
|
41
|
-
|
|
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
|
|
31
|
+
Graph runner - exposes mcpGraph server as MCP server where each tool runs a graph
|
|
46
32
|
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
- Maybe to distinguish them from each other, focus on set domain/tools available
|
|
33
|
+
- -g / --graph specifies the graph configuration file to use
|
|
34
|
+
- -m / --mcp if provided, parse mcpServers from referenced mcp.json file (jsonc support?), add to graph
|
|
35
|
+
- If mcpServers provided in graph, add them (overiding any passed-in MCP server with the same name)
|
|
51
36
|
|
|
52
|
-
|
|
37
|
+
### mcpGraphToolkit
|
|
53
38
|
|
|
54
|
-
|
|
39
|
+
mcpGraphToolkit is a set of tools for building, testing, and running mcpGraph tools specified in a single mcpGraph server (file)
|
|
55
40
|
|
|
56
|
-
|
|
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)
|
|
41
|
+
Will have it's own corresponding skill (separate from mcpGraph)
|
|
61
42
|
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
- This is where being an agent gateway (especially a "smart" on that is managing tool disclosure/aggregation/etc) would be handy
|
|
43
|
+
Same params as mcpGraph (-m/--mcp, -g/-graph)
|
|
44
|
+
- Future: If graph file doesn't exist, create it from template?
|
|
65
45
|
|
|
66
|
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
46
|
+
Setup:
|
|
47
|
+
- Create (or reference existing) mcp.json
|
|
48
|
+
- Create mcpgraph.yaml file (can use generic template, doesn't need any mcpServers or tools, just "server" block)
|
|
49
|
+
- Install mcpGraphToolkit as MCP server in agent pointing to mcp and graph files
|
|
69
50
|
|
|
70
|
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
|
|
51
|
+
Use case:
|
|
52
|
+
- Agent can discover existing tools and call them
|
|
53
|
+
- Agent can create new tools (with support for testing)
|
|
54
|
+
- Agent can manage tools in the mcpGraph (add/update/delete)
|
|
55
|
+
|
|
56
|
+
Tools:
|
|
57
|
+
- getGraphServer - return full details of mcpGraph server
|
|
58
|
+
- listMcpServers - return list of available mcpServer servers (name, title, instructions, version)
|
|
59
|
+
- listMcpServerTools - return list of tools (name/description only), optionally filtered by MCP server name
|
|
60
|
+
- getMcpServerTool - return full MCP server tool details (including input and output)
|
|
61
|
+
- listGraphTools - return a list of exported tools from the mcpGraph (name, description)
|
|
62
|
+
- getGraphTool - return full detail of an exported tool from the mcpGraph
|
|
63
|
+
- addGraphTool, updateGraphTool, deleteGraphTool - crud for exported mcpGraph tools
|
|
64
|
+
- runGraphTool - run an exported tool from the mcpGraph
|
|
65
|
+
- can specify existing tool name, or run a tool definition supplied in payload
|
|
66
|
+
- input includes tool input (arbitrary JSON)
|
|
67
|
+
- output inclides tool result payload (or error)
|
|
68
|
+
- can specify logging, in which case logging will also be returned with payload
|
|
69
|
+
- Future: optionally return detailed results (execution history, node-level)
|
|
70
|
+
- Future: runtime debugging - step through graph, etc?
|
|
71
|
+
- testJSONata - test a JSONata expression
|
|
72
|
+
- provide context object, JSONata string, returns result object or error)
|
|
73
|
+
- Future: validate-only mode?
|
|
74
|
+
- testJSONLogic - test a JSON Logic expression
|
|
75
|
+
- provide context object, JSON Logic object, return result or error)
|
|
76
|
+
- Future: validate-only mode?
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### mcpGraphManager
|
|
80
|
+
|
|
81
|
+
Manage a collection of graphs / graph tools
|
|
74
82
|
|
|
75
|
-
|
|
83
|
+
- m / --mcp is path to mcp.json with all tools
|
|
84
|
+
- d / --dir is directory where graphs live (assumes we have read or read/write access - write tools only available if write access?)
|
|
85
|
+
- Would we want a mode where we pass a single -g / --graph and only expose tools relevant a single graph server, and also whether we have write access to it?
|
|
86
|
+
|
|
87
|
+
Manage a set of graphs and their tools
|
|
88
|
+
- list graph servers, list tools, list tools by graph server
|
|
89
|
+
- find graph server/tool
|
|
90
|
+
- list by graph server/tool name/description, get graph server / tool for details?
|
|
91
|
+
- add/edit/delete graph server
|
|
92
|
+
- add/edit/delete graph server tool?
|
|
93
|
+
- run graph server tool (basic running, no debugging, just results as when running as MCP server)
|
|
94
|
+
- tool names will be graph server.name + "__" + tool.name (so we can dereference on run tool)
|
|
95
|
+
|
|
96
|
+
## Issues
|
|
76
97
|
|
|
98
|
+
What about MCP servers that require a secret or OAuth (where the agent can talk to the MCP server)
|
|
99
|
+
- How can we talk to that MCP server securely without doing an agent tool call (which would defeat our purpose)
|
|
100
|
+
- This is where being an agent gateway (especially a "smart" on that is managing tool disclosure/aggregation/etc) would be handy
|
package/docs/design.md
CHANGED
|
@@ -173,7 +173,7 @@ server:
|
|
|
173
173
|
name: "fileUtils"
|
|
174
174
|
version: "1.0.0"
|
|
175
175
|
title: "File utilities"
|
|
176
|
-
instructions: "This server provides file utility tools for counting files in directories."
|
|
176
|
+
instructions: "This server provides file utility tools for counting files and calculating total file sizes in directories."
|
|
177
177
|
|
|
178
178
|
# Optional: Execution limits to prevent infinite loops
|
|
179
179
|
executionLimits:
|