@drawio/mcp 1.1.7 → 1.2.0
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/package.json +1 -1
- package/src/index.js +21 -2
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -5,6 +5,9 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
5
5
|
import { ListToolsRequestSchema, CallToolRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
6
6
|
import pako from "pako";
|
|
7
7
|
import { spawn } from "child_process";
|
|
8
|
+
import { writeFileSync, unlinkSync } from "fs";
|
|
9
|
+
import { join } from "path";
|
|
10
|
+
import { tmpdir } from "os";
|
|
8
11
|
|
|
9
12
|
const DRAWIO_BASE_URL = "https://app.diagrams.net/";
|
|
10
13
|
|
|
@@ -17,7 +20,18 @@ function openBrowser(url)
|
|
|
17
20
|
|
|
18
21
|
if (process.platform === "win32")
|
|
19
22
|
{
|
|
20
|
-
|
|
23
|
+
// cmd.exe's "start" command treats & as a command separator and
|
|
24
|
+
// drops everything after # in URLs, so the #create=... fragment
|
|
25
|
+
// (which carries the entire diagram payload) is silently lost.
|
|
26
|
+
// Writing a temporary .url file preserves the full URL intact.
|
|
27
|
+
const tmpFile = join(tmpdir(), "drawio-mcp-" + Date.now() + ".url");
|
|
28
|
+
writeFileSync(tmpFile, "[InternetShortcut]\r\nURL=" + url + "\r\n");
|
|
29
|
+
child = spawn("cmd", ["/c", "start", "", tmpFile], { shell: false, stdio: "ignore" });
|
|
30
|
+
|
|
31
|
+
setTimeout(function()
|
|
32
|
+
{
|
|
33
|
+
try { unlinkSync(tmpFile); } catch (e) { /* ignore */ }
|
|
34
|
+
}, 10000);
|
|
21
35
|
}
|
|
22
36
|
else if (process.platform === "darwin")
|
|
23
37
|
{
|
|
@@ -108,7 +122,7 @@ const tools =
|
|
|
108
122
|
"Opens the draw.io editor with a diagram from XML content. " +
|
|
109
123
|
"Use this to view, edit, or create diagrams in draw.io format. " +
|
|
110
124
|
"The XML should be valid draw.io/mxGraph XML format. " +
|
|
111
|
-
"IMPORTANT: Do NOT
|
|
125
|
+
"IMPORTANT: Do NOT include ANY XML comments (<!-- -->) in the output — they are strictly forbidden. " +
|
|
112
126
|
"EDGE GEOMETRY: Every edge mxCell MUST contain a <mxGeometry relative=\"1\" as=\"geometry\" /> child element, even when there are no waypoints. Self-closing edge cells (<mxCell ... edge=\"1\" ... />) are invalid and will not render correctly. " +
|
|
113
127
|
"EDGE ROUTING: Use edgeStyle=orthogonalEdgeStyle for right-angle connectors. " +
|
|
114
128
|
"Space nodes at least 60px apart to avoid overlapping edges. " +
|
|
@@ -120,7 +134,12 @@ const tools =
|
|
|
120
134
|
"(2) swimlane style (style=\"swimlane;startSize=30;\") for labeled containers with a title bar - use when the container needs visual borders/headers or when the container itself has connections; " +
|
|
121
135
|
"(3) any shape can be a container by adding container=1 to its style, but also add pointerEvents=0 unless the container itself needs to be connectable. " +
|
|
122
136
|
"Always use pointerEvents=0 on container styles that should not capture connections being rewired between children. " +
|
|
137
|
+
"EDGE LABELS: Do NOT wrap edge labels in HTML markup to reduce font size. The default font size for edge labels is already 11px (vs 12px for vertices), so they are already smaller. Just set the value attribute directly. " +
|
|
123
138
|
"LAYOUT: Align nodes to a grid (multiples of 10). Use consistent spacing (e.g., 200px horizontal, 120px vertical between nodes). " +
|
|
139
|
+
"DARK MODE COLORS: To enable dark mode color adaptation, the mxGraphModel element must include adaptiveColors=\"auto\". " +
|
|
140
|
+
"strokeColor, fillColor, and fontColor default to 'default', which renders as black in light theme and white in dark theme. " +
|
|
141
|
+
"Explicit colors (e.g. fillColor=#DAE8FC) specify the light-mode color; the dark-mode color is computed automatically by inverting RGB values and rotating the hue 180 degrees. " +
|
|
142
|
+
"To specify both colors explicitly, use light-dark(lightColor,darkColor) in the style string, e.g. fontColor=light-dark(#7EA6E0,#FF0000). " +
|
|
124
143
|
"See https://www.drawio.com/doc/faq/drawio-style-reference.html for the complete style reference.",
|
|
125
144
|
inputSchema:
|
|
126
145
|
{
|