@gehdoc/svg-to-video 0.27.8 → 0.28.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/README.md CHANGED
@@ -7,6 +7,7 @@
7
7
  [![CI](https://img.shields.io/github/actions/workflow/status/GehDoc/svg-to-video/ci.yml?branch=main&logo=githubactions&logoColor=white&label=CI)](https://github.com/GehDoc/svg-to-video/actions/workflows/ci.yml)
8
8
  [![GitHub Release](https://img.shields.io/github/v/release/GehDoc/svg-to-video?logo=github&logoColor=white&label=release&color=2b3137)](https://github.com/GehDoc/svg-to-video/releases)
9
9
  [![npm Version](https://img.shields.io/npm/v/@gehdoc/svg-to-video?logo=npm&logoColor=white&label=npm&color=CB3837)](https://www.npmjs.com/package/@gehdoc/svg-to-video)
10
+ [![Glama](https://img.shields.io/badge/Glama-MCP%20listed-orange)](https://glama.ai/mcp/servers/GehDoc/svg-to-video)
10
11
  [![MCP Registry](https://img.shields.io/badge/MCP-io.github.GehDoc%2Fsvg--to--video-purple?logo=modelcontextprotocol&logoColor=white)](https://registry.modelcontextprotocol.io/v0/servers/io.github.GehDoc%2Fsvg-to-video/versions/latest)
11
12
  [![llms.txt](https://img.shields.io/badge/llms.txt-available-blue)](https://gehdoc.github.io/svg-to-video/llms.txt)
12
13
  [![Docker Image](https://img.shields.io/docker/v/gehdoc/svg-to-video?label=docker&logo=docker&logoColor=white&sort=semver&color=2496ed)](https://hub.docker.com/r/gehdoc/svg-to-video)
@@ -84,8 +85,8 @@ npx @gehdoc/svg-to-video input.svg 60 ./out-dir -d 5 --format gif --transparent
84
85
  # Node.js (animated PNG output)
85
86
  npx @gehdoc/svg-to-video input.svg 60 ./out-dir -d 5 --format apng
86
87
 
87
- # Docker (zero local dependencies; add :Z to -v for SELinux / Fedora)
88
- docker run --rm -v $(pwd):/data:Z gehdoc/svg-to-video /data/input.svg 60 /data/out-dir -d 5 --format gif
88
+ # Docker (zero local dependencies; requires --shm-size=2gb for Chromium rendering; add :Z to -v for SELinux / Fedora)
89
+ docker run --rm --shm-size=2gb -e PUPPETEER_ARGS="--no-sandbox" -v $(pwd):/data:Z gehdoc/svg-to-video /data/input.svg 60 /data/out-dir -d 5 --format gif
89
90
  ```
90
91
 
91
92
  See [docs/CLI.md](./docs/CLI.md) for full usage, arguments, and options. For local building and source execution, see [CONTRIBUTING.md](./CONTRIBUTING.md#commands--testing-strategy).
@@ -119,6 +120,8 @@ See **[docs/MCP.md](./docs/MCP.md)** for full setup instructions, tool schemas,
119
120
  - 📦 **npm Package**: [`@gehdoc/svg-to-video`](https://www.npmjs.com/package/@gehdoc/svg-to-video)
120
121
  - 🐳 **Docker Hub Image**: [`gehdoc/svg-to-video`](https://hub.docker.com/r/gehdoc/svg-to-video)
121
122
  - 🌐 **Web Studio**: [`gehdoc.github.io/svg-to-video/`](https://gehdoc.github.io/svg-to-video/)
123
+ - 🤖 **MCP Registry**: [`io.github.GehDoc/svg-to-video`](https://registry.modelcontextprotocol.io/v0/servers/io.github.GehDoc%2Fsvg-to-video/versions/latest)
124
+ - ⭐ **Glama MCP**: [`glama.ai/mcp/servers/GehDoc/svg-to-video`](https://glama.ai/mcp/servers/GehDoc/svg-to-video)
122
125
 
123
126
  ---
124
127
 
@@ -5,6 +5,7 @@ import { injectApngMetadata } from '#shared/apngMetadataInjector.js';
5
5
  export class ApngFormatGenerator {
6
6
  id = 'apng';
7
7
  extensions = ['.apng', '.png'];
8
+ mimeType = 'image/png';
8
9
  supportsAlpha = true;
9
10
  buildFfmpegArgs(options) {
10
11
  const { fps, hold, outDir, transparent, metadata, inputPattern, pkgVersion, outputFileName, } = options;
@@ -5,6 +5,7 @@ import { injectGifMetadata } from '#shared/gifMetadataInjector.js';
5
5
  export class GifFormatGenerator {
6
6
  id = 'gif';
7
7
  extensions = ['.gif'];
8
+ mimeType = 'image/gif';
8
9
  supportsAlpha = true;
9
10
  buildFfmpegArgs(options) {
10
11
  const { fps, hold, outDir, transparent, metadata, inputPattern, pkgVersion, outputFileName, } = options;
@@ -3,6 +3,7 @@ import { mergeMetadataComments } from '#shared/metadata.js';
3
3
  export class MkvFormatGenerator {
4
4
  id = 'mkv';
5
5
  extensions = ['.mkv'];
6
+ mimeType = 'video/x-matroska';
6
7
  supportsAlpha = true;
7
8
  buildFfmpegArgs(options) {
8
9
  const { fps, hold, outDir, transparent, metadata, inputPattern, pkgVersion, outputFileName, } = options;
@@ -3,6 +3,7 @@ import { mergeMetadataComments } from '#shared/metadata.js';
3
3
  export class MovFormatGenerator {
4
4
  id = 'mov';
5
5
  extensions = ['.mov'];
6
+ mimeType = 'video/quicktime';
6
7
  supportsAlpha = true;
7
8
  buildFfmpegArgs(options) {
8
9
  const { fps, hold, outDir, transparent, metadata, inputPattern, pkgVersion, outputFileName, } = options;
@@ -3,6 +3,7 @@ import { mergeMetadataComments } from '#shared/metadata.js';
3
3
  export class Mp4FormatGenerator {
4
4
  id = 'mp4';
5
5
  extensions = ['.mp4'];
6
+ mimeType = 'video/mp4';
6
7
  supportsAlpha = false;
7
8
  buildFfmpegArgs(options) {
8
9
  const { fps, hold, outDir, metadata, inputPattern, pkgVersion, outputFileName, } = options;
@@ -3,6 +3,7 @@ import { mergeMetadataComments } from '#shared/metadata.js';
3
3
  export class WebmFormatGenerator {
4
4
  id = 'webm';
5
5
  extensions = ['.webm'];
6
+ mimeType = 'video/webm';
6
7
  supportsAlpha = true;
7
8
  buildFfmpegArgs(options) {
8
9
  const { fps, hold, outDir, transparent, metadata, inputPattern, pkgVersion, outputFileName, } = options;
package/dist/src/mcp.js CHANGED
@@ -9,6 +9,7 @@ import { execFileSync } from 'child_process';
9
9
  import { fileURLToPath } from 'url';
10
10
  import { JSDOM } from 'jsdom';
11
11
  import { analyzeSvgAnimation, parseSvgDimensions, calculateAspectRatio, } from '#shared/analyzeSvgAnimation.js';
12
+ import { formatRegistry } from './formats/registry.js';
12
13
  import { isLoggerJsonOutput } from './utils/logger.js';
13
14
  import { trackEvent } from './utils/analytics.js';
14
15
  import { pkg } from './utils/packageInfo.js';
@@ -17,6 +18,25 @@ const __dirname = path.dirname(__filename);
17
18
  const cliJsPath = path.join(__dirname, 'index.js');
18
19
  const cliTsPath = path.join(__dirname, 'index.ts');
19
20
  const cliIndexPath = fs.existsSync(cliJsPath) ? cliJsPath : cliTsPath;
21
+ const isHosted = process.env.MCP_HOSTED === 'true' ||
22
+ process.env.MCP_HOSTED === '1' ||
23
+ process.argv.includes('--hosted');
24
+ function trackSecurityRejection() {
25
+ trackEvent('file-load', {
26
+ aspectRatio: 'unknown',
27
+ hasAnimation: false,
28
+ isDimensionsDetected: false,
29
+ rejectionReason: 'path-traversal-blocked',
30
+ isHosted: true,
31
+ }, 'mcp');
32
+ }
33
+ function getMimeType(formatStr) {
34
+ const generator = formatRegistry.get(formatStr);
35
+ if (generator?.mimeType) {
36
+ return generator.mimeType;
37
+ }
38
+ return 'application/octet-stream';
39
+ }
20
40
  const server = new Server({
21
41
  name: 'svg-to-video',
22
42
  version: pkg.version,
@@ -30,21 +50,21 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
30
50
  tools: [
31
51
  {
32
52
  name: 'render_svg_to_video',
33
- description: 'Render an animated SVG (from file path or raw SVG code) into a high-quality video (MP4, WebM, MKV, MOV) or animated image (aPNG, GIF) with optional background transparency.',
53
+ description: 'Render an animated SVG (from raw SVG code or file path) into a high-quality video (MP4, WebM, MKV, MOV) or animated image (aPNG, GIF) with in-band Base64 media delivery. Use this tool when you need to convert animated SVG graphics into video or image files. First use inspect_svg_animation to detect duration and dimensions if unknown. Specify svgContent for raw XML input or svgFilePath for local files. Pass transparent: true for WebM/GIF/aPNG transparency.',
34
54
  inputSchema: {
35
55
  type: 'object',
36
56
  properties: {
37
57
  svgFilePath: {
38
58
  type: 'string',
39
- description: 'Absolute or relative path to the input .svg file.',
59
+ description: 'Absolute or relative path to the input .svg file (forbidden in hosted sandboxed mode).',
40
60
  },
41
61
  svgContent: {
42
62
  type: 'string',
43
- description: 'Raw SVG string content to render (if svgFilePath is not provided).',
63
+ description: 'Raw SVG string content to render (required if svgFilePath is not provided).',
44
64
  },
45
65
  outDir: {
46
66
  type: 'string',
47
- description: 'Output directory for the generated media file. Defaults to current working directory.',
67
+ description: 'Output directory to preserve generated file locally. Omit to deliver purely in-band via ephemeral storage (forbidden in hosted sandboxed mode).',
48
68
  },
49
69
  fps: {
50
70
  type: 'number',
@@ -90,13 +110,13 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
90
110
  },
91
111
  {
92
112
  name: 'inspect_svg_animation',
93
- description: 'Analyze an SVG file or raw SVG content to detect CSS keyframe animations, estimate duration, and extract viewBox dimensions.',
113
+ description: 'Analyze an SVG file or raw SVG content to detect CSS keyframe animations, estimate duration, and extract viewBox dimensions. Call this tool first before rendering to discover animation parameters and calculate optimal resolution.',
94
114
  inputSchema: {
95
115
  type: 'object',
96
116
  properties: {
97
117
  svgFilePath: {
98
118
  type: 'string',
99
- description: 'Path to the .svg file to inspect.',
119
+ description: 'Path to the .svg file to inspect (forbidden in hosted sandboxed mode).',
100
120
  },
101
121
  svgContent: {
102
122
  type: 'string',
@@ -112,6 +132,18 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
112
132
  const { name, arguments: args } = request.params;
113
133
  if (name === 'inspect_svg_animation') {
114
134
  const params = (args || {});
135
+ if (isHosted && params.svgFilePath) {
136
+ trackSecurityRejection();
137
+ return {
138
+ isError: true,
139
+ content: [
140
+ {
141
+ type: 'text',
142
+ text: 'Access to svgFilePath is forbidden when MCP_HOSTED security sandboxing is enabled. Please provide raw svgContent instead.',
143
+ },
144
+ ],
145
+ };
146
+ }
115
147
  let svgContent = params.svgContent;
116
148
  if (!svgContent && params.svgFilePath) {
117
149
  if (!fs.existsSync(params.svgFilePath)) {
@@ -166,53 +198,82 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
166
198
  }
167
199
  if (name === 'render_svg_to_video') {
168
200
  const params = (args || {});
169
- let targetSvgPath = params.svgFilePath;
170
- let tempSvgFile = false;
171
- if (!targetSvgPath && params.svgContent) {
172
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'svg2vid-mcp-'));
173
- targetSvgPath = path.join(tempDir, 'input.svg');
174
- fs.writeFileSync(targetSvgPath, params.svgContent, 'utf-8');
175
- tempSvgFile = true;
176
- }
177
- if (!targetSvgPath || !fs.existsSync(targetSvgPath)) {
201
+ if (isHosted && (params.svgFilePath || params.outDir)) {
202
+ trackSecurityRejection();
178
203
  return {
179
204
  isError: true,
180
205
  content: [
181
206
  {
182
207
  type: 'text',
183
- text: `Input SVG not found or not provided: ${targetSvgPath || 'N/A'}`,
208
+ text: 'Providing svgFilePath or custom outDir is forbidden when MCP_HOSTED security sandboxing is enabled. Use raw svgContent and rely on in-band media delivery.',
184
209
  },
185
210
  ],
186
211
  };
187
212
  }
188
- const outDir = params.outDir || process.cwd();
189
- const fps = String(params.fps || 60);
190
- const command = cliIndexPath.endsWith('.ts') ? 'npx' : process.execPath;
191
- const cliArgs = cliIndexPath.endsWith('.ts')
192
- ? ['tsx', cliIndexPath, targetSvgPath, fps, outDir, '--json', '--force']
193
- : [cliIndexPath, targetSvgPath, fps, outDir, '--json', '--force'];
194
- if (params.duration) {
195
- cliArgs.push('-d', String(params.duration));
196
- }
197
- if (params.format) {
198
- cliArgs.push('--format', params.format);
199
- }
200
- if (params.transparent) {
201
- cliArgs.push('--transparent');
202
- }
203
- if (params.resolution) {
204
- cliArgs.push('--resolution', params.resolution);
205
- }
206
- if (params.scale) {
207
- cliArgs.push('--scale', String(params.scale));
208
- }
209
- if (params.bgColor) {
210
- cliArgs.push('--bg-color', params.bgColor);
211
- }
212
- if (params.hold) {
213
- cliArgs.push('-h', String(params.hold));
214
- }
213
+ let tempWorkDir = null;
214
+ let targetSvgPath = params.svgFilePath;
215
215
  try {
216
+ if (!targetSvgPath && params.svgContent) {
217
+ tempWorkDir = fs.mkdtempSync(path.join(os.tmpdir(), 'svg2vid-mcp-'));
218
+ targetSvgPath = path.join(tempWorkDir, 'input.svg');
219
+ fs.writeFileSync(targetSvgPath, params.svgContent, 'utf-8');
220
+ }
221
+ if (!targetSvgPath || !fs.existsSync(targetSvgPath)) {
222
+ return {
223
+ isError: true,
224
+ content: [
225
+ {
226
+ type: 'text',
227
+ text: `Input SVG not found or not provided: ${targetSvgPath || 'N/A'}`,
228
+ },
229
+ ],
230
+ };
231
+ }
232
+ const isExplicitOutDir = Boolean(params.outDir);
233
+ let renderOutDir;
234
+ if (isExplicitOutDir && params.outDir) {
235
+ renderOutDir = params.outDir;
236
+ }
237
+ else {
238
+ if (!tempWorkDir) {
239
+ tempWorkDir = fs.mkdtempSync(path.join(os.tmpdir(), 'svg2vid-mcp-'));
240
+ }
241
+ renderOutDir = tempWorkDir;
242
+ }
243
+ const fps = String(params.fps || 60);
244
+ const command = cliIndexPath.endsWith('.ts') ? 'npx' : process.execPath;
245
+ const cliArgs = cliIndexPath.endsWith('.ts')
246
+ ? [
247
+ 'tsx',
248
+ cliIndexPath,
249
+ targetSvgPath,
250
+ fps,
251
+ renderOutDir,
252
+ '--json',
253
+ '--force',
254
+ ]
255
+ : [cliIndexPath, targetSvgPath, fps, renderOutDir, '--json', '--force'];
256
+ if (params.duration) {
257
+ cliArgs.push('-d', String(params.duration));
258
+ }
259
+ if (params.format) {
260
+ cliArgs.push('--format', params.format);
261
+ }
262
+ if (params.transparent) {
263
+ cliArgs.push('--transparent');
264
+ }
265
+ if (params.resolution) {
266
+ cliArgs.push('--resolution', params.resolution);
267
+ }
268
+ if (params.scale) {
269
+ cliArgs.push('--scale', String(params.scale));
270
+ }
271
+ if (params.bgColor) {
272
+ cliArgs.push('--bg-color', params.bgColor);
273
+ }
274
+ if (params.hold) {
275
+ cliArgs.push('-h', String(params.hold));
276
+ }
216
277
  const rawOutput = execFileSync(command, cliArgs, {
217
278
  encoding: 'utf-8',
218
279
  cwd: process.cwd(),
@@ -221,36 +282,55 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
221
282
  SVG_TO_VIDEO_INTERFACE: 'mcp',
222
283
  },
223
284
  });
224
- if (tempSvgFile && targetSvgPath) {
225
- try {
226
- fs.rmSync(path.dirname(targetSvgPath), {
227
- recursive: true,
228
- force: true,
229
- });
230
- }
231
- catch {
232
- // ignore cleanup error
233
- }
234
- }
235
285
  const parsed = JSON.parse(rawOutput.trim());
236
286
  if (isLoggerJsonOutput(parsed)) {
237
- if (parsed.success === true) {
238
- return {
239
- content: [
240
- {
241
- type: 'text',
242
- text: JSON.stringify(parsed, null, 2),
287
+ if (parsed.success === true && parsed.outputFile) {
288
+ const generatedFilePath = parsed.outputFile;
289
+ const mediaBuffer = fs.readFileSync(generatedFilePath);
290
+ const base64Data = mediaBuffer.toString('base64');
291
+ const resolvedFormat = parsed.format || params.format || 'webm';
292
+ const mimeType = getMimeType(resolvedFormat);
293
+ const responseTextObject = { ...parsed };
294
+ if (!isExplicitOutDir) {
295
+ delete responseTextObject['outputFile'];
296
+ }
297
+ const responseContentList = [
298
+ {
299
+ type: 'text',
300
+ text: JSON.stringify(responseTextObject, null, 2),
301
+ },
302
+ ];
303
+ if (mimeType.startsWith('image/')) {
304
+ responseContentList.push({
305
+ type: 'image',
306
+ data: base64Data,
307
+ mimeType,
308
+ });
309
+ }
310
+ else {
311
+ responseContentList.push({
312
+ type: 'resource',
313
+ resource: {
314
+ uri: `urn:svg-to-video:media`,
315
+ mimeType,
316
+ blob: base64Data,
243
317
  },
244
- ],
318
+ });
319
+ }
320
+ return {
321
+ content: responseContentList,
245
322
  };
246
323
  }
247
324
  else {
325
+ const errorMsg = 'error' in parsed && typeof parsed.error === 'string'
326
+ ? parsed.error
327
+ : 'Conversion failed';
248
328
  return {
249
329
  isError: true,
250
330
  content: [
251
331
  {
252
332
  type: 'text',
253
- text: parsed.error || 'Conversion failed',
333
+ text: errorMsg,
254
334
  },
255
335
  ],
256
336
  };
@@ -269,17 +349,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
269
349
  }
270
350
  }
271
351
  catch (error) {
272
- if (tempSvgFile && targetSvgPath) {
273
- try {
274
- fs.rmSync(path.dirname(targetSvgPath), {
275
- recursive: true,
276
- force: true,
277
- });
278
- }
279
- catch {
280
- // ignore cleanup error
281
- }
282
- }
283
352
  return {
284
353
  isError: true,
285
354
  content: [
@@ -290,6 +359,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
290
359
  ],
291
360
  };
292
361
  }
362
+ finally {
363
+ if (tempWorkDir) {
364
+ try {
365
+ fs.rmSync(tempWorkDir, { recursive: true, force: true });
366
+ }
367
+ catch {
368
+ // ignore cleanup error
369
+ }
370
+ }
371
+ }
293
372
  }
294
373
  return {
295
374
  isError: true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gehdoc/svg-to-video",
3
3
  "mcpName": "io.github.GehDoc/svg-to-video",
4
- "version": "0.27.8",
4
+ "version": "0.28.0",
5
5
  "type": "module",
6
6
  "description": "Professional animated SVG to Video (MP4/WebM/MKV/MOV) and Animated Image (aPNG/GIF) converter featuring frame-accurate rendering, CLI automation, Model Context Protocol (MCP) server integration, and a serverless Web Studio.",
7
7
  "imports": {
@@ -57,12 +57,12 @@
57
57
  "@umami/node": "^0.4.0",
58
58
  "commander": "^15.0.0",
59
59
  "jsdom": "^29.1.1",
60
+ "mcp-proxy": "^6.7.19",
60
61
  "puppeteer": "^25.8.0",
61
62
  "tsx": "^4.23.0"
62
63
  },
63
64
  "devDependencies": {
64
65
  "@eslint/js": "^9.39.4",
65
- "@types/commander": "^2.12.0",
66
66
  "@types/ffprobe-static": "^2.0.3",
67
67
  "@types/jsdom": "^28.0.3",
68
68
  "@types/node": "^25.4.0",
@@ -88,7 +88,12 @@
88
88
  "lint:fix": "eslint . --fix && npm run lint:fix -w web",
89
89
  "format": "prettier --check .",
90
90
  "format:fix": "prettier --write .",
91
+ "cli": "tsx src/index.ts",
91
92
  "mcp": "tsx src/mcp.ts",
93
+ "mcp:sse": "mcp-proxy --port 8080 --host 0.0.0.0 -- tsx src/mcp.ts",
94
+ "start:cli": "node dist/src/index.js",
95
+ "start:mcp": "node dist/src/mcp.js",
96
+ "start:mcp:sse": "mcp-proxy --port 8080 --host 0.0.0.0 -- node dist/src/mcp.js",
92
97
  "test:cli": "tsx --test tests/cli.spec.ts",
93
98
  "test:mcp": "tsx --test tests/mcp.spec.ts",
94
99
  "test:pack": "npm run build && tsx --test tests/pack.spec.ts",
@@ -35,5 +35,5 @@ When asked to generate a video or GIF from an SVG animation:
35
35
 
36
36
  3. **Option C: Via Docker**:
37
37
  ```bash
38
- docker run -i --rm --user $(id -u):$(id -g) -v $(pwd):/app/data:Z gehdoc/svg-to-video mcp
38
+ docker run --rm -p 8080:8080 --shm-size=2gb -e PUPPETEER_ARGS="--no-sandbox" gehdoc/svg-to-video --mcp
39
39
  ```