svg-mcp 1.0.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/dist/index.d.ts +1 -0
- package/dist/index.js +66 -0
- package/logo.svg +500 -0
- package/package.json +27 -0
- package/src/index.ts +82 -0
- package/tsconfig.json +14 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const promises_1 = require("fs/promises");
|
|
4
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
5
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
|
+
const resvg_js_1 = require("@resvg/resvg-js");
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const server = new mcp_js_1.McpServer({
|
|
9
|
+
name: "svg-mcp",
|
|
10
|
+
version: "1.0.0",
|
|
11
|
+
});
|
|
12
|
+
function viewSvgToResponse(svg, width) {
|
|
13
|
+
const opts = {};
|
|
14
|
+
if (width) {
|
|
15
|
+
opts.fitTo = { mode: "width", value: width };
|
|
16
|
+
}
|
|
17
|
+
const resvg = new resvg_js_1.Resvg(svg, opts);
|
|
18
|
+
const viewed = resvg.render();
|
|
19
|
+
const pngBuffer = viewed.asPng();
|
|
20
|
+
return {
|
|
21
|
+
content: [
|
|
22
|
+
{
|
|
23
|
+
type: "image",
|
|
24
|
+
data: Buffer.from(pngBuffer).toString("base64"),
|
|
25
|
+
mimeType: "image/png",
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
server.registerTool("viewSVG", {
|
|
31
|
+
title: "View SVG",
|
|
32
|
+
description: "Views an SVG string. Use this to preview an SVG code.",
|
|
33
|
+
inputSchema: {
|
|
34
|
+
svg: zod_1.z.string().describe("The SVG markup string to view"),
|
|
35
|
+
width: zod_1.z
|
|
36
|
+
.number()
|
|
37
|
+
.int()
|
|
38
|
+
.positive()
|
|
39
|
+
.optional()
|
|
40
|
+
.describe("Optional width in pixels to scale the output image"),
|
|
41
|
+
},
|
|
42
|
+
}, async ({ svg, width }) => viewSvgToResponse(svg, width));
|
|
43
|
+
server.registerTool("viewSVGFile", {
|
|
44
|
+
title: "View SVG File",
|
|
45
|
+
description: "Reads an SVG file from disk. Use this to preview an SVG file.",
|
|
46
|
+
inputSchema: {
|
|
47
|
+
path: zod_1.z.string().describe("Absolute or relative path to the SVG file"),
|
|
48
|
+
width: zod_1.z
|
|
49
|
+
.number()
|
|
50
|
+
.int()
|
|
51
|
+
.positive()
|
|
52
|
+
.optional()
|
|
53
|
+
.describe("Optional width in pixels to scale the output image"),
|
|
54
|
+
},
|
|
55
|
+
}, async ({ path, width }) => {
|
|
56
|
+
const svg = await (0, promises_1.readFile)(path, "utf-8");
|
|
57
|
+
return viewSvgToResponse(svg, width);
|
|
58
|
+
});
|
|
59
|
+
async function main() {
|
|
60
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
61
|
+
await server.connect(transport);
|
|
62
|
+
}
|
|
63
|
+
main().catch((err) => {
|
|
64
|
+
console.error("Fatal error:", err);
|
|
65
|
+
process.exit(1);
|
|
66
|
+
});
|
package/logo.svg
ADDED
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<svg
|
|
3
|
+
viewBox="0 0 48 48"
|
|
4
|
+
width="48"
|
|
5
|
+
height="48"
|
|
6
|
+
version="1.1"
|
|
7
|
+
id="svg23"
|
|
8
|
+
sodipodi:docname="logo.svg"
|
|
9
|
+
inkscape:version="1.4.3 (0d15f75, 2025-12-25)"
|
|
10
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
11
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
12
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
13
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
14
|
+
xmlns:svg="http://www.w3.org/2000/svg">
|
|
15
|
+
<sodipodi:namedview
|
|
16
|
+
id="namedview23"
|
|
17
|
+
pagecolor="#505050"
|
|
18
|
+
bordercolor="#eeeeee"
|
|
19
|
+
borderopacity="1"
|
|
20
|
+
inkscape:showpageshadow="0"
|
|
21
|
+
inkscape:pageopacity="0"
|
|
22
|
+
inkscape:pagecheckerboard="0"
|
|
23
|
+
inkscape:deskcolor="#505050"
|
|
24
|
+
inkscape:zoom="8.34386"
|
|
25
|
+
inkscape:cx="26.186921"
|
|
26
|
+
inkscape:cy="44.044363"
|
|
27
|
+
inkscape:window-width="1920"
|
|
28
|
+
inkscape:window-height="1129"
|
|
29
|
+
inkscape:window-x="-8"
|
|
30
|
+
inkscape:window-y="-8"
|
|
31
|
+
inkscape:window-maximized="1"
|
|
32
|
+
inkscape:current-layer="svg23" />
|
|
33
|
+
<defs
|
|
34
|
+
id="defs7">
|
|
35
|
+
<linearGradient
|
|
36
|
+
id="linearGradient57"
|
|
37
|
+
inkscape:collect="always">
|
|
38
|
+
<stop
|
|
39
|
+
style="stop-color:#080c24;stop-opacity:1;"
|
|
40
|
+
offset="0"
|
|
41
|
+
id="stop57" />
|
|
42
|
+
<stop
|
|
43
|
+
style="stop-color:#3b82f6;stop-opacity:1;"
|
|
44
|
+
offset="1"
|
|
45
|
+
id="stop58" />
|
|
46
|
+
</linearGradient>
|
|
47
|
+
<!-- Metallic gradient for the robot arms -->
|
|
48
|
+
<linearGradient
|
|
49
|
+
id="metal"
|
|
50
|
+
x1="0"
|
|
51
|
+
y1="0"
|
|
52
|
+
x2="1"
|
|
53
|
+
y2="1">
|
|
54
|
+
<stop
|
|
55
|
+
offset="0%"
|
|
56
|
+
stop-color="#eeeeee"
|
|
57
|
+
id="stop1" />
|
|
58
|
+
<stop
|
|
59
|
+
offset="50%"
|
|
60
|
+
stop-color="#999999"
|
|
61
|
+
id="stop2" />
|
|
62
|
+
<stop
|
|
63
|
+
offset="100%"
|
|
64
|
+
stop-color="#444444"
|
|
65
|
+
id="stop3" />
|
|
66
|
+
</linearGradient>
|
|
67
|
+
<!-- Dark metal for joints -->
|
|
68
|
+
<linearGradient
|
|
69
|
+
id="darkMetal"
|
|
70
|
+
x1="0"
|
|
71
|
+
y1="0"
|
|
72
|
+
x2="1"
|
|
73
|
+
y2="1">
|
|
74
|
+
<stop
|
|
75
|
+
offset="0%"
|
|
76
|
+
stop-color="#666666"
|
|
77
|
+
id="stop4" />
|
|
78
|
+
<stop
|
|
79
|
+
offset="100%"
|
|
80
|
+
stop-color="#222222"
|
|
81
|
+
id="stop5" />
|
|
82
|
+
</linearGradient>
|
|
83
|
+
<!-- Pen gradient -->
|
|
84
|
+
<linearGradient
|
|
85
|
+
id="pen"
|
|
86
|
+
x1="0"
|
|
87
|
+
y1="0"
|
|
88
|
+
x2="1"
|
|
89
|
+
y2="0">
|
|
90
|
+
<stop
|
|
91
|
+
offset="0%"
|
|
92
|
+
stop-color="#e040fb"
|
|
93
|
+
id="stop6" />
|
|
94
|
+
<stop
|
|
95
|
+
offset="100%"
|
|
96
|
+
stop-color="#5c6bc0"
|
|
97
|
+
id="stop7" />
|
|
98
|
+
</linearGradient>
|
|
99
|
+
<linearGradient
|
|
100
|
+
inkscape:collect="always"
|
|
101
|
+
xlink:href="#metal"
|
|
102
|
+
id="linearGradient34"
|
|
103
|
+
x1="-47.819202"
|
|
104
|
+
y1="-53.686592"
|
|
105
|
+
x2="59.553978"
|
|
106
|
+
y2="53.686592"
|
|
107
|
+
gradientTransform="scale(1.7043362,0.58673869)"
|
|
108
|
+
gradientUnits="userSpaceOnUse" />
|
|
109
|
+
<linearGradient
|
|
110
|
+
inkscape:collect="always"
|
|
111
|
+
xlink:href="#darkMetal"
|
|
112
|
+
id="linearGradient35"
|
|
113
|
+
x1="63.5"
|
|
114
|
+
y1="-36.5"
|
|
115
|
+
x2="136.5"
|
|
116
|
+
y2="36.5"
|
|
117
|
+
gradientUnits="userSpaceOnUse" />
|
|
118
|
+
<linearGradient
|
|
119
|
+
inkscape:collect="always"
|
|
120
|
+
xlink:href="#metal"
|
|
121
|
+
id="linearGradient36"
|
|
122
|
+
x1="63.643177"
|
|
123
|
+
y1="-33.275368"
|
|
124
|
+
x2="130.19391"
|
|
125
|
+
y2="33.275368"
|
|
126
|
+
gradientTransform="scale(1.5476915,0.64612362)"
|
|
127
|
+
gradientUnits="userSpaceOnUse" />
|
|
128
|
+
<linearGradient
|
|
129
|
+
inkscape:collect="always"
|
|
130
|
+
xlink:href="#darkMetal"
|
|
131
|
+
id="linearGradient37"
|
|
132
|
+
x1="176.5"
|
|
133
|
+
y1="-23.5"
|
|
134
|
+
x2="223.5"
|
|
135
|
+
y2="23.5"
|
|
136
|
+
gradientUnits="userSpaceOnUse" />
|
|
137
|
+
<linearGradient
|
|
138
|
+
inkscape:collect="always"
|
|
139
|
+
xlink:href="#metal"
|
|
140
|
+
id="linearGradient38"
|
|
141
|
+
x1="220.37579"
|
|
142
|
+
y1="-23.869417"
|
|
143
|
+
x2="268.11462"
|
|
144
|
+
y2="23.869417"
|
|
145
|
+
gradientTransform="scale(0.90073417,1.1102055)"
|
|
146
|
+
gradientUnits="userSpaceOnUse" />
|
|
147
|
+
<linearGradient
|
|
148
|
+
inkscape:collect="always"
|
|
149
|
+
xlink:href="#pen"
|
|
150
|
+
id="linearGradient39"
|
|
151
|
+
x1="247.76131"
|
|
152
|
+
y1="-35.669872"
|
|
153
|
+
x2="297.47244"
|
|
154
|
+
y2="-35.669872"
|
|
155
|
+
gradientTransform="scale(0.86256212,1.1593368)"
|
|
156
|
+
gradientUnits="userSpaceOnUse" />
|
|
157
|
+
<linearGradient
|
|
158
|
+
inkscape:collect="always"
|
|
159
|
+
xlink:href="#metal"
|
|
160
|
+
id="linearGradient51"
|
|
161
|
+
gradientUnits="userSpaceOnUse"
|
|
162
|
+
gradientTransform="scale(1.7043362,0.58673869)"
|
|
163
|
+
x1="-47.819202"
|
|
164
|
+
y1="-53.686592"
|
|
165
|
+
x2="59.553978"
|
|
166
|
+
y2="53.686592" />
|
|
167
|
+
<linearGradient
|
|
168
|
+
inkscape:collect="always"
|
|
169
|
+
xlink:href="#darkMetal"
|
|
170
|
+
id="linearGradient52"
|
|
171
|
+
gradientUnits="userSpaceOnUse"
|
|
172
|
+
x1="63.5"
|
|
173
|
+
y1="-36.5"
|
|
174
|
+
x2="136.5"
|
|
175
|
+
y2="36.5" />
|
|
176
|
+
<linearGradient
|
|
177
|
+
inkscape:collect="always"
|
|
178
|
+
xlink:href="#metal"
|
|
179
|
+
id="linearGradient53"
|
|
180
|
+
gradientUnits="userSpaceOnUse"
|
|
181
|
+
gradientTransform="scale(1.5476915,0.64612362)"
|
|
182
|
+
x1="63.643177"
|
|
183
|
+
y1="-33.275368"
|
|
184
|
+
x2="130.19391"
|
|
185
|
+
y2="33.275368" />
|
|
186
|
+
<linearGradient
|
|
187
|
+
inkscape:collect="always"
|
|
188
|
+
xlink:href="#darkMetal"
|
|
189
|
+
id="linearGradient54"
|
|
190
|
+
gradientUnits="userSpaceOnUse"
|
|
191
|
+
x1="176.5"
|
|
192
|
+
y1="-23.5"
|
|
193
|
+
x2="223.5"
|
|
194
|
+
y2="23.5" />
|
|
195
|
+
<linearGradient
|
|
196
|
+
inkscape:collect="always"
|
|
197
|
+
xlink:href="#metal"
|
|
198
|
+
id="linearGradient55"
|
|
199
|
+
gradientUnits="userSpaceOnUse"
|
|
200
|
+
gradientTransform="scale(0.90073417,1.1102055)"
|
|
201
|
+
x1="220.37579"
|
|
202
|
+
y1="-23.869417"
|
|
203
|
+
x2="268.11462"
|
|
204
|
+
y2="23.869417" />
|
|
205
|
+
<linearGradient
|
|
206
|
+
inkscape:collect="always"
|
|
207
|
+
xlink:href="#pen"
|
|
208
|
+
id="linearGradient56"
|
|
209
|
+
gradientUnits="userSpaceOnUse"
|
|
210
|
+
gradientTransform="scale(0.86256212,1.1593368)"
|
|
211
|
+
x1="247.76131"
|
|
212
|
+
y1="-35.669872"
|
|
213
|
+
x2="297.47244"
|
|
214
|
+
y2="-35.669872" />
|
|
215
|
+
<radialGradient
|
|
216
|
+
inkscape:collect="always"
|
|
217
|
+
xlink:href="#linearGradient57"
|
|
218
|
+
id="radialGradient58"
|
|
219
|
+
cx="24.001221"
|
|
220
|
+
cy="23.99555"
|
|
221
|
+
fx="24.001221"
|
|
222
|
+
fy="23.99555"
|
|
223
|
+
r="21.023381"
|
|
224
|
+
gradientTransform="matrix(1,0,0,0.99984273,0,0.0037737)"
|
|
225
|
+
gradientUnits="userSpaceOnUse" />
|
|
226
|
+
</defs>
|
|
227
|
+
<!-- Background paper -->
|
|
228
|
+
<circle
|
|
229
|
+
cx="24"
|
|
230
|
+
cy="24"
|
|
231
|
+
r="20.929468"
|
|
232
|
+
fill="none"
|
|
233
|
+
stroke="#e0e0e0"
|
|
234
|
+
stroke-width="0.190268"
|
|
235
|
+
stroke-dasharray="15, 10"
|
|
236
|
+
id="circle7"
|
|
237
|
+
style="stroke-dasharray:8, 8;stroke-dashoffset:0;fill:url(#radialGradient58);fill-opacity:1;stroke-width:1.2;stroke-linecap:round;stroke-linejoin:round;stroke:#60a5fa" />
|
|
238
|
+
<circle
|
|
239
|
+
cx="24"
|
|
240
|
+
cy="24"
|
|
241
|
+
r="13.318753"
|
|
242
|
+
fill="none"
|
|
243
|
+
stroke="#e0e0e0"
|
|
244
|
+
stroke-width="0.095134"
|
|
245
|
+
stroke-dasharray="5, 5"
|
|
246
|
+
id="circle8"
|
|
247
|
+
style="stroke-width:0.8;stroke-dasharray:52.55744667, 52.55744667;stroke-dashoffset:0;stroke-linecap:round;stroke:#93c5fd;stroke-opacity:0.6" />
|
|
248
|
+
<g
|
|
249
|
+
id="g45"
|
|
250
|
+
transform="rotate(179.94562,24.29229,24.19309)">
|
|
251
|
+
<g
|
|
252
|
+
id="robot-1"
|
|
253
|
+
transform="matrix(0.09513395,0,0,0.09513395,31.130992,24.719092)">
|
|
254
|
+
<g
|
|
255
|
+
transform="rotate(-45,106.06602,256.06602)"
|
|
256
|
+
id="g12">
|
|
257
|
+
<!-- Base arm (Drawn solidly, getting "sketched" at the back) -->
|
|
258
|
+
<path
|
|
259
|
+
d="M -80,-30 H 100 V 30 H -80 Z"
|
|
260
|
+
fill="url(#metal)"
|
|
261
|
+
stroke="#333333"
|
|
262
|
+
stroke-width="3"
|
|
263
|
+
id="path8"
|
|
264
|
+
style="fill:url(#linearGradient34)" />
|
|
265
|
+
<line
|
|
266
|
+
x1="-80"
|
|
267
|
+
y1="-30"
|
|
268
|
+
x2="-80"
|
|
269
|
+
y2="30"
|
|
270
|
+
stroke="#f8f9fa"
|
|
271
|
+
stroke-width="4"
|
|
272
|
+
stroke-dasharray="5, 5"
|
|
273
|
+
id="line8" />
|
|
274
|
+
<!-- Sketched edge -->
|
|
275
|
+
<!-- Forearm joint -->
|
|
276
|
+
<circle
|
|
277
|
+
cx="100"
|
|
278
|
+
cy="0"
|
|
279
|
+
r="35"
|
|
280
|
+
fill="url(#darkMetal)"
|
|
281
|
+
stroke="#333333"
|
|
282
|
+
stroke-width="3"
|
|
283
|
+
id="circle9"
|
|
284
|
+
style="fill:url(#linearGradient35)" />
|
|
285
|
+
<circle
|
|
286
|
+
cx="100"
|
|
287
|
+
cy="0"
|
|
288
|
+
r="15"
|
|
289
|
+
fill="#333333"
|
|
290
|
+
id="circle10" />
|
|
291
|
+
<!-- Wrist / Hand -->
|
|
292
|
+
<rect
|
|
293
|
+
x="100"
|
|
294
|
+
y="-20"
|
|
295
|
+
width="100"
|
|
296
|
+
height="40"
|
|
297
|
+
rx="8"
|
|
298
|
+
fill="url(#metal)"
|
|
299
|
+
stroke="#333333"
|
|
300
|
+
stroke-width="3"
|
|
301
|
+
id="rect10"
|
|
302
|
+
style="fill:url(#linearGradient36)" />
|
|
303
|
+
<circle
|
|
304
|
+
cx="200"
|
|
305
|
+
cy="0"
|
|
306
|
+
r="22"
|
|
307
|
+
fill="url(#darkMetal)"
|
|
308
|
+
stroke="#333333"
|
|
309
|
+
stroke-width="3"
|
|
310
|
+
id="circle11"
|
|
311
|
+
style="fill:url(#linearGradient37)" />
|
|
312
|
+
<!-- Fingers gripping pen -->
|
|
313
|
+
<path
|
|
314
|
+
d="m 200,-25 40,10 v 30 l -40,10 z"
|
|
315
|
+
fill="url(#metal)"
|
|
316
|
+
stroke="#333333"
|
|
317
|
+
stroke-width="3"
|
|
318
|
+
stroke-linejoin="round"
|
|
319
|
+
id="path11"
|
|
320
|
+
style="fill:url(#linearGradient38)" />
|
|
321
|
+
<!-- Pen Body -->
|
|
322
|
+
<polygon
|
|
323
|
+
points="255,15 225,10 215,-40 235,-35 "
|
|
324
|
+
fill="url(#pen)"
|
|
325
|
+
stroke="#222222"
|
|
326
|
+
stroke-width="2"
|
|
327
|
+
id="polygon11"
|
|
328
|
+
style="fill:url(#linearGradient39)" />
|
|
329
|
+
<!-- Pen Nib -->
|
|
330
|
+
<polygon
|
|
331
|
+
points="255,15 275,35 245,25 "
|
|
332
|
+
fill="#222222"
|
|
333
|
+
id="polygon12" />
|
|
334
|
+
<!-- Ink Drop/Tip -->
|
|
335
|
+
<circle
|
|
336
|
+
cx="275"
|
|
337
|
+
cy="35"
|
|
338
|
+
r="3"
|
|
339
|
+
fill="#333333"
|
|
340
|
+
id="circle12" />
|
|
341
|
+
</g>
|
|
342
|
+
</g>
|
|
343
|
+
<path
|
|
344
|
+
d="M 37.980636,23.196949 Q 44.449745,19.962394 50.728586,5.1214979"
|
|
345
|
+
fill="none"
|
|
346
|
+
stroke="#222222"
|
|
347
|
+
stroke-width="0.285402"
|
|
348
|
+
stroke-linecap="round"
|
|
349
|
+
stroke-dasharray="10, 6"
|
|
350
|
+
id="path16" />
|
|
351
|
+
<path
|
|
352
|
+
d="M 37.980636,23.196949 Q 46.352424,24.719092 54.724212,9.1171238"
|
|
353
|
+
fill="none"
|
|
354
|
+
stroke="#222222"
|
|
355
|
+
stroke-width="0.190268"
|
|
356
|
+
stroke-linecap="round"
|
|
357
|
+
stroke-dasharray="5, 8"
|
|
358
|
+
id="path17" />
|
|
359
|
+
<line
|
|
360
|
+
x1="38.266037"
|
|
361
|
+
y1="22.816412"
|
|
362
|
+
x2="39.217381"
|
|
363
|
+
y2="21.865072"
|
|
364
|
+
id="line19"
|
|
365
|
+
style="stroke:#e67e22;stroke-width:0.190268;stroke-linecap:round" />
|
|
366
|
+
<line
|
|
367
|
+
x1="38.741707"
|
|
368
|
+
y1="23.767752"
|
|
369
|
+
x2="40.168716"
|
|
370
|
+
y2="24.243422"
|
|
371
|
+
id="line20"
|
|
372
|
+
style="stroke:#e67e22;stroke-width:0.190268;stroke-linecap:round" />
|
|
373
|
+
</g>
|
|
374
|
+
<g
|
|
375
|
+
id="g51"
|
|
376
|
+
transform="rotate(-13.874532,27.877931,26.240036)">
|
|
377
|
+
<g
|
|
378
|
+
id="g49"
|
|
379
|
+
transform="matrix(0.09513395,0,0,0.09513395,31.130992,24.719092)">
|
|
380
|
+
<g
|
|
381
|
+
transform="rotate(-45,106.06602,256.06602)"
|
|
382
|
+
id="g48">
|
|
383
|
+
<!-- Base arm (Drawn solidly, getting "sketched" at the back) -->
|
|
384
|
+
<path
|
|
385
|
+
d="M -80,-30 H 100 V 30 H -80 Z"
|
|
386
|
+
fill="url(#metal)"
|
|
387
|
+
stroke="#333333"
|
|
388
|
+
stroke-width="3"
|
|
389
|
+
id="path45"
|
|
390
|
+
style="fill:url(#linearGradient51)" />
|
|
391
|
+
<line
|
|
392
|
+
x1="-80"
|
|
393
|
+
y1="-30"
|
|
394
|
+
x2="-80"
|
|
395
|
+
y2="30"
|
|
396
|
+
stroke="#f8f9fa"
|
|
397
|
+
stroke-width="4"
|
|
398
|
+
stroke-dasharray="5, 5"
|
|
399
|
+
id="line45" />
|
|
400
|
+
<!-- Sketched edge -->
|
|
401
|
+
<!-- Forearm joint -->
|
|
402
|
+
<circle
|
|
403
|
+
cx="100"
|
|
404
|
+
cy="0"
|
|
405
|
+
r="35"
|
|
406
|
+
fill="url(#darkMetal)"
|
|
407
|
+
stroke="#333333"
|
|
408
|
+
stroke-width="3"
|
|
409
|
+
id="circle45"
|
|
410
|
+
style="fill:url(#linearGradient52)" />
|
|
411
|
+
<circle
|
|
412
|
+
cx="100"
|
|
413
|
+
cy="0"
|
|
414
|
+
r="15"
|
|
415
|
+
fill="#333333"
|
|
416
|
+
id="circle46" />
|
|
417
|
+
<!-- Wrist / Hand -->
|
|
418
|
+
<rect
|
|
419
|
+
x="100"
|
|
420
|
+
y="-20"
|
|
421
|
+
width="100"
|
|
422
|
+
height="40"
|
|
423
|
+
rx="8"
|
|
424
|
+
fill="url(#metal)"
|
|
425
|
+
stroke="#333333"
|
|
426
|
+
stroke-width="3"
|
|
427
|
+
id="rect46"
|
|
428
|
+
style="fill:url(#linearGradient53)" />
|
|
429
|
+
<circle
|
|
430
|
+
cx="200"
|
|
431
|
+
cy="0"
|
|
432
|
+
r="22"
|
|
433
|
+
fill="url(#darkMetal)"
|
|
434
|
+
stroke="#333333"
|
|
435
|
+
stroke-width="3"
|
|
436
|
+
id="circle47"
|
|
437
|
+
style="fill:url(#linearGradient54)" />
|
|
438
|
+
<!-- Fingers gripping pen -->
|
|
439
|
+
<path
|
|
440
|
+
d="m 200,-25 40,10 v 30 l -40,10 z"
|
|
441
|
+
fill="url(#metal)"
|
|
442
|
+
stroke="#333333"
|
|
443
|
+
stroke-width="3"
|
|
444
|
+
stroke-linejoin="round"
|
|
445
|
+
id="path47"
|
|
446
|
+
style="fill:url(#linearGradient55)" />
|
|
447
|
+
<!-- Pen Body -->
|
|
448
|
+
<polygon
|
|
449
|
+
points="235,-35 255,15 225,10 215,-40 "
|
|
450
|
+
fill="url(#pen)"
|
|
451
|
+
stroke="#222222"
|
|
452
|
+
stroke-width="2"
|
|
453
|
+
id="polygon47"
|
|
454
|
+
style="fill:url(#linearGradient56)" />
|
|
455
|
+
<!-- Pen Nib -->
|
|
456
|
+
<polygon
|
|
457
|
+
points="275,35 245,25 255,15 "
|
|
458
|
+
fill="#222222"
|
|
459
|
+
id="polygon48" />
|
|
460
|
+
<!-- Ink Drop/Tip -->
|
|
461
|
+
<circle
|
|
462
|
+
cx="275"
|
|
463
|
+
cy="35"
|
|
464
|
+
r="3"
|
|
465
|
+
fill="#333333"
|
|
466
|
+
id="circle48" />
|
|
467
|
+
</g>
|
|
468
|
+
</g>
|
|
469
|
+
<path
|
|
470
|
+
d="M 37.980636,23.196949 Q 44.449745,19.962394 50.728586,5.1214979"
|
|
471
|
+
fill="none"
|
|
472
|
+
stroke="#222222"
|
|
473
|
+
stroke-width="0.285402"
|
|
474
|
+
stroke-linecap="round"
|
|
475
|
+
stroke-dasharray="10, 6"
|
|
476
|
+
id="path49" />
|
|
477
|
+
<path
|
|
478
|
+
d="M 37.980636,23.196949 Q 46.352424,24.719092 54.724212,9.1171238"
|
|
479
|
+
fill="none"
|
|
480
|
+
stroke="#222222"
|
|
481
|
+
stroke-width="0.190268"
|
|
482
|
+
stroke-linecap="round"
|
|
483
|
+
stroke-dasharray="5, 8"
|
|
484
|
+
id="path50" />
|
|
485
|
+
<line
|
|
486
|
+
x1="38.266037"
|
|
487
|
+
y1="22.816412"
|
|
488
|
+
x2="39.217381"
|
|
489
|
+
y2="21.865072"
|
|
490
|
+
id="line50"
|
|
491
|
+
style="stroke:#e67e22;stroke-width:0.190268;stroke-linecap:round" />
|
|
492
|
+
<line
|
|
493
|
+
x1="38.741707"
|
|
494
|
+
y1="23.767752"
|
|
495
|
+
x2="40.168716"
|
|
496
|
+
y2="24.243422"
|
|
497
|
+
id="line51"
|
|
498
|
+
style="stroke:#e67e22;stroke-width:0.190268;stroke-linecap:round" />
|
|
499
|
+
</g>
|
|
500
|
+
</svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "svg-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server that allows AI to view SVGs",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"start": "tsc && node dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"mcp",
|
|
13
|
+
"svg",
|
|
14
|
+
"render"
|
|
15
|
+
],
|
|
16
|
+
"author": "LizeLive",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
20
|
+
"@resvg/resvg-js": "^2.6.2",
|
|
21
|
+
"zod": "^4.3.6"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^25.5.0",
|
|
25
|
+
"typescript": "^5.9.3"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { readFile } from "fs/promises";
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { Resvg } from "@resvg/resvg-js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
const server = new McpServer({
|
|
8
|
+
name: "svg-mcp",
|
|
9
|
+
version: "1.0.0",
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
function viewSvgToResponse(svg: string, width?: number) {
|
|
13
|
+
const opts: Record<string, unknown> = {};
|
|
14
|
+
if (width) {
|
|
15
|
+
opts.fitTo = { mode: "width" as const, value: width };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const resvg = new Resvg(svg, opts);
|
|
19
|
+
const viewed = resvg.render();
|
|
20
|
+
const pngBuffer = viewed.asPng();
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
content: [
|
|
24
|
+
{
|
|
25
|
+
type: "image" as const,
|
|
26
|
+
data: Buffer.from(pngBuffer).toString("base64"),
|
|
27
|
+
mimeType: "image/png" as const,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
server.registerTool(
|
|
34
|
+
"viewSVG",
|
|
35
|
+
{
|
|
36
|
+
title: "View SVG",
|
|
37
|
+
description:
|
|
38
|
+
"Views an SVG string. Use this to preview an SVG code.",
|
|
39
|
+
inputSchema: {
|
|
40
|
+
svg: z.string().describe("The SVG markup string to view"),
|
|
41
|
+
width: z
|
|
42
|
+
.number()
|
|
43
|
+
.int()
|
|
44
|
+
.positive()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe("Optional width in pixels to scale the output image"),
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
async ({ svg, width }) => viewSvgToResponse(svg, width)
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
server.registerTool(
|
|
53
|
+
"viewSVGFile",
|
|
54
|
+
{
|
|
55
|
+
title: "View SVG File",
|
|
56
|
+
description:
|
|
57
|
+
"Reads an SVG file from disk. Use this to preview an SVG file.",
|
|
58
|
+
inputSchema: {
|
|
59
|
+
path: z.string().describe("Absolute or relative path to the SVG file"),
|
|
60
|
+
width: z
|
|
61
|
+
.number()
|
|
62
|
+
.int()
|
|
63
|
+
.positive()
|
|
64
|
+
.optional()
|
|
65
|
+
.describe("Optional width in pixels to scale the output image"),
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
async ({ path, width }) => {
|
|
69
|
+
const svg = await readFile(path, "utf-8");
|
|
70
|
+
return viewSvgToResponse(svg, width);
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
async function main() {
|
|
75
|
+
const transport = new StdioServerTransport();
|
|
76
|
+
await server.connect(transport);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
main().catch((err) => {
|
|
80
|
+
console.error("Fatal error:", err);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "Node16",
|
|
5
|
+
"moduleResolution": "Node16",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"skipLibCheck": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"]
|
|
14
|
+
}
|