@drawio/mcp 1.0.4 → 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 +46 -2
- package/package.json +1 -1
- package/src/claude-project-instructions.txt +104 -0
package/README.md
CHANGED
|
@@ -267,9 +267,53 @@ Product Database,database,
|
|
|
267
267
|
4. The URL is returned to the LLM, which can present it to the user
|
|
268
268
|
5. Opening the URL loads draw.io with the diagram ready to view/edit
|
|
269
269
|
|
|
270
|
-
## Alternative: Project Instructions (
|
|
270
|
+
## Alternative: Project Instructions (No MCP Required)
|
|
271
271
|
|
|
272
|
-
|
|
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.
|
|
273
317
|
|
|
274
318
|
## Development
|
|
275
319
|
|
package/package.json
CHANGED
|
@@ -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.
|