@drawio/mcp 1.1.0 → 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
107
 
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
-
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,52 +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. The script outputs a complete HTML page with the URL embedded as a clickable button
293
- 4. Claude presents the HTML as an artifact - the user clicks the button to open draw.io
294
-
295
- ### Why HTML Output?
296
-
297
- The generated URL contains compressed base64 data. LLMs are known to silently corrupt base64 strings when reproducing them token by token - even a single changed character breaks the link completely.
298
-
299
- By having the Python script output a complete HTML page with the link already embedded, the URL never passes through Claude's text generation. Claude simply presents the script output as an artifact, ensuring the link is always correct.
300
-
301
- ## Development
302
-
303
- ```bash
304
- # Install dependencies
305
- npm install
306
-
307
- # Run the server
308
- npm start
309
- ```
310
-
311
119
  ## Related Resources
312
120
 
313
121
  - [draw.io](https://www.draw.io) - Free online diagram editor
314
122
  - [draw.io Desktop](https://github.com/jgraph/drawio-desktop) - Desktop application
315
- - [@drawio/mcp on npm](https://www.npmjs.com/package/@drawio/mcp) - This package on npm
316
- - [drawio-mcp on GitHub](https://github.com/jgraph/drawio-mcp) - Source code repository
317
- - [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
318
124
  - [MCP Specification](https://modelcontextprotocol.io/)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawio/mcp",
3
- "version": "1.1.0",
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,160 +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 and output it as an HTML artifact:
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
40
- encoded = quote(diagram_code, safe='')
41
- c = zlib.compressobj(9, zlib.DEFLATED, -15)
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
-
48
- # Output as HTML page
49
- print(f"""<!DOCTYPE html>
50
- <html>
51
- <head>
52
- <meta charset="utf-8">
53
- <style>
54
- body {{
55
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
56
- display: flex;
57
- justify-content: center;
58
- align-items: center;
59
- min-height: 100vh;
60
- margin: 0;
61
- background: #f8f9fa;
62
- }}
63
- .card {{
64
- text-align: center;
65
- background: white;
66
- border-radius: 12px;
67
- padding: 40px;
68
- box-shadow: 0 2px 8px rgba(0,0,0,0.1);
69
- }}
70
- .card h2 {{
71
- margin: 0 0 8px;
72
- color: #1a1a1a;
73
- }}
74
- .card p {{
75
- margin: 0 0 24px;
76
- color: #666;
77
- }}
78
- .btn {{
79
- display: inline-block;
80
- padding: 14px 32px;
81
- background: #4285f4;
82
- color: white;
83
- text-decoration: none;
84
- border-radius: 8px;
85
- font-size: 16px;
86
- font-weight: 500;
87
- transition: background 0.2s;
88
- }}
89
- .btn:hover {{
90
- background: #3367d6;
91
- }}
92
- </style>
93
- </head>
94
- <body>
95
- <div class="card">
96
- <h2>Diagram Ready</h2>
97
- <p>Click below to open your diagram in draw.io</p>
98
- <a class="btn" href="{url}" target="_blank" rel="noopener noreferrer">
99
- Open in draw.io
100
- </a>
101
- </div>
102
- </body>
103
- </html>""")
104
- ```
105
-
106
- ## Format Examples
107
-
108
- ### Mermaid
109
- ```
110
- graph TD
111
- A[Start] --> B{Decision}
112
- B -->|Yes| C[Action]
113
- B -->|No| D[End]
114
- ```
115
-
116
- ### XML (draw.io native)
117
- ```xml
118
- <mxGraphModel>
119
- <root>
120
- <mxCell id="0"/>
121
- <mxCell id="1" parent="0"/>
122
- <mxCell id="2" value="Box" style="rounded=1;fillColor=#d5e8d4;" vertex="1" parent="1">
123
- <mxGeometry x="100" y="100" width="120" height="60" as="geometry"/>
124
- </mxCell>
125
- </root>
126
- </mxGraphModel>
127
- ```
128
-
129
- ### CSV (hierarchical data)
130
- ```
131
- # label: %name%
132
- # style: rounded=1;whiteSpace=wrap;html=1;
133
- # connect: {"from":"manager","to":"name","invert":true}
134
- # layout: auto
135
- name,manager
136
- CEO,
137
- CTO,CEO
138
- CFO,CEO
139
- ```
140
-
141
- ## Instructions
142
-
143
- 1. When a diagram is requested, determine the best format
144
- 2. Generate the diagram code
145
- 3. Execute the Python code to create the URL
146
- 4. **Create an HTML artifact** from the script output – this is the clickable link for the user
147
-
148
- ## CRITICAL: URL Output Rules
149
-
150
- **NEVER type, retype, or reproduce the generated URL in your chat response.**
151
-
152
- The URL contains compressed base64 data. Retyping it WILL corrupt it – even a single changed character breaks the link completely.
153
-
154
- Instead, follow this process:
155
- 1. Execute the Python script
156
- 2. The script outputs a complete HTML page with the correct link embedded
157
- 3. Present the HTML output as an artifact (the link inside is guaranteed correct because it was generated by the script, not by you)
158
- 4. In your chat message, simply tell the user to click the button in the artifact
159
-
160
- **DO NOT** copy the URL from the script output into your response text. The artifact IS the delivery mechanism for the link.