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
| 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 |
Input Schema (JSON Schema)
{
"properties": {
"connections": {
"description": "Array of connections between nodes",
"items": {
"properties": {
"from": {
"description": "Source node ID",
"type": "string"
},
"label": {
"description": "Connection label",
"type": "string"
},
"to": {
"description": "Target node ID",
"type": "string"
}
},
"required": [
"from",
"to"
],
"type": "object"
},
"type": "array"
},
"filename": {
"description": "Name for the output .drawio file (extension will be added automatically)",
"type": "string"
},
"nodes": {
"description": "Array of network nodes",
"items": {
"properties": {
"id": {
"description": "Unique identifier for the node",
"type": "string"
},
"label": {
"description": "Display label for the node",
"type": "string"
},
"type": {
"description": "Shape type for the node",
"enum": [
"rectangle",
"cylinder",
"database",
"cloud",
"hexagon",
"ellipse"
],
"type": "string"
},
"x": {
"description": "X coordinate position",
"type": "number"
},
"y": {
"description": "Y coordinate position",
"type": "number"
}
},
"required": [
"id",
"label",
"x",
"y"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"filename",
"nodes",
"connections"
],
"type": "object"
}
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'], }, },