diagram-generator生成和编辑各种类型的图表(drawio、mermaid、excalidraw)。支持流程图、时序图、类图、ER图、思维导图、架构图、网络拓扑图等常见图表类型。能够根据自然语言描述创建新图表,也能读取并修改已有的 drawio/mermaid/excalidraw 文件。使用独立的 MCP server (mcp-diagram-generator) 生成图表文件,减少 token 消耗并保证输出一致性。支持自动配置管理,默认输出路径为项目目录下的 diagrams/{format}/,支持自定义路径和自动创建目录。
Install via ClawdBot CLI:
clawdbot install Matthewyin/diagram-generatorGenerate and edit diagrams in multiple formats (drawio, mermaid, excalidraw) by creating structured JSON descriptions and delegating file generation to the mcp-diagram-generator MCP server.
Contact Information If you encounter any issues, please contact AlkaidY at tccio2023@gmail.com.
IMPORTANT: This skill requires the mcp-diagram-generator MCP server to be installed and configured.
Before using this skill, verify the MCP server is available by checking if you can access these tools:
mcpmcp-diagram-generatorget_configmcpmcp-diagram-generatorgenerate_diagrammcpmcp-diagram-generatorinit_configIf these tools are NOT available, you need to configure the MCP server first (see below).
Option 1: Using npx (Recommended - Auto-downloads the package)
Add the following to your Claude Code configuration file:
~/.claude.json) for all projects, or.claude.json) for specific project{
"mcpServers": {
"mcp-diagram-generator": {
"command": "npx",
"args": ["-y", "mcp-diagram-generator"]
}
}
}
After adding this configuration:
Option 2: Local Development (For developers)
If you're developing the MCP server locally:
{
"mcpServers": {
"mcp-diagram-generator": {
"command": "node",
"args": ["/absolute/path/to/mcp-diagram-generator/dist/index.js"]
}
}
}
After configuration, verify it works:
get_config() toolIssue: "Tool not found" error
Issue: Configuration looks correct but tools still not available
On first use, the MCP server will automatically:
.diagram-config.json)diagrams/{format}/You can customize paths at any time using the init_config tool.
Simple example - just provide diagram spec, let the server handle the rest:
User: "创建一个网络拓扑图"
Skill will:
generate_diagram with only diagram_spec parameterdiagrams/{format}/{title}-{date}.{ext}Extract from user's natural language:
Use format-selection-guide.md to decide:
| Format | Best For |
|--------|----------|
| drawio | Complex diagrams, network topology with nested containers, fine-grained styling, manual editing |
| mermaid | Quick generation, code-friendly, version control, documentation |
| excalidraw | Hand-drawn style, creative/diagrammatic flexibility, informal sketches |
Create a JSON description following the JSON Schema. Key structure:
{
"format": "drawio",
"title": "diagram name",
"elements": [
{
"id": "unique-id",
"type": "container|node|edge",
"name": "display name",
"level": "environment|datacenter|zone|device", // for network topology
"style": {...},
"geometry": {...},
"children": [...] // for nested containers
}
]
}
Important: Use unique IDs for all elements. For nested structures, maintain parent-child relationships.
Option A: Use defaults (recommended)
{
"diagram_spec": <the JSON object created above>
// output_path is optional - server will use configured default
// filename is optional - server will auto-generate based on title and date
}
The MCP server will:
diagrams/drawio/network-topology-2025-02-03.drawio)Option B: Specify custom path
{
"diagram_spec": <the JSON object>,
"output_path": "custom/path/to/diagram.drawio",
"filename": "my-custom-name" // optional, overrides auto-generated filename
}
Option C: Just provide filename, use default directory
{
"diagram_spec": <the JSON object>,
"filename": "my-diagram.drawio"
// Saves to diagrams/{format}/my-diagram.drawio
}
Initialize with defaults:
Call: init_config()
Result: Creates .diagram-config.json with default paths
Initialize with custom paths:
Call: init_config({
paths: {
drawio: "output/diagrams/drawio",
mermaid: "output/diagrams/mermaid",
excalidraw: "output/diagrams/excalidraw"
}
})
Call: get_config()
Returns: Current paths and initialization status
Call: set_output_path({
format: "drawio",
path: "custom/drawio-path"
})
Network topology diagrams require a 4-level hierarchical structure:
Environment (level="environment")
└── Datacenter (level="datacenter")
└── Zone (level="zone")
└── Device (type="node")
Style conventions:
fillColor: #e1d5e7, strokeColor: #9673a6 (purple)fillColor: #d5e8d4, strokeColor: #82b366 (green)fillColor: #fff2cc, strokeColor: #d6b656 (yellow)Device types and styles:
strokeColor: #607D8B (blue-gray)strokeColor: #4CAF50 (green)strokeColor: #F44336 (red)strokeColor: #607D8B (blue-gray)User: "画一个用户登录流程图,包含登录验证、重定向、错误处理"
Generate JSON:
{
"format": "mermaid",
"title": "用户登录流程",
"elements": [
{"type": "node", "id": "start", "name": "开始", "geometry": {"x": 0, "y": 0}},
{"type": "node", "id": "login", "name": "输入用户名密码", "geometry": {"x": 0, "y": 100}},
{"type": "node", "id": "validate", "name": "验证", "geometry": {"x": 0, "y": 200}},
{"type": "node", "id": "success", "name": "登录成功", "geometry": {"x": -100, "y": 300}},
{"type": "node", "id": "error", "name": "显示错误", "geometry": {"x": 100, "y": 300}},
{"type": "edge", "source": "start", "target": "login"},
{"type": "edge", "source": "login", "target": "validate"},
{"type": "edge", "source": "validate", "target": "success", "label": "成功"},
{"type": "edge", "source": "validate", "target": "error", "label": "失败"}
]
}
Call MCP:
generate_diagram({
diagram_spec: <above JSON>,
format: "mermaid"
// No output_path needed - auto-saves to diagrams/mermaid/
})
User: "创建一个网络拓扑图,包含省中心机房(上联区、汇聚区、终端区),连接到生产网"
Generate JSON with nested containers (see json-schema-guide.md for details).
Call MCP:
generate_diagram({
diagram_spec: <network topology JSON>,
filename: "省中心网络拓扑" // Optional, for custom filename
})
If mcp-diagram-generator is not available, you need to install it.
Option 1: Using npx (Recommended)
Add to your Claude Code/OpenCode settings:
{
"mcpServers": {
"diagram-generator": {
"command": "npx",
"args": ["-y", "mcp-diagram-generator"]
}
}
}
Option 2: Local Development
cd mcp-diagram-generator && npm installnpm run build{
"mcpServers": {
"diagram-generator": {
"command": "node",
"args": ["/absolute/path/to/mcp-diagram-generator/dist/index.js"]
}
}
}
If MCP server returns validation error:
Old behavior: Error if directory doesn't exist
New behavior: Directory is created automatically ✅
If you still see directory errors:
get_config()init_config()The server automatically uses the correct extension based on format:
.drawio.md.excalidrawYou don't need to specify extension in filename parameter.
level field matches hierarchy (environment/datacenter/zone)parent IDs are correct in child elementsLet the server manage output paths for consistency:
{
"diagram_spec": <spec>
// Don't specify output_path unless necessary
}
Titles are used for auto-generated filenames:
{
"title": "生产环境网络拓扑-亦庄与西五环",
// Generates: 生产环境网络拓扑-亦庄与西五环-2025-02-03.drawio
}
Instead of specifying output_path every time, configure once:
First time: init_config({ paths: { drawio: "custom/path" } })
After that: Just use generate_diagram() without output_path
get_config() // Shows all paths and status
Generated Feb 15, 2026
Developers can quickly generate UML class diagrams and sequence diagrams from code descriptions to document system architecture. This aids in onboarding new team members and maintaining clear design documentation within agile sprints.
IT teams can create detailed network topology diagrams to visualize server racks, zones, and device connections for capacity planning and troubleshooting. This helps in documenting existing infrastructure and planning upgrades or expansions.
Database administrators can generate Entity-Relationship (ER) diagrams from natural language descriptions to design and communicate database schemas. This streamlines the process of mapping out tables, relationships, and constraints before implementation.
Business analysts can create flowcharts and mind maps to visualize workflows, decision trees, and organizational structures. This supports process optimization, training, and compliance documentation across departments like finance or operations.
Educators and trainers can produce architecture diagrams and mind maps to illustrate complex concepts in courses or workshops. This enhances learning materials for topics like system design or project management in academic or corporate training settings.
Offer a free tier with basic diagram generation and limited exports, while charging for advanced features like custom templates, team collaboration, and high-resolution downloads. This model attracts individual users and converts them into paying enterprise customers.
Sell annual licenses to companies for unlimited diagram creation, integration with internal tools like Jira or Confluence, and dedicated support. This targets large organizations needing scalable solutions for documentation and planning across teams.
Provide API access to the diagram generation engine, allowing developers to embed diagram creation into their own applications or workflows. This monetizes the underlying technology through usage-based pricing or tiered API plans.
💬 Integration Tip
Ensure the MCP server is correctly configured in Claude Code's settings file and restart the application to avoid tool availability issues.
Display and control HTML content on connected Mac, iOS, or Android nodes via a web-based canvas with live reload and remote actions.
Create, export, and manage Canva designs via the Connect API. Generate social posts, carousels, and graphics programmatically.
Create software diagrams using Mermaid syntax. Use when users need to create, visualize, or document software through diagrams including class diagrams, sequence diagrams, flowcharts, ERDs, C4 architecture diagrams, state diagrams, git graphs, and other diagram types. Triggers include requests to diagram, visualize, model, map out, or show the flow of a system.
Generate diagrams from descriptions with Mermaid, PlantUML, or ASCII for architecture, flows, sequences, and data models.
Generate and render diagrams from Mermaid syntax into PNG, SVG, or PDF using customizable themes and various diagram types.
Generate beautiful, hand-drawn Mermaid diagrams with robust syntax (quoted labels, ELK layout). Use this skill when the user asks for "diagram", "flowchart", "sequence diagram", or "visualize this process".