Renders diagram source files to PNG/SVG using Kroki. No runtime dependencies — uses only Node.js built-ins. Two usage modes: - CLI — drop source files into src/, run make render, get images in diagrams/ - MCP server — AI tools (renderdiagram, renderfile) render on demand and return a one-click preview URL Output lands in diagrams/. Format is detected from the file extension. Unsupported extensions
Add this skill
npx mdskills install Dev-Dipesh/canopyWell-documented MCP server providing comprehensive diagram rendering across 25+ formats with local and remote Kroki support
1# Canopy23Renders diagram source files to PNG/SVG using [Kroki](https://kroki.io). No runtime dependencies — uses only Node.js built-ins.4567Two usage modes:89- **CLI** — drop source files into `src/`, run `make render`, get images in `diagrams/`10- **MCP server** — AI tools (`render_diagram`, `render_file`) render on demand and return a one-click preview URL1112---1314## Quick start1516```bash17make up # start local Kroki (Docker)18make render # render all files in src/ → diagrams/19```2021Output lands in `diagrams/`.2223---2425## CLI usage2627```bash28make render # render everything in src/29make render FILE=public/flow.puml # single file30make render DIR=src/public # subdirectory → diagrams/public/31make render DIR=src/public OUT=out/pub # custom output directory32```3334---3536## Supported formats3738Format is detected from the file extension. Unsupported extensions are skipped.3940| Extension(s) | Kroki type |41|---------------------------------|--------------|42| `.puml`, `.plantuml` | plantuml |43| `.c4puml` | c4plantuml |44| `.mmd`, `.mermaid` | mermaid |45| `.dot`, `.gv` | graphviz |46| `.d2` | d2 |47| `.dbml` | dbml |48| `.ditaa` | ditaa |49| `.erd` | erd |50| `.excalidraw` | excalidraw |51| `.blockdiag` | blockdiag |52| `.seqdiag` | seqdiag |53| `.actdiag` | actdiag |54| `.nwdiag` | nwdiag |55| `.packetdiag` | packetdiag |56| `.rackdiag` | rackdiag |57| `.bpmn` | bpmn |58| `.bytefield` | bytefield |59| `.nomnoml` | nomnoml |60| `.pikchr` | pikchr |61| `.dsl` | structurizr |62| `.bob` | svgbob |63| `.symbolator` | symbolator |64| `.tikz` | tikz |65| `.vega` | vega |66| `.vegalite` | vegalite |67| `.wavedrom` | wavedrom |68| `.wireviz` | wireviz |6970To add a format, edit the `KROKI_TYPE` map in `generate.cjs`. Full list: https://kroki.io/#support7172---7374## Markdown files7576Embed diagrams as fenced code blocks using the diagram type as the language name. Each block is rendered individually and saved to a sub-directory named after the `.md` file.7778### Title syntax7980Add a title after the language name on the opening fence line:8182````md83```plantuml "User Registration Flow"84@startuml85Alice -> Bob: hello86@enduml87```88````89→ `diagrams/architecture/User Registration Flow.png`9091````md92```plantuml user-flow93```94````95→ `diagrams/architecture/user-flow.png`9697Without a title, files are named by type and sequence number: `plantuml-01.png`, `mermaid-01.png`, etc.9899### Example100101````md102```plantuml "Sequence Overview"103@startuml104...105@enduml106```107108```mermaid data-flow109graph TD110 A --> B111```112````113114Render a markdown file:115116```bash117make render FILE=src/architecture.md118```119120Output for `src/architecture.md`:121122```123diagrams/124└── architecture/125 ├── Sequence Overview.png126 └── data-flow.png127```128129---130131## Project structure132133```134canopy/135├── generate.cjs # CLI renderer136├── mcp.cjs # MCP server + HTTP preview server137├── lib/renderer.cjs # shared rendering logic138├── Makefile139├── docker-compose.yml140├── src/141│ ├── public/ # committed — shared diagrams142│ └── private/ # gitignored — sensitive diagrams143└── diagrams/144 ├── public/ # committed145 └── private/ # gitignored146```147148Sub-directory structure is mirrored from `src/` to `diagrams/` automatically:149150```151src/public/flow.puml → diagrams/public/flow.png152src/public/arch.md → diagrams/public/arch/sequence.png153```154155---156157## Local Kroki server158159Run your own Kroki instance via Docker to avoid sending diagrams to the public server.160161```bash162make up # start all containers (detached)163make down # stop and remove containers164make restart # restart containers165make status # show container status166```167168The script checks `http://localhost:8000` automatically on every run:169170```171Kroki: checking http://localhost:8000 ... ok172```173174If unavailable, it asks before falling back to `https://kroki.io`.175176Containers started by `docker-compose.yml`:177178| Service | Image | Covers |179|--------------|-----------------------------|------------------------------------------------------------|180| `kroki` | yuzutech/kroki | Core (PlantUML, C4, GraphViz, D2, Mermaid, etc.) |181| `mermaid` | yuzutech/kroki-mermaid | Mermaid |182| `blockdiag` | yuzutech/kroki-blockdiag | BlockDiag, SeqDiag, ActDiag, NwDiag, PacketDiag, RackDiag |183| `bpmn` | yuzutech/kroki-bpmn | BPMN |184| `excalidraw` | yuzutech/kroki-excalidraw | Excalidraw |185| `wireviz` | yuzutech/kroki-wireviz | WireViz |186187---188189## MCP server190191The MCP server exposes diagram rendering as AI tools. It starts an HTTP file server on port 17432 (auto-increments if taken) alongside the MCP stdio transport.192193194195**Available tools:**196197| Tool | Description |198|------|-------------|199| `render_diagram` | Render diagram source text → returns a preview URL |200| `render_file` | Render a source file from disk → returns preview URL(s) |201| `list_supported_types` | List all supported Kroki types and extensions |202203The preview URL (e.g. `http://127.0.0.1:17432/a1b2c3`) opens directly in your browser.204205### Claude Code206207Add globally so it's available in every project:208209```bash210claude mcp add canopy -s user node /path/to/canopy/mcp.cjs211```212213Or let Claude Code auto-discover it when you open this repo — `.mcp.json` is already included.214215### Claude Desktop216217Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:218219```json220{221 "mcpServers": {222 "canopy": {223 "command": "node",224 "args": ["/path/to/canopy/mcp.cjs"]225 }226 }227}228```229230Restart Claude Desktop after editing. The MCP server starts automatically when the app launches.231232---233234## Notes235236- `diagrams/private/` and `src/private/` are gitignored — use them for sensitive diagrams.237- Non-diagram code blocks in `.md` files are silently skipped.238- Rendered images are saved to `~/.canopy/output/` and persist across reboots. The registry is persisted to `~/.canopy/registry.json` and reloaded on each server start, so preview URLs remain valid indefinitely as long as the image file exists on disk.239
Full transparency — inspect the skill content before installing.