drawio-mcp
Produces .drawio files compatible with diagrams.net, enabling opening and editing of generated diagrams in the diagrams.net editor.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@drawio-mcpDraw a class diagram for a library management system with Book, Member, and Librarian classes."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Draw.io MCP — UML Diagram Generator
drawio-mcp là một MCP server (Model Context Protocol) cho phép bạn sinh UML diagrams chất lượng cao ngay trong quá trình chat với AI — không cần rời khỏi terminal, không cần công cụ vẽ tay.
🎯 Vấn đề & Giải pháp
Trước đây | Với drawio-mcp |
Bạn phải tự vẽ diagram bằng tay trong draw.io, LucidChart, hay PlantUML | Bạn mô tả bằng ngôn ngữ tự nhiên, AI sinh file |
Mất 10–30 phút để kéo thả align từng box | Mất vài giây — AI tự layout chuẩn UML |
Không tích hợp được vào AI tools | Là MCP server — kết nối trực tiếp với Claude, Cursor, Codex qua MCP protocol |
File không chuẩn, khó chỉnh sửa lại | File |
Kết quả: Bạn tập trung vào thiết kế, AI lo phần trình bày.
Related MCP server: Draw.io Diagram Server
✨ Tính năng nổi bật
🎯 Tự động layout — không cần chỉ định tọa độ, AI tự sắp xếp theo chuẩn UML
🔄 Backward edges / loops — activity diagram hỗ trợ đường vòng (error → retry) với waypoints thông minh
🎨 Đúng ký hiệu UML — bullseye end node, filled sync arrows, activation bars, lifelines
🏊 Swimlanes — activity diagram có swimlane với topological ordering
🔁 Self-loops — sequence diagram hỗ trợ self-message (U-shape)
📁 Output chuẩn .drawio — mở được bằng diagrams.net, chỉnh sửa được bằng giao diện kéo thả
📊 Hỗ trợ 4 loại sơ đồ
Diagram | Ký hiệu đặc biệt |
Class Diagram | Classes, attributes, methods, stereotypes (interface/abstract/enum), 6 loại relationships |
Use Case Diagram | Stick figure actors, white ellipse use cases, system boundary, include/extend/generalization, actor generalization |
Activity Diagram | Start/end (bullseye), action, decision, merge, fork/join, swimlanes, backward edges, labeled flows |
Sequence Diagram | Participants (actor/boundary/control/entity), lifelines, activation bars, self-loops, 5 message types |
🚀 Cài đặt
Yêu cầu
Node.js ≥ 18.0.0
npm
Clone & build
git clone <repo-url> drawio-mcp
cd drawio-mcp
npm install
npm run buildKết quả: thư mục dist/ chứa file dist/index.js — đây là entry point của MCP server.
⚙️ Cấu hình trên các nền tảng
Claude Code (CLI)
Thêm vào file ~/.claude/settings.json (global) hoặc .claude/settings.local.json (project):
{
"mcpServers": {
"drawio-uml": {
"command": "node",
"args": ["D:\\path\\to\\drawio-mcp\\dist\\index.js"]
}
}
}Lưu ý: Dùng path tuyệt đối đến thư mục dự án. Trên Windows dùng
\\, trên Mac/Linux dùng/.
Claude Desktop
Mở Settings → Developer → MCP Servers → Add → Điền:
Field | Value |
Name |
|
Command |
|
Arguments |
|
Hoặc sửa file cấu hình Claude Desktop tại:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonMac:
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"drawio-uml": {
"command": "node",
"args": ["D:\\path\\to\\drawio-mcp\\dist\\index.js"]
}
}
}Cursor
Thêm vào file .cursor/settings.json trong project:
{
"mcpServers": {
"drawio-uml": {
"command": "node",
"args": ["D:\\path\\to\\drawio-mcp\\dist\\index.js"]
}
}
}Codex / Windsurf / Cline / Continue / Các IDE khác
Thêm MCP server với cấu hình tương tự:
{
"mcpServers": {
"drawio-uml": {
"command": "node",
"args": ["/absolute/path/to/drawio-mcp/dist/index.js"]
}
}
}Sau khi cấu hình, restart IDE. Tools sẽ xuất hiện trong danh sách MCP tools.
🛠️ Các MCP Tools
Tool | Description |
| Create UML class diagram |
| Create use case diagram |
| Create activity diagram |
| Create sequence diagram |
| Read & parse existing .drawio file — xem cấu trúc cells, positions, labels, connections |
| Modify existing .drawio file — move, resize, relabel, add/remove cells, thêm edges |
Read + Update flow:
1. draw_activity_diagram(...) → sinh file
2. read_diagram_file({ file_path: "activity-diagram-xxx.drawio" }) → xem cell IDs
3. update_diagram_file({
file_path: "activity-diagram-xxx.drawio",
operations: [
{ type: "move_by", cellId: "4", dx: 50, dy: 0 },
{ type: "relabel", cellId: "4", value: "New Label" },
]
}) → sửa file, không cần tạo mớiSau khi gọi tool tạo/sửa, file .drawio được ghi vào thư mục ./output/.
💡 Prompt templates chuẩn
Dưới đây là các prompt đã tối ưu để sinh từng loại diagram. Copy-paste nguyên mẫu và thay đổi thông tin của bạn.
1. Class Diagram
Vẽ class diagram cho hệ thống quản lý thư viện:
- class Book: attributes = [id, title, author, isbn], methods = [borrow(), return()]
- class Member: attributes = [id, name, email], methods = [borrowBook(), returnBook()]
- class Librarian extends Member: attributes = [employeeId]
- class BorrowRecord: attributes = [id, borrowDate, dueDate]
- class Library: attributes = [name, address]
Relationships:
- Librarian → Member (inheritance)
- BorrowRecord → Member (association, "borrowed by")
- BorrowRecord → Book (association, "contains")
- Library → Book (aggregation, "has")Kết quả: File .drawio với đầy đủ class compartments, stereotypes, relationships đúng UML.
2. Use Case Diagram
Vẽ use case diagram cho hệ thống ATM:
System name: "ATM System"
Actors:
- Customer (mô tả: người dùng ATM)
- Bank Admin (mô tả: quản trị viên ngân hàng)
Use cases:
- "Withdraw Cash" (id: uc1)
- "Deposit Cash" (id: uc2)
- "Transfer Funds" (id: uc3)
- "Check Balance" (id: uc4)
- "Change PIN" (id: uc5)
- "Manage Users" (id: uc6)
Associations:
- Customer → uc1
- Customer → uc2
- Customer → uc3
- Customer → uc4
- Customer → uc5
- Bank Admin → uc6
Relationships:
- uc3 → uc2 (include) — Transfer cần Deposit để có tiền
- uc5 → uc4 (extend) — Change PIN có thể cần Check Balance
System boundary: "ATM System" bao gồm tất cả use casesKết quả: Stick figure actors bên trái, white ellipse use cases bên phải trong system boundary. Đúng ký hiệu UML chuẩn.
3. Activity Diagram
Vẽ activity diagram cho quy trình đặt hàng online:
Start node: s1
Action nodes:
- login (label: "Log in")
- browse (label: "Browse products")
- cart (label: "Add to cart")
- checkout (label: "Proceed to checkout")
- payment (label: "Process payment")
- confirm (label: "Send confirmation")
- cancel (label: "Cancel order")
- redirect (label: "Redirect to payment gateway")
- verify (label: "Verify payment")
End nodes: e1, e2
Decision nodes:
- d1 (label: "Continue shopping?")
- d2 (label: "Payment successful?")
Flows:
- s1 → login
- login → browse
- browse → cart
- cart → d1
- d1 → checkout (label: "Yes")
- d1 → browse (label: "No") # backward edge (loop)
- checkout → redirect
- redirect → payment
- payment → d2
- d2 → verify (label: "Yes")
- d2 → payment (label: "No") # backward edge (loop)
- verify → confirm
- confirm → e1
- checkout → cancel (label: "Cancel")
- cancel → e2
Swimlanes: (tùy chọn — bỏ nếu không cần)
- "Customer" gồm: [s1, login, browse, cart, d1, checkout, cancel]
- "System" gồm: [redirect, payment, d2, verify]
- "Email Service" gồm: [confirm]Kết quả: Layout theo topological levels, backward edges có waypoints, decision branches có nhãn Yes/No.
Mẹo: Bỏ phần swimlanes nếu muốn layout đơn giản, chỉ giữ lại nodes + flows.
4. Sequence Diagram
Vẽ sequence diagram cho quy trình rút tiền ATM:
Title: "ATM Transaction"
Participants:
- "User" (type: actor)
- "Cây ATM" (type: boundary)
- "Server Ngân Hàng" (type: entity)
Messages:
# ── Authentication ──
- User → Cây ATM: Nhập thẻ (asynchronous, order: 1)
- Cây ATM → User: Yêu cầu mã PIN (asynchronous, order: 2)
- User → Cây ATM: Nhập mã PIN (asynchronous, order: 3)
- Cây ATM → Server Ngân Hàng: Kiểm tra mã PIN (synchronous, order: 4)
- Server Ngân Hàng → Cây ATM: Xác nhận mã PIN (return, order: 5)
# ── Menu ──
- Cây ATM → User: Hiển thị danh sách lựa chọn (asynchronous, order: 6)
- User → Cây ATM: Nhập lựa chọn (asynchronous, order: 7)
# ── Alt: Kiểm tra số dư / Rút tiền / Huỷ ──
# (gán fragment cho mọi message trong block)
- Cây ATM → Server Ngân Hàng: Lấy số dư (synchronous, order: 8) # fragment: alt, condition: "Kiểm tra số dư / Rút tiền / Huỷ", fromOrder: 8, toOrder: 20
- Server Ngân Hàng → Cây ATM: Trả về số dư (return, order: 9)
- Cây ATM → User: Hiển thị số dư (asynchronous, order: 10)
- Cây ATM → User: Yêu cầu nhập số tiền (asynchronous, order: 11)
- User → Cây ATM: Nhập số tiền (asynchronous, order: 12)
- Cây ATM → Server Ngân Hàng: Kiểm tra số dư (synchronous, order: 13)
- Server Ngân Hàng → Cây ATM: Trả về số dư (return, order: 14)
# ── Nested Alt: Số dư > Số tiền / Số dư < Số tiền ──
- Cây ATM → Server Ngân Hàng: Cập nhật số dư (synchronous, order: 15) # fragment: alt, condition: "Đủ tiền / Không đủ", fromOrder: 15, toOrder: 19
- Server Ngân Hàng → Cây ATM: Số dư đã được cập nhật (return, order: 16)
- Cây ATM → User: Thông báo "Hãy nhận tiền" (asynchronous, order: 17)
- User → Cây ATM: Nhận tiền (asynchronous, order: 18)
- Cây ATM → User: Thông báo "Số dư không đủ" (asynchronous, order: 19)
# ── Huỷ ──
- Cây ATM → User: Thông báo "Huỷ giao dịch" (asynchronous, order: 20)
# ── Final ──
- Cây ATM → User: In hóa đơn (asynchronous, order: 21)
- Cây ATM → User: Trả thẻ (asynchronous, order: 22)
- User → Cây ATM: Nhận lại thẻ (asynchronous, order: 23)
- Cây ATM → User: Hiển thị cảm ơn (asynchronous, order: 24)Kết quả: Participants header ngang trên cùng, lifelines dọc, activation bars rỗng viền đen, self-loops vẽ U-shape bên phải.
Mẹo:
type: "actor"→ không có activation bar (đúng UML)type: "boundary"/"control"/"entity"→ có màu khác nhautype: "synchronous"→ mũi tên đặc, đường thẳng (sender chờ)type: "asynchronous"→ mũi tên mở (hói), đường thẳngtype: "return"→ dashed line, gray, open arrowFragment gán vào message đầu tiên của block với
fromOrder=order đầu,toOrder=order cuốiFragment lồng nhau — tạo fragment thứ 2 với
fromOrder/toOrderbên trong fragment ngoài
📂 Output
File sinh ra ở ./output/ với tên dạng <prefix>-<timestamp>.drawio.
Mở bằng:
app.diagrams.net → File → Open → chọn file
Hoặc VS Code extension "Draw.io Integration"
🧪 Development
npm run dev # Chạy MCP server với tsx (hot reload)
npm run test # Chạy unit tests
npm run build # Build TypeScript → dist/
npm run inspect # Test với MCP Inspector🏗️ Kiến trúc dự án
src/
├── index.ts # Entry point MCP server (stdio)
├── types/ # Zod schemas + TypeScript interfaces
│ ├── class-diagram.ts
│ ├── usecase-diagram.ts
│ ├── activity-diagram.ts
│ └── sequence-diagram.ts
├── builders/ # Sinh mxGraph XML cells
│ ├── base-builder.ts # Abstract class (ID, addVertex, addEdge, serialize)
│ ├── class-builder.ts
│ ├── usecase-builder.ts
│ ├── activity-builder.ts
│ └── sequence-builder.ts
├── tools/ # MCP tool definitions
│ ├── class-diagram.ts
│ ├── usecase-diagram.ts
│ ├── activity-diagram.ts
│ └── sequence-diagram.ts
└── utils/
├── diagram-writer.ts # Ghi file .drawio
├── compression.ts # Deflate + base64
├── layout.ts # Grid layout helpers
└── styles.ts # draw.io mxGraph styles📝 License
MIT
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/rifujin123/drawio-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server