| name | diagram |
| description | Renders interactive diagrams in the browser using Cytoscape.js. Use when the user asks to visualize, diagram, draw, render, or show a graph, flowchart, dependency tree, roadmap, architecture diagram, or any node-and-edge structure. Always renders live in browser — never as a static image. |
| allowed-tools | Write, Edit, mcp__chrome-devtools__new_page, mcp__chrome-devtools__navigate_page, mcp__chrome-devtools__wait_for, mcp__chrome-devtools__take_screenshot, mcp__chrome-devtools__evaluate_script, mcp__chrome-devtools__list_pages |
| category | tool |
| input_types | ["question"] |
| output_types | ["chart","plan"] |
| complexity | moderate |
| cost_profile | low |
| maturity | beta |
| metadata_source | inferred |
Diagram
Renders interactive, draggable diagrams in the browser using Cytoscape.js from context-supplied nodes and edges.
Workflow
- Extract nodes and edges — read labels, connections, and any grouping/color hints from the user's request or conversation context.
- Assign colors and positions — choose a color scheme and set x/y coordinates for a readable layout. See TEMPLATE.md for layout patterns.
- Write the HTML file — write a complete self-contained file to
/tmp/diagram.html using the Cytoscape.js template. See TEMPLATE.md for the full template.
- Render in browser — follow
_shared/chrome-devtools-render.md to open /tmp/diagram.html, wait for render, screenshot, and fix-and-reload if needed. wait_for a string from the legend or a node label. See TROUBLESHOOTING.md for diagram-specific fixes.
Self-review checklist
Before delivering, verify ALL:
Golden rules
Hard rules. Never violate these.
- Never use boolean edge attributes. Cytoscape selectors do not reliably match boolean data values. Always store edge style flags as strings:
dashed: 'yes' or dashed: 'no'. Use selector edge[dashed = "yes"].
- Never render to PNG. Always write
/tmp/diagram.html and open in browser. Static images cannot be dragged or zoomed by the user.
- Always call
cy.fit last. cy.fit(cy.elements(), 60) must be the final line in the script block. Without it, the diagram may render off-screen or at wrong zoom.
- Always use
new_page for first open. Use mcp__chrome-devtools__new_page with url: file:///tmp/diagram.html. Only use navigate_page with type: reload for subsequent reloads.
- Always wait before screenshotting. Call
wait_for on a text string that appears after Cytoscape renders (legend text or a node label). Never call take_screenshot immediately after new_page.
- Never set node dimensions to
label. Always use explicit pixel widths and heights (e.g. width: 200px, height: 80px). The label value causes unpredictable sizing.
- Always use
text-wrap: wrap with text-max-width. Without these, long labels overflow node boundaries invisibly.
Reference files
| File | Contents |
|---|
| TEMPLATE.md | Complete Cytoscape.js HTML template, color palette, layout patterns for common diagram types |
| TROUBLESHOOTING.md | Failure diagnosis table: symptoms, causes, fixes |