mcpgraph 0.1.2 → 0.1.4

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.
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Example: Using the mcpGraph API programmatically
3
+ *
4
+ * This example shows how to use the McpGraphApi class in your own applications,
5
+ * such as a UX server or other programmatic interface.
6
+ */
7
+
8
+ import { McpGraphApi } from '../src/api.js';
9
+
10
+ async function example() {
11
+ // Create an API instance (loads and validates config)
12
+ const api = new McpGraphApi('examples/count_files.yaml');
13
+
14
+ // Get server information
15
+ const serverInfo = api.getServerInfo();
16
+ console.log(`Server: ${serverInfo.name} v${serverInfo.version}`);
17
+
18
+ // List all available tools
19
+ const tools = api.listTools();
20
+ console.log(`Available tools: ${tools.map(t => t.name).join(', ')}`);
21
+
22
+ // Get information about a specific tool
23
+ const toolInfo = api.getTool('count_files');
24
+ if (toolInfo) {
25
+ console.log(`Tool: ${toolInfo.name}`);
26
+ console.log(`Description: ${toolInfo.description}`);
27
+ }
28
+
29
+ // Execute a tool
30
+ const result = await api.executeTool('count_files', {
31
+ directory: './tests/files',
32
+ });
33
+
34
+ console.log('Execution result:', result.result);
35
+ console.log('Structured content:', result.structuredContent);
36
+
37
+ // Clean up resources
38
+ await api.close();
39
+ }
40
+
41
+ // Example: Validate config without creating an API instance
42
+ function validateConfigExample() {
43
+ const errors = McpGraphApi.validateConfig('examples/count_files.yaml');
44
+ if (errors.length > 0) {
45
+ console.error('Validation errors:');
46
+ for (const error of errors) {
47
+ console.error(` - ${error.message}`);
48
+ }
49
+ } else {
50
+ console.log('Config is valid!');
51
+ }
52
+ }
53
+
54
+ // Example: Load and validate config
55
+ function loadAndValidateExample() {
56
+ const { config, errors } = McpGraphApi.loadAndValidateConfig('examples/count_files.yaml');
57
+ if (errors.length > 0) {
58
+ console.error('Validation errors:', errors);
59
+ } else {
60
+ console.log('Config loaded successfully');
61
+ console.log(`Tools: ${config.tools.map(t => t.name).join(', ')}`);
62
+ }
63
+ }
64
+
65
+ // Run examples
66
+ if (import.meta.url === `file://${process.argv[1]}`) {
67
+ example().catch(console.error);
68
+ }
69
+
@@ -2,9 +2,9 @@ version: "1.0"
2
2
 
3
3
  # MCP Server Metadata
4
4
  server:
5
- name: "mcpGraph"
5
+ name: "fileUtils"
6
6
  version: "1.0.0"
7
- description: "MCP server that executes directed graphs of MCP tool calls"
7
+ description: "File utilities"
8
8
 
9
9
  # Tool Definitions
10
10
  tools:
@@ -24,19 +24,36 @@ tools:
24
24
  count:
25
25
  type: "number"
26
26
  description: "The number of files in the directory"
27
- entryNode: "entry_count_files"
28
- exitNode: "exit_count_files"
27
+
28
+ # MCP Servers used by the graph
29
+ servers:
30
+ # Stdio server (type is optional, defaults to stdio)
31
+ filesystem:
32
+ command: "npx"
33
+ args:
34
+ - "-y"
35
+ - "@modelcontextprotocol/server-filesystem"
36
+ - "/Users/bob/Documents/GitHub/mcpGraph/tests/files"
37
+
38
+ # Example: Streamable HTTP server (preferred for HTTP/SSE)
39
+ # httpServer:
40
+ # type: "streamableHttp"
41
+ # url: "https://api.example.com/mcp"
42
+ # headers:
43
+ # Authorization: "Bearer token"
44
+ # X-Custom-Header: "value"
29
45
 
30
46
  # Graph Nodes
31
47
  nodes:
32
48
  # Entry node: Receives tool arguments
33
49
  - id: "entry_count_files"
34
50
  type: "entry"
51
+ tool: "count_files"
35
52
  next: "list_directory_node"
36
53
 
37
54
  # List directory contents
38
55
  - id: "list_directory_node"
39
- type: "mcp_tool"
56
+ type: "mcp"
40
57
  server: "filesystem"
41
58
  tool: "list_directory"
42
59
  args:
@@ -54,4 +71,5 @@ nodes:
54
71
  # Exit node: Returns the count
55
72
  - id: "exit_count_files"
56
73
  type: "exit"
74
+ tool: "count_files"
57
75
 
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "mcpgraph",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "MCP server that executes directed graphs of MCP server calls",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",
7
+ "exports": {
8
+ ".": "./dist/api.js",
9
+ "./api": "./dist/api.js"
10
+ },
7
11
  "bin": {
8
12
  "mcpgraph": "./dist/main.js"
9
13
  },