@drawio/mcp 1.0.3 → 1.0.5

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
@@ -10,27 +10,7 @@ The official [draw.io](https://www.draw.io) MCP (Model Context Protocol) server
10
10
  - **URL support**: Fetch content from URLs automatically
11
11
  - **Customizable display**: Lightbox mode, dark mode, and more
12
12
 
13
- ## Two Ways to Use
14
-
15
- ### Option 1: MCP Server (Claude Desktop)
16
-
17
- Install and configure the MCP server for Claude Desktop. The server runs locally and can automatically open diagrams in your browser.
18
-
19
- ### Option 2: Project Instructions (No MCP)
20
-
21
- Use draw.io diagram generation with custom project instructions - works in both Claude.ai and Claude Desktop without installing the MCP server. See [Using Project Instructions](#using-project-instructions-no-mcp) below.
22
-
23
- | Feature | MCP Server | Project Instructions |
24
- |---------|------------|----------------------|
25
- | Platform | Claude Desktop | Claude.ai & Claude Desktop |
26
- | Installation | Required | None |
27
- | System access | Opens browser automatically | No system access |
28
- | Link verification | Automatic | User can inspect link before clicking |
29
- | Complexity | More setup | Just paste instructions |
30
-
31
- ---
32
-
33
- ## MCP Server Installation
13
+ ## Installation
34
14
 
35
15
  ### Using npx (recommended)
36
16
 
@@ -287,57 +267,69 @@ Product Database,database,
287
267
  4. The URL is returned to the LLM, which can present it to the user
288
268
  5. Opening the URL loads draw.io with the diagram ready to view/edit
289
269
 
290
- ## Development
270
+ ## Alternative: Project Instructions (No MCP Required)
291
271
 
292
- ```bash
293
- # Install dependencies
294
- npm install
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.
295
273
 
296
- # Run the server
297
- npm start
298
- ```
274
+ ### Advantages
299
275
 
300
- ---
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
301
280
 
302
- ## Using Project Instructions (No MCP)
281
+ ### How to Install
303
282
 
304
- You can use draw.io diagram generation without installing the MCP server by using custom project instructions. This works in both Claude.ai (web) and Claude Desktop.
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
305
286
 
306
- **Advantages:**
287
+ ### How It Works
307
288
 
308
- - **No installation** - Just paste instructions into a project
309
- - **Works everywhere** - Claude.ai and Claude Desktop
310
- - **No system access** - Claude generates a link without accessing your computer
311
- - **Transparent** - You can inspect the generated URL before clicking
312
- - **Verifiable** - The link visibly points to `app.diagrams.net`
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
313
293
 
314
- ### Setup
294
+ ### Token Usage Note
315
295
 
316
- 1. Create a new Project in Claude.ai or Claude Desktop
317
- 2. In Project Settings, paste the contents of [`claude-project-instructions.txt`](./claude-project-instructions.txt) into the custom instructions
318
- 3. Start a conversation and ask Claude to create diagrams
296
+ The current instructions tell Claude to output the URL as a clickable link for user convenience. This has two considerations:
319
297
 
320
- ### How It Works
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
321
302
 
322
- Claude creates an **HTML artifact** that:
323
- 1. Generates Mermaid/CSV/XML diagram code based on your request
324
- 2. Compresses the diagram data using pako.js (loaded from CDN)
325
- 3. Shows a button to open draw.io with the diagram in lightbox mode
326
- 4. In draw.io, hover to see the "Edit" button to open the full editor
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
327
307
 
328
- **Note:** The artifact uses draw.io's lightbox mode (`lightbox=1&dark=auto&border=10&edit=_blank`).
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
+ ```
329
315
 
330
- ### Example
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.
331
317
 
332
- **You:** Create a flowchart for a user login process
318
+ ## Development
333
319
 
334
- **Claude:** *Creates an HTML artifact with an "Open in draw.io" button*
320
+ ```bash
321
+ # Install dependencies
322
+ npm install
335
323
 
336
- ---
324
+ # Run the server
325
+ npm start
326
+ ```
337
327
 
338
328
  ## Related Resources
339
329
 
340
330
  - [draw.io](https://www.draw.io) - Free online diagram editor
341
331
  - [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
342
334
  - [Mermaid.js Documentation](https://mermaid.js.org/intro/)
343
335
  - [MCP Specification](https://modelcontextprotocol.io/)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawio/mcp",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
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",
@@ -0,0 +1,104 @@
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/#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.