create_network_diagram
Generate network and architecture diagrams by specifying custom nodes and connections, producing Draw.io compatible files for visualization.
Instructions
Create a network or architecture diagram with custom positioned nodes and connections.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes | Name for the output .drawio file (extension will be added automatically) | |
| nodes | Yes | Array of network nodes | |
| connections | Yes | Array of connections between nodes |
Implementation Reference
- drawio-generator.js:181-211 (handler)Core handler function that generates Draw.io XML for network diagrams by creating shapes for nodes and connectors for connections.createNetworkDiagram(nodes, connections) { const elements = []; const nodeIds = {}; // Create nodes nodes.forEach(node => { const type = node.type || 'rectangle'; const x = node.x || 100; const y = node.y || 100; const width = node.width || 120; const height = node.height || 60; const label = node.label || 'Node'; const shape = this.createShape(label, type, x, y, width, height); elements.push(shape); nodeIds[node.id] = shape.id; }); // Create connections connections.forEach(conn => { const sourceId = nodeIds[conn.from]; const targetId = nodeIds[conn.to]; if (sourceId && targetId) { const connector = this.createConnector(sourceId, targetId, conn.label || ''); elements.push(connector); } }); return this.generateDiagram(elements); }
- index.js:373-384 (handler)MCP tool handler that processes the tool call, generates the diagram using the generator, saves it to a file, and returns success message.handleCreateNetworkDiagram(args) { const xml = this.generator.createNetworkDiagram(args.nodes, args.connections); const filePath = this.saveToFile(args.filename, xml); return { content: [ { type: 'text', text: `Network diagram created successfully and saved to: ${filePath}\n\nYou can open this file directly in Draw.io.`, }, ], }; }
- index.js:153-215 (schema)Input schema defining parameters for the create_network_diagram tool: filename, nodes (with id, label, type, x, y), and connections (from, to, label).inputSchema: { type: 'object', properties: { filename: { type: 'string', description: 'Name for the output .drawio file (extension will be added automatically)', }, nodes: { type: 'array', description: 'Array of network nodes', items: { type: 'object', properties: { id: { type: 'string', description: 'Unique identifier for the node', }, label: { type: 'string', description: 'Display label for the node', }, type: { type: 'string', enum: ['rectangle', 'cylinder', 'database', 'cloud', 'hexagon', 'ellipse'], description: 'Shape type for the node', }, x: { type: 'number', description: 'X coordinate position', }, y: { type: 'number', description: 'Y coordinate position', }, }, required: ['id', 'label', 'x', 'y'], }, }, connections: { type: 'array', description: 'Array of connections between nodes', items: { type: 'object', properties: { from: { type: 'string', description: 'Source node ID', }, to: { type: 'string', description: 'Target node ID', }, label: { type: 'string', description: 'Connection label', }, }, required: ['from', 'to'], }, }, }, required: ['filename', 'nodes', 'connections'], },
- index.js:150-216 (registration)Tool registration in the MCP server's listTools handler, including name, description, and schema.{ name: 'create_network_diagram', description: 'Create a network or architecture diagram with custom positioned nodes and connections.', inputSchema: { type: 'object', properties: { filename: { type: 'string', description: 'Name for the output .drawio file (extension will be added automatically)', }, nodes: { type: 'array', description: 'Array of network nodes', items: { type: 'object', properties: { id: { type: 'string', description: 'Unique identifier for the node', }, label: { type: 'string', description: 'Display label for the node', }, type: { type: 'string', enum: ['rectangle', 'cylinder', 'database', 'cloud', 'hexagon', 'ellipse'], description: 'Shape type for the node', }, x: { type: 'number', description: 'X coordinate position', }, y: { type: 'number', description: 'Y coordinate position', }, }, required: ['id', 'label', 'x', 'y'], }, }, connections: { type: 'array', description: 'Array of connections between nodes', items: { type: 'object', properties: { from: { type: 'string', description: 'Source node ID', }, to: { type: 'string', description: 'Target node ID', }, label: { type: 'string', description: 'Connection label', }, }, required: ['from', 'to'], }, }, }, required: ['filename', 'nodes', 'connections'], }, },