@drawio/mcp 1.0.6 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,11 @@
1
- # Draw.io MCP Server
1
+ # Draw.io MCP Tool Server
2
2
 
3
- The official [draw.io](https://www.draw.io) MCP (Model Context Protocol) server that enables LLMs to create and open diagrams in the draw.io editor.
3
+ The official [draw.io](https://www.draw.io) MCP server that opens diagrams directly in the draw.io editor. Supports XML, CSV, and Mermaid.js formats with lightbox and dark mode options.
4
+
5
+ This package is part of the [drawio-mcp](https://github.com/jgraph/drawio-mcp) repository, which also includes:
6
+
7
+ - **[MCP App Server](https://github.com/jgraph/drawio-mcp/tree/main/mcp-app-server)** — Renders diagrams inline in AI chat interfaces. Hosted at `https://mcp.draw.io/mcp` — no install required.
8
+ - **[Project Instructions](https://github.com/jgraph/drawio-mcp/tree/main/project-instructions)** — Zero-install approach using Claude Project instructions.
4
9
 
5
10
  ## Features
6
11
 
@@ -29,7 +34,7 @@ drawio-mcp
29
34
 
30
35
  ```bash
31
36
  git clone https://github.com/jgraph/drawio-mcp.git
32
- cd drawio-mcp
37
+ cd drawio-mcp/mcp-tool-server
33
38
  npm install
34
39
  npm start
35
40
  ```
@@ -96,168 +101,12 @@ Opens the draw.io editor with a Mermaid.js diagram.
96
101
 
97
102
  ## Example Prompts
98
103
 
99
- Here are example prompts you can use with Claude to create diagrams.
100
-
101
- **Important:** Claude Desktop may have multiple ways to create diagrams (artifacts, browser control, MCP tools). To ensure Claude uses the draw.io MCP, explicitly mention the tool name in your prompt.
102
-
103
- You can also add a system instruction to your Claude Desktop project:
104
- > "Always use the draw.io MCP tools (open_drawio_mermaid, open_drawio_csv, open_drawio_xml) to create diagrams. Do not use browser control or artifacts."
105
-
106
- ### Explicit MCP Tool Calls
107
-
108
- These prompts explicitly request the draw.io MCP tools:
109
-
110
- **Mermaid:**
111
- - "Use `open_drawio_mermaid` to create a flowchart for a user login process"
112
- - "Use the draw.io MCP tool `open_drawio_mermaid` to make a sequence diagram showing OAuth2 flow"
113
- - "Create a state diagram with `open_drawio_mermaid` for an order lifecycle"
114
-
115
- **CSV:**
116
- - "Use `open_drawio_csv` to create an org chart for our team: CEO -> CTO, CFO; CTO -> 3 Engineers"
117
- - "Use the draw.io MCP tool `open_drawio_csv` to generate a network topology diagram"
118
- - "Create a microservices architecture with `open_drawio_csv`"
119
-
120
- **XML:**
104
+ - "Use `open_drawio_mermaid` to create a sequence diagram showing OAuth2 authentication flow"
105
+ - "Use `open_drawio_csv` to create an org chart: CEO → CTO, CFO; CTO → 3 Engineers"
121
106
  - "Use `open_drawio_xml` to create a detailed AWS architecture diagram with VPC, subnets, and security groups"
122
- - "Use the draw.io MCP tool `open_drawio_xml` to create a floor plan with 3 offices and a conference room"
123
- - "Create a network rack diagram with `open_drawio_xml` showing servers, switches, and cabling"
124
-
125
- ### Mermaid Diagrams
126
-
127
- **Flowcharts:**
128
- - "Create a flowchart showing a user login process with password validation and 2FA"
129
- - "Make a diagram of a CI/CD pipeline with build, test, and deploy stages"
130
- - "Draw a decision tree for troubleshooting network connectivity issues"
131
-
132
- **Sequence Diagrams:**
133
- - "Create a sequence diagram showing OAuth2 authentication flow"
134
- - "Make a sequence diagram of a REST API request/response cycle"
135
- - "Draw the interaction between a web browser, server, and database for a search query"
136
-
137
- **Class Diagrams:**
138
- - "Create a class diagram for a simple e-commerce system with Product, Order, and Customer classes"
139
- - "Make a UML class diagram showing inheritance for a vehicle hierarchy"
140
-
141
- **Other Mermaid Types:**
142
- - "Create an entity relationship diagram for a blog with users, posts, and comments"
143
- - "Make a state diagram for an order lifecycle (pending, confirmed, shipped, delivered)"
144
- - "Draw a Gantt chart for a 3-month software development project"
145
-
146
- ### CSV Diagrams
147
-
148
- **Org Charts (generated from description):**
149
- - "Create an org chart for a tech startup with a CEO, CTO with 3 engineers, and CFO with 2 accountants"
150
- - "Make an organizational diagram for a hospital with departments: Emergency, Surgery, Pediatrics, each with a head doctor and 2 staff"
151
- - "Generate an org chart showing: John (CEO) manages Sarah (VP Sales) and Mike (VP Engineering). Sarah manages 2 sales reps, Mike manages 3 developers"
152
-
153
- **Network/Architecture Diagrams (generated from description):**
154
- - "Create a network diagram showing: Load Balancer connects to 3 Web Servers, each Web Server connects to a shared Database and Cache"
155
- - "Make an AWS architecture diagram with: Users -> CloudFront -> ALB -> 2 EC2 instances -> RDS"
156
- - "Generate a microservices diagram with API Gateway connecting to Auth, Users, Orders, and Payments services"
157
-
158
- **Process/Workflow Diagrams (generated from description):**
159
- - "Create a diagram showing our hiring process: Application -> HR Review -> Technical Interview -> Culture Fit -> Offer -> Onboarding"
160
- - "Make a diagram of a pizza order flow from customer order through kitchen stations to delivery"
161
-
162
- **From Existing Data:**
163
- - "Create a diagram from this CSV data showing project dependencies"
164
- - "Turn this spreadsheet of employees and managers into an org chart"
165
-
166
- ### XML Diagrams
167
-
168
- **Complex Custom Diagrams:**
169
- - "Create a detailed AWS architecture diagram with VPC, subnets, EC2, and RDS"
170
- - "Make a custom floor plan layout with specific room dimensions"
171
- - "Draw a circuit diagram with specific component placements"
172
-
173
- **Importing Existing Diagrams:**
174
- - "Open this draw.io XML file and let me edit it"
175
- - "Load my existing diagram from this URL: https://example.com/diagram.xml"
176
-
177
- ## Format Examples
178
-
179
- ### Flowchart with Mermaid
180
-
181
- ```text
182
- graph TD
183
- A[Start] --> B{Decision}
184
- B -->|Yes| C[Action 1]
185
- B -->|No| D[Action 2]
186
- C --> E[End]
187
- D --> E
188
- ```
189
-
190
- ### Sequence Diagram with Mermaid
191
-
192
- ```text
193
- sequenceDiagram
194
- participant User
195
- participant Server
196
- participant Database
197
-
198
- User->>Server: Login Request
199
- Server->>Database: Validate Credentials
200
- Database-->>Server: User Data
201
- Server-->>User: JWT Token
202
- ```
203
-
204
- ### Org Chart with CSV
205
-
206
- ```csv
207
- ## Org Chart
208
- # label: %name%<br><i style="color:gray;">%title%</i>
209
- # style: rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;
210
- # connect: {"from":"manager","to":"name","invert":true,"style":"curved=1;endArrow=blockThin;endFill=1;"}
211
- # layout: auto
212
- # nodespacing: 40
213
- # levelspacing: 60
214
- name,title,manager
215
- Alice Johnson,CEO,
216
- Bob Smith,CTO,Alice Johnson
217
- Carol Williams,CFO,Alice Johnson
218
- Dave Brown,Lead Engineer,Bob Smith
219
- Eve Davis,Senior Engineer,Bob Smith
220
- Frank Miller,Accountant,Carol Williams
221
- ```
222
-
223
- ### Entity List with CSV
224
-
225
- ```csv
226
- ## Entity Diagram
227
- # label: %name%
228
- # style: shape=rectangle;rounded=1;whiteSpace=wrap;html=1;
229
- # connect: {"from":"connects_to","to":"name","style":"endArrow=classic;"}
230
- # layout: horizontalflow
231
- name,type,connects_to
232
- API Gateway,service,Auth Service
233
- Auth Service,service,User Database
234
- User Database,database,
235
- API Gateway,service,Product Service
236
- Product Service,service,Product Database
237
- Product Database,database,
238
- ```
239
107
 
240
- ### Native XML
241
-
242
- ```xml
243
- <mxGraphModel>
244
- <root>
245
- <mxCell id="0"/>
246
- <mxCell id="1" parent="0"/>
247
- <mxCell id="2" value="Hello World" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;"
248
- vertex="1" parent="1">
249
- <mxGeometry x="100" y="100" width="120" height="60" as="geometry"/>
250
- </mxCell>
251
- <mxCell id="3" value="Another Box" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;"
252
- vertex="1" parent="1">
253
- <mxGeometry x="280" y="100" width="120" height="60" as="geometry"/>
254
- </mxCell>
255
- <mxCell id="4" style="endArrow=classic;html=1;" edge="1" parent="1" source="2" target="3">
256
- <mxGeometry relative="1" as="geometry"/>
257
- </mxCell>
258
- </root>
259
- </mxGraphModel>
260
- ```
108
+ > **Tip:** Claude Desktop may have multiple ways to create diagrams. To ensure it uses the draw.io MCP, mention the tool name explicitly or add a system instruction:
109
+ > *"Always use the draw.io MCP tools to create diagrams."*
261
110
 
262
111
  ## How It Works
263
112
 
@@ -267,69 +116,9 @@ Product Database,database,
267
116
  4. The URL is returned to the LLM, which can present it to the user
268
117
  5. Opening the URL loads draw.io with the diagram ready to view/edit
269
118
 
270
- ## Alternative: Project Instructions (No MCP Required)
271
-
272
- An alternative approach is available that works **without installing the MCP server**. Instead of using MCP tools, you add instructions to a Claude Project that teach Claude to generate draw.io URLs using Python code execution.
273
-
274
- ### Advantages
275
-
276
- - **No installation required** - works immediately in Claude.ai
277
- - **No desktop app needed** - works entirely in the browser
278
- - **Easy to use** - just add instructions to your Claude Project
279
- - **Privacy-friendly** - the generated URL uses a hash fragment (`#create=...`), which stays in the browser and is never sent to any server
280
-
281
- ### How to Install
282
-
283
- 1. Open your Claude Project settings
284
- 2. Add the contents of [`src/claude-project-instructions.txt`](src/claude-project-instructions.txt) to your project instructions
285
- 3. Ask Claude to create diagrams - it will generate clickable draw.io URLs
286
-
287
- ### How It Works
288
-
289
- The instructions teach Claude to:
290
- 1. Generate diagram code (Mermaid, XML, or CSV)
291
- 2. Execute Python code to compress and encode the diagram
292
- 3. Output a clickable URL that opens draw.io with your diagram
293
-
294
- ### Token Usage Note
295
-
296
- The current instructions tell Claude to output the URL as a clickable link for user convenience. This has two considerations:
297
-
298
- 1. **Token count**: The URL can be long (especially for complex diagrams), which consumes output tokens
299
- 2. **Character accuracy**: The URL contains base64-encoded data where even a single character change breaks the diagram. The instructions emphasize character-perfect accuracy, but if you experience issues with broken links, you can use the alternative ending below.
300
-
301
- ### Alternative: Reference Script Output Only
302
-
303
- If you prefer not to have Claude re-type the URL (to save tokens or avoid potential character substitution issues), replace the last section of the instructions with:
304
-
305
- ```
306
- ## CRITICAL: URL Output Rules
307
-
308
- **NEVER re-type, repeat, or copy the generated URL in your response.**
309
-
310
- After the Python script executes, simply tell the user:
311
- > "Click the URL in the code output above to open your diagram."
312
-
313
- Why: The URL contains base64-encoded data that can be corrupted when reproduced. The ONLY safe URL is the one printed directly by Python in the execution output.
314
- ```
315
-
316
- This approach requires users to click the URL in the code execution output rather than in Claude's response, but guarantees the URL is always correct.
317
-
318
- ## Development
319
-
320
- ```bash
321
- # Install dependencies
322
- npm install
323
-
324
- # Run the server
325
- npm start
326
- ```
327
-
328
119
  ## Related Resources
329
120
 
330
121
  - [draw.io](https://www.draw.io) - Free online diagram editor
331
122
  - [draw.io Desktop](https://github.com/jgraph/drawio-desktop) - Desktop application
332
- - [@drawio/mcp on npm](https://www.npmjs.com/package/@drawio/mcp) - This package on npm
333
- - [drawio-mcp on GitHub](https://github.com/jgraph/drawio-mcp) - Source code repository
334
- - [Mermaid.js Documentation](https://mermaid.js.org/intro/)
123
+ - [drawio-mcp on GitHub](https://github.com/jgraph/drawio-mcp) - Full repository with all three approaches
335
124
  - [MCP Specification](https://modelcontextprotocol.io/)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawio/mcp",
3
- "version": "1.0.6",
3
+ "version": "1.1.1",
4
4
  "description": "Official draw.io MCP server for LLMs - Open diagrams in draw.io editor",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -1,104 +0,0 @@
1
- # Draw.io Diagram Generation
2
-
3
- When the user requests any visual diagram, use draw.io to create it.
4
-
5
- ## Supported Diagrams
6
-
7
- Draw.io supports virtually any diagram type:
8
- - **Standard**: Flowcharts, org charts, mind maps, timelines, Venn diagrams
9
- - **Software**: UML (class, sequence, activity, use case), ERD, architecture diagrams
10
- - **Cloud/Infrastructure**: AWS, Azure, GCP, Kubernetes, network topology
11
- - **Engineering**: Electrical circuits, digital logic, P&ID, floor plans
12
- - **Business**: BPMN, value streams, customer journeys, SWOT
13
- - **UI/UX**: Wireframes, mockups, sitemaps
14
- - **And more**: Infographics, data flows, decision trees, etc.
15
-
16
- ## Format Selection
17
-
18
- Choose the optimal format for the task:
19
-
20
- | Format | Best For |
21
- |--------|----------|
22
- | **Mermaid** | Flowcharts, sequences, ERD, Gantt, state diagrams, class diagrams |
23
- | **CSV** | Hierarchical data (org charts), bulk import from spreadsheets |
24
- | **XML** | Complex layouts, precise positioning, custom styling, icons, shapes |
25
-
26
- ## URL Generation
27
-
28
- Execute this Python code to generate the draw.io URL:
29
-
30
- ```python
31
- import json, zlib, base64
32
- from urllib.parse import quote
33
-
34
- # Set these variables:
35
- diagram_type = "mermaid" # "mermaid", "xml", or "csv"
36
- diagram_code = """graph TD
37
- A[Start] --> B[End]"""
38
-
39
- # Generate compressed URL (raw deflate with 4KB window for memory efficiency)
40
- encoded = quote(diagram_code, safe='')
41
- c = zlib.compressobj(9, zlib.DEFLATED, -15) # -15 = raw deflate with 32KB window
42
- raw_deflate = c.compress(encoded.encode('utf-8')) + c.flush()
43
- data = base64.b64encode(raw_deflate).decode()
44
-
45
- payload = json.dumps({"type": diagram_type, "compressed": True, "data": data})
46
- url = f"https://app.diagrams.net/?pv=0&grid=0#create={quote(payload, safe='')}"
47
- print(url)
48
- ```
49
-
50
- ## Format Examples
51
-
52
- ### Mermaid
53
- ```
54
- graph TD
55
- A[Start] --> B{Decision}
56
- B -->|Yes| C[Action]
57
- B -->|No| D[End]
58
- ```
59
-
60
- ### XML (draw.io native)
61
- ```xml
62
- <mxGraphModel>
63
- <root>
64
- <mxCell id="0"/>
65
- <mxCell id="1" parent="0"/>
66
- <mxCell id="2" value="Box" style="rounded=1;fillColor=#d5e8d4;" vertex="1" parent="1">
67
- <mxGeometry x="100" y="100" width="120" height="60" as="geometry"/>
68
- </mxCell>
69
- </root>
70
- </mxGraphModel>
71
- ```
72
-
73
- ### CSV (hierarchical data)
74
- ```
75
- # label: %name%
76
- # style: rounded=1;whiteSpace=wrap;html=1;
77
- # connect: {"from":"manager","to":"name","invert":true}
78
- # layout: auto
79
- name,manager
80
- CEO,
81
- CTO,CEO
82
- CFO,CEO
83
- ```
84
-
85
- ## Instructions
86
-
87
- 1. When a diagram is requested, determine the best format
88
- 2. Generate the diagram code
89
- 3. Execute the Python code to create the URL
90
- 4. Return the clickable URL to the user
91
-
92
- ## CRITICAL: URL Output Rules
93
-
94
- **ABSOLUTELY ZERO TOLERANCE: When outputting the URL, you MUST reproduce it with 100% character-perfect accuracy.**
95
-
96
- - The URL is a cryptographic hash - changing even ONE character destroys it completely
97
- - DO NOT "fix" or "correct" anything - if it looks wrong, it is still correct
98
- - DO NOT substitute any characters: no `i`↔`I`, no `k`↔`u`, no `0`↔`O`, no `l`↔`1`, NOTHING
99
- - Copy the URL byte-for-byte, character-for-character, exactly as printed by Python
100
- - If you are uncertain about any character, output it EXACTLY as shown - never guess
101
-
102
- **THE LINK WILL BE COMPLETELY BROKEN AND USELESS IF YOU CHANGE EVEN A SINGLE CHARACTER.**
103
-
104
- After executing the script, output the URL exactly as a clickable link for the user.