Skip to main content
Glama

generate_diagram

Generate architecture, flowchart, sequence, class, ER, and mindmap diagrams from D2 or DOT source code, rendered locally to vector SVG without external installations.

Instructions

Generate architecture / flowchart / sequence / class / ER / mindmap diagrams (架构图/流程图/时序图/类图/ER图/思维导图/示意图), rendered locally to vector SVG. The D2 and Graphviz engines are BUILT IN (WASM, bundled with this tool) — you do NOT need d2/dot/graphviz installed, do NOT run which d2/which dot, and do NOT shell out to them or write DOT files by hand; just call this tool and provide the D2 or DOT DSL. Prefer this for structured technical diagrams (architecture, flowchart, sequence, ER, class). LIMITS: D2 produces clean auto-laid-out diagrams with shapes/connections/basic style (fill/stroke/shadow/border-radius/gradients) — it does NOT support SVG filters (feGaussianBlur glow/blur), ambient lighting, vignette, pattern grids, or artistic depth effects. For highly stylized '酷炫/霓虹/科技感' graphics requiring glow/blur/depth beyond what D2 offers, hand-writing SVG is appropriate. mermaid is not supported in-process (needs a browser); use d2 or graphviz instead. Multilingual triggers: 図 · diagrama · diagramme · Diagramm · диаграмма · diagrama (ja/es/fr/de/ru/pt).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesD2 or DOT source code. D2 SYNTAX (full docs: https://d2lang.com): RULE 1: in { } blocks, each property on its OWN LINE (newline-separated). WRONG: `x: { fill: red; shape: oval }`. RIGHT: x: { shape: oval style.fill: red } RULE 2 (CRITICAL): `#` starts a COMMENT. Hex colors MUST be quoted: `style.fill: "#f0ff3a"` (WRONG: `style.fill: #f0ff3a`). Named colors don't need quotes: `style.fill: red`. Gradients: `style.fill: "linear-gradient(#hex, #hex)"` (quoted) or `style.fill: linear-gradient(red, blue)` (named). RULE 3 (CRITICAL): numeric properties accept INTEGERS ONLY (NOT floats). `style.stroke-width: 2` ✅, `style.stroke-width: 1.5` ❌ ERROR. SHAPES: rectangle(default), oval, circle, diamond, hexagon, cylinder, cloud, person, page, step, stored_data, package. LAYOUT: `direction: right` (or left/up/down) at top level only. CONNECTIONS: `a -> b: label`, `a <-> b`, chain `a -> b -> c`. STYLE (value types matter!): style.fill / style.stroke / style.font-color → color: named (red) or hex QUOTED ("#ff0000") or gradient QUOTED. style.stroke-width → INTEGER 0-15 (NOT float!) style.stroke-dash → INTEGER 0-10 style.font-size → INTEGER 8-100 style.border-radius → INTEGER 0-20 style.opacity → FLOAT 0-1 style.shadow / style.3d / style.double-border / style.bold / style.italic → true or false style.text-transform → uppercase / lowercase / title / none width / height → INTEGER (pixels) CONTAINERS: nested { }; cross-ref `parent.child`. ICONS: `icon: lucide:server` (Iconify set:name, auto-resolved by this tool). EXAMPLE (styled): direction: right db: { shape: cylinder style.fill: "#1a1a2e" style.stroke: "#f0ff3a" style.stroke-width: 2 style.shadow: true } api: { shape: hexagon style.fill: "#16213e" style.border-radius: 14 } api -> db: query MISTAKES: (1) space-separating properties on one line = ERROR. (2) Unquoted hex (# starts comment) = ERROR. (3) Float for integer property (1.5 for stroke-width) = ERROR. (4) Referencing by label not key. (5) `direction:` is top-level only. Graphviz DOT (semicolons OK): digraph G { rankdir=LR; A -> B; C }
nameNoOutput filename (without extension)
themeNoTheme (D2 theme name or ID; d2 only)
engineNoRender engine: d2 (D2 WASM, default) or graphviz (DOT). mermaid is listed for discoverability but unsupported in-process — use d2/graphviz.d2
formatNoOutput format (svg = vector high-res)svg
outDirNoOutput directory, default session-dir/output
diagramTypeNoDiagram type hint (flowchart/sequence/class/architecture...)
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It discloses that D2 and Graphviz are built-in (WASM), limits of D2 (no SVG filters), and that mermaid is unsupported. Also details common mistakes and style constraints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Description is long but well-structured, front-loading core purpose and key constraints. Each sentence is informative, though some could be consolidated; however, given complexity, thoroughness is justified.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given high complexity (multiple engines, DSL syntax, constraints) and no output schema, the description is remarkably complete. It covers all parameters, usage patterns, limitations, and error prevention.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, but description adds enormous value beyond schema: full D2 syntax, examples, common errors, and detailed parameter usage. This is exceptional.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description explicitly states the tool generates various diagram types (architecture, flowchart, sequence, etc.) and renders to SVG. It clearly distinguishes from siblings by focusing on structured technical diagrams using D2 or Graphviz DSL.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit when-to-use ('Prefer this for structured technical diagrams') and when-not-to-use ('For highly stylized graphics... hand-writing SVG is appropriate'). Also warns against shelling out for d2/dot and clarifies mermaid is unsupported in-process.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wangdong233/media-gen-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server