@drawio/mcp 1.1.8 → 1.2.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +35 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawio/mcp",
3
- "version": "1.1.8",
3
+ "version": "1.2.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",
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
- child = spawn("cmd", ["/c", "start", "", url], { shell: false, stdio: "ignore" });
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 use double hyphens (--) inside XML comments, as this is invalid XML and will break the parser. Use single hyphens or rephrase instead. " +
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. " +
@@ -269,6 +283,25 @@ server.setRequestHandler(CallToolRequestSchema, async (request) =>
269
283
  };
270
284
  }
271
285
 
286
+ if (typeof inputContent !== "string")
287
+ {
288
+ const actualType = typeof inputContent;
289
+ const preview = JSON.stringify(inputContent).substring(0, 200);
290
+
291
+ return {
292
+ content:
293
+ [
294
+ {
295
+ type: "text",
296
+ text: `Error: content parameter must be a string, but received ${actualType}: ${preview}\n\n` +
297
+ "Common mistake: passing a JSON object or nested structure instead of a plain string. " +
298
+ "Make sure the diagram content (XML, CSV, or Mermaid) is passed directly as a string value.",
299
+ },
300
+ ],
301
+ isError: true,
302
+ };
303
+ }
304
+
272
305
  content = inputContent;
273
306
 
274
307
  switch (name)