draw-io-mcp
Enables creating and editing Draw.io diagrams via natural language, supporting shapes, connectors, and multi-line text.
README
Draw.io MCP Server
A Model Context Protocol (MCP) server that enables Claude to create and manipulate Draw.io diagrams directly through conversation.
Features
- Create new Draw.io diagram files
- Add various shapes (rectangles, ellipses, rhombus, cylinders, hexagons, clouds, etc.)
- Add connectors/arrows between shapes
- Multi-line text support - Use
\nfor line breaks in shape labels (great for class diagrams) - Customize colors, positions, and sizes
- List and read existing diagrams
- Intelligent path resolution (supports relative, absolute, and ~ paths)
- Automatic path translation for cross-platform compatibility
Installation
- Clone this repository:
git clone <repository-url>
cd draw-io-mcp
- Install dependencies:
npm install
- Build the project:
npm run build
Configuration for Claude Desktop
To use this MCP server with Claude Desktop, add the following configuration to your Claude Desktop config file:
macOS
Edit: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows
Edit: %APPDATA%\Claude\claude_desktop_config.json
Add the following configuration:
{
"mcpServers": {
"draw-io": {
"command": "node",
"args": ["/absolute/path/to/draw-io-mcp/dist/index.js"]
}
}
}
Replace /absolute/path/to/draw-io-mcp with the actual path to this project directory.
After adding the configuration, restart Claude Desktop.
Configuration for Claude Code
To use this MCP server with Claude Code (the CLI), add it via the claude mcp add command or by editing the config file directly.
Option 1: CLI (recommended)
claude mcp add draw-io node /absolute/path/to/draw-io-mcp/dist/index.js
Replace /absolute/path/to/draw-io-mcp with the actual path to this project directory.
Option 2: Edit the config file directly
Claude Code stores MCP configuration in ~/.claude/mcp.json (global) or .claude/mcp.json inside a project (project-scoped). Add the following entry:
{
"mcpServers": {
"draw-io": {
"command": "node",
"args": ["/absolute/path/to/draw-io-mcp/dist/index.js"]
}
}
}
Verify the server is running
After adding the configuration, start or restart Claude Code and run:
claude mcp list
You should see draw-io listed as a connected server. You can also run:
claude mcp get draw-io
to inspect its status and the tools it exposes.
Scope options
Claude Code supports three configuration scopes:
| Scope | Flag | Config location | When to use |
|---|---|---|---|
| Local (project-only) | --scope local |
.claude/mcp.json in project |
Diagrams for a specific repo |
| User (global) | --scope user |
~/.claude/mcp.json |
Available in all your projects |
| Project (shared) | --scope project |
.mcp.json in project root |
Shared with teammates via git |
Example to add with a specific scope:
claude mcp add --scope user draw-io node /absolute/path/to/draw-io-mcp/dist/index.js
Usage Examples
Once configured, you can ask Claude to create diagrams:
Example 1: Simple Flowchart
Create a flowchart at ./flowchart.drawio with:
1. A "Start" rectangle at (100, 50)
2. A "Process Data" rectangle at (100, 150)
3. A "Decision" rhombus at (100, 250)
4. Connect them with arrows
Example 2: Architecture Diagram
Create a system architecture diagram at ./architecture.drawio showing:
- A cloud shape for "Cloud Services"
- A cylinder for "Database"
- Rectangles for different services
- Connect them appropriately
Example 3: Class Diagram with Multi-line Text
Create a class diagram for a Vehicle hierarchy with:
- A Vehicle class with attributes (brand, model) and methods (start, stop)
- A Car subclass with numDoors attribute
- A Motorcycle subclass with engineCC attribute
Use \n for line breaks to separate class name, attributes, and methods
The \n in shape text creates proper line breaks, so text like:
Vehicle\n---\n- brand: String\n+ start(): void
Renders as:
Vehicle
---
- brand: String
+ start(): void
Available Tools
The MCP server provides the following tools:
- create_diagram - Create a new Draw.io diagram file
- add_shape - Add shapes (rectangle, ellipse, rhombus, cylinder, hexagon, cloud, step, parallelogram, trapezoid, triangle). Supports multi-line text with
\n - add_connector - Add connectors between shapes with different styles (straight, curved, orthogonal)
- read_diagram - Read the raw XML content of a diagram
- list_shapes - List all shapes in a diagram with their properties
Path Handling
All diagrams are saved to your Desktop by default to make it easy to find them. The server intelligently handles file paths across different platforms:
Default Behavior
- Simple filenames:
diagram.drawio→ Saved to your Desktop - Relative paths:
./flowchart.drawio→ Saved to your Desktop (subdirectories ignored) - Claude-suggested paths:
/home/claude/test.drawio→ Saved to your Desktop
This makes it crystal clear where your files are - they're always on YOUR computer's Desktop, not on any remote machine.
Supported Path Formats
-
Desktop (default):
diagram.drawio- Saved to
~/Desktop/diagram.drawio
- Saved to
-
Absolute paths:
/Users/username/Documents/diagram.drawio- Used as-is (validated for safety)
- Lets you save to specific locations if needed
-
Home directory subdirectories:
~/Documents/diagram.drawio- Expands
~and saves to the specified location - Useful for organizing diagrams in specific folders
- Expands
Automatic Path Translation
When Claude Desktop suggests paths like /home/claude/diagram.drawio, the server automatically translates them to your Desktop:
/home/claude/diagram.drawio→~/Desktop/diagram.drawio/home/claude/subfolder/test.drawio→~/Desktop/test.drawio
This ensures you always know where your files are saved.
Safety Features
The server prevents file creation in system directories (/usr, /bin, /etc, etc.) to protect your system.
Development
Build
npm run build
Watch Mode
npm run watch
File Format
Draw.io files (.drawio) are XML-based files that can be opened with:
- Draw.io web app (https://app.diagrams.net)
- Draw.io desktop application
- VS Code with Draw.io extension
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。