@drawio/mcp 1.1.1 → 1.1.3

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 (3) hide show
  1. package/README.md +3 -4
  2. package/package.json +2 -2
  3. package/src/index.js +20 -62
package/README.md CHANGED
@@ -12,7 +12,6 @@ This package is part of the [drawio-mcp](https://github.com/jgraph/drawio-mcp) r
12
12
  - **Open XML diagrams**: Load native draw.io/mxGraph XML format
13
13
  - **Import CSV data**: Convert tabular data to diagrams (org charts, flowcharts, etc.)
14
14
  - **Render Mermaid.js**: Transform Mermaid syntax into editable draw.io diagrams
15
- - **URL support**: Fetch content from URLs automatically
16
15
  - **Customizable display**: Lightbox mode, dark mode, and more
17
16
 
18
17
  ## Installation
@@ -75,7 +74,7 @@ Opens the draw.io editor with XML content.
75
74
 
76
75
  | Parameter | Type | Required | Description |
77
76
  |-----------|------|----------|-------------|
78
- | `content` | string | Yes | Draw.io XML or URL to XML |
77
+ | `content` | string | Yes | Draw.io XML content |
79
78
  | `lightbox` | boolean | No | Read-only view mode (default: false) |
80
79
  | `dark` | string | No | "auto", "true", or "false" (default: "auto") |
81
80
 
@@ -85,7 +84,7 @@ Opens the draw.io editor with CSV data converted to a diagram.
85
84
 
86
85
  | Parameter | Type | Required | Description |
87
86
  |-----------|------|----------|-------------|
88
- | `content` | string | Yes | CSV content or URL to CSV |
87
+ | `content` | string | Yes | CSV content |
89
88
  | `lightbox` | boolean | No | Read-only view mode (default: false) |
90
89
  | `dark` | string | No | "auto", "true", or "false" (default: "auto") |
91
90
 
@@ -95,7 +94,7 @@ Opens the draw.io editor with a Mermaid.js diagram.
95
94
 
96
95
  | Parameter | Type | Required | Description |
97
96
  |-----------|------|----------|-------------|
98
- | `content` | string | Yes | Mermaid syntax or URL |
97
+ | `content` | string | Yes | Mermaid.js syntax |
99
98
  | `lightbox` | boolean | No | Read-only view mode (default: false) |
100
99
  | `dark` | string | No | "auto", "true", or "false" (default: "auto") |
101
100
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawio/mcp",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
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",
@@ -36,7 +36,7 @@
36
36
  "node": ">=18.0.0"
37
37
  },
38
38
  "dependencies": {
39
- "@modelcontextprotocol/sdk": "1.11.2",
39
+ "@modelcontextprotocol/sdk": "^1.27.1",
40
40
  "pako": "^2.1.0"
41
41
  },
42
42
  "files": [
package/src/index.js CHANGED
@@ -4,7 +4,7 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
4
4
  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
- import { exec } from "child_process";
7
+ import { spawn } from "child_process";
8
8
 
9
9
  const DRAWIO_BASE_URL = "https://app.diagrams.net/";
10
10
 
@@ -13,29 +13,27 @@ const DRAWIO_BASE_URL = "https://app.diagrams.net/";
13
13
  */
14
14
  function openBrowser(url)
15
15
  {
16
- const platform = process.platform;
17
- let command;
16
+ let child;
18
17
 
19
- if (platform === "win32")
18
+ if (process.platform === "win32")
20
19
  {
21
- command = `start "" "${url}"`;
20
+ child = spawn("cmd", ["/c", "start", "", url], { shell: false, stdio: "ignore" });
22
21
  }
23
- else if (platform === "darwin")
22
+ else if (process.platform === "darwin")
24
23
  {
25
- command = `open "${url}"`;
24
+ child = spawn("open", [url], { shell: false, stdio: "ignore" });
26
25
  }
27
26
  else
28
27
  {
29
- command = `xdg-open "${url}"`;
28
+ child = spawn("xdg-open", [url], { shell: false, stdio: "ignore" });
30
29
  }
31
30
 
32
- exec(command, (error) =>
31
+ child.on("error", function(error)
33
32
  {
34
- if (error)
35
- {
36
- console.error(`Failed to open browser: ${error.message}`);
37
- }
33
+ console.error(`Failed to open browser: ${error.message}`);
38
34
  });
35
+
36
+ child.unref();
39
37
  }
40
38
 
41
39
  /**
@@ -101,44 +99,16 @@ function generateDrawioUrl(data, type, options = {})
101
99
  return DRAWIO_BASE_URL + (paramsStr ? "?" + paramsStr : "") + createHash;
102
100
  }
103
101
 
104
- /**
105
- * Fetches content from a URL
106
- */
107
- async function fetchContent(url)
108
- {
109
- const response = await fetch(url);
110
- if (!response.ok)
111
- {
112
- throw new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);
113
- }
114
- return response.text();
115
- }
116
-
117
- /**
118
- * Determines if the input is a URL
119
- */
120
- function isUrl(input)
121
- {
122
- try
123
- {
124
- new URL(input);
125
- return true;
126
- }
127
- catch
128
- {
129
- return false;
130
- }
131
- }
132
-
133
102
  // Define the tools
134
103
  const tools =
135
104
  [
136
105
  {
137
106
  name: "open_drawio_xml",
138
107
  description:
139
- "Opens the draw.io editor with a diagram from XML content or a URL to XML content. " +
108
+ "Opens the draw.io editor with a diagram from XML content. " +
140
109
  "Use this to view, edit, or create diagrams in draw.io format. " +
141
- "The XML should be valid draw.io/mxGraph XML format.",
110
+ "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.",
142
112
  inputSchema:
143
113
  {
144
114
  type: "object",
@@ -148,8 +118,7 @@ const tools =
148
118
  {
149
119
  type: "string",
150
120
  description:
151
- "The draw.io XML content or a URL pointing to XML content. " +
152
- "If a URL is provided, the content will be fetched automatically.",
121
+ "The draw.io XML content in mxGraphModel format.",
153
122
  },
154
123
  lightbox:
155
124
  {
@@ -169,7 +138,7 @@ const tools =
169
138
  {
170
139
  name: "open_drawio_csv",
171
140
  description:
172
- "Opens the draw.io editor with a diagram generated from CSV data or a URL to CSV data. " +
141
+ "Opens the draw.io editor with a diagram generated from CSV data. " +
173
142
  "The CSV format should follow draw.io's CSV import specification which allows " +
174
143
  "creating org charts, flowcharts, and other diagrams from tabular data.",
175
144
  inputSchema:
@@ -181,9 +150,7 @@ const tools =
181
150
  {
182
151
  type: "string",
183
152
  description:
184
- "The CSV content or a URL pointing to CSV content. " +
185
- "If a URL is provided, the content will be fetched automatically. " +
186
- "The CSV should follow draw.io's CSV import format.",
153
+ "The CSV content following draw.io's CSV import format.",
187
154
  },
188
155
  lightbox:
189
156
  {
@@ -203,7 +170,7 @@ const tools =
203
170
  {
204
171
  name: "open_drawio_mermaid",
205
172
  description:
206
- "Opens the draw.io editor with a diagram generated from Mermaid.js syntax or a URL to Mermaid content. " +
173
+ "Opens the draw.io editor with a diagram generated from Mermaid.js syntax. " +
207
174
  "Supports flowcharts, sequence diagrams, class diagrams, state diagrams, " +
208
175
  "entity relationship diagrams, and more using Mermaid.js syntax.",
209
176
  inputSchema:
@@ -215,8 +182,7 @@ const tools =
215
182
  {
216
183
  type: "string",
217
184
  description:
218
- "The Mermaid.js diagram definition or a URL pointing to Mermaid content. " +
219
- "If a URL is provided, the content will be fetched automatically. " +
185
+ "The Mermaid.js diagram definition. " +
220
186
  "Example: 'graph TD; A-->B; B-->C;'",
221
187
  },
222
188
  lightbox:
@@ -285,15 +251,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) =>
285
251
  };
286
252
  }
287
253
 
288
- // Fetch content if it's a URL
289
- if (isUrl(inputContent))
290
- {
291
- content = await fetchContent(inputContent);
292
- }
293
- else
294
- {
295
- content = inputContent;
296
- }
254
+ content = inputContent;
297
255
 
298
256
  switch (name)
299
257
  {