@mindstone/mcp-server-runway 0.4.0 → 0.4.2

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,7 +7,7 @@ Runway ML MCP server for Model Context Protocol hosts. Generate AI video, images
7
7
 
8
8
  ## Status
9
9
 
10
- - **Version:** [0.4.0](./CHANGELOG.md) · [npm](https://www.npmjs.com/package/@mindstone/mcp-server-runway)
10
+ - **Version:** [0.4.2](./CHANGELOG.md) · [npm](https://www.npmjs.com/package/@mindstone/mcp-server-runway)
11
11
  - **Auth:** API key ([`RUNWAYML_API_SECRET`](./server.json))
12
12
  - **Tools:** [23](./src/tools/) (video, image, audio, voices, tasks)
13
13
  - **Surface:** cloud-api
@@ -130,6 +130,8 @@ node dist/index.js
130
130
  - `character_performance` — Animate a character with facial expressions and body movements (Act-Two)
131
131
  - `upscale_video` — Upscale a video up to 4K (Magnific Video Upscaler)
132
132
 
133
+ Video models: `generate_video_from_image` takes `gen4_turbo` (default), `gen4.5`, `veo3.1` or `veo3.1_fast`; `generate_video_from_text` takes `gen4.5` (default), `veo3.1` or `veo3.1_fast`. `veo3` is no longer accepted by Runway and is refused before any request; use `veo3.1` or `veo3.1_fast` instead.
134
+
133
135
  ### Image
134
136
  - `generate_image` — Generate an image from text, optionally with reference images
135
137
 
package/dist/client.d.ts CHANGED
@@ -7,6 +7,8 @@
7
7
  * Auth: Authorization: Bearer {key}, X-Runway-Version: 2024-11-06
8
8
  * Base URL: https://api.dev.runwayml.com/v1
9
9
  */
10
+ /** Envelope source label for Runway-authored text (error bodies, task failures). */
11
+ export declare const RUNWAY_API_SOURCE = "runway-api";
10
12
  /**
11
13
  * Validate that `input` is a local file path inside the allow-listed root,
12
14
  * canonicalising via `fs.realpathSync` so that symlink-escape attempts are
package/dist/client.js CHANGED
@@ -12,6 +12,9 @@ import * as os from 'os';
12
12
  import * as path from 'path';
13
13
  import { RunwayError, getRequestTimeoutMs, getUploadTimeoutMs, RUNWAY_API_BASE, RUNWAY_API_VERSION, MIME_MAP, DATA_URI_BINARY_LIMITS, MAX_UPLOAD_BYTES, MIN_UPLOAD_BYTES, } from './types.js';
14
14
  import { getApiKey } from './auth.js';
15
+ import { wrapUntrusted } from './untrusted-content.js';
16
+ /** Envelope source label for Runway-authored text (error bodies, task failures). */
17
+ export const RUNWAY_API_SOURCE = 'runway-api';
15
18
  // ============================================================================
16
19
  // Local-file sandbox
17
20
  // ============================================================================
@@ -317,7 +320,7 @@ export async function runwayFetch(urlPath, options = {}) {
317
320
  detail = (await response.json())?.error || '';
318
321
  }
319
322
  catch { /* empty */ }
320
- throw new RunwayError(`Runway API error (HTTP ${response.status}): ${detail}`, `HTTP_${response.status}`, 'Try again or check https://dev.runwayml.com/');
323
+ throw new RunwayError(`Runway API error (HTTP ${response.status}): ${detail ? wrapUntrusted(detail, RUNWAY_API_SOURCE) : ''}`, `HTTP_${response.status}`, 'Try again or check https://dev.runwayml.com/');
321
324
  }
322
325
  return (await response.json());
323
326
  }
@@ -543,7 +546,6 @@ export function costEstimate(model, duration, audio) {
543
546
  gen4_turbo: 5,
544
547
  aleph2: 28,
545
548
  act_two: 5,
546
- veo3: 40,
547
549
  'veo3.1': audio === false ? 20 : 40,
548
550
  'veo3.1_fast': audio === false ? 10 : 15,
549
551
  };
@@ -1,7 +1,8 @@
1
1
  import { z } from 'zod';
2
- import { runwayFetch, runwayRawFetch, validateDownloadUrl, assertDownloadPathInRoot } from '../client.js';
2
+ import { runwayFetch, runwayRawFetch, validateDownloadUrl, assertDownloadPathInRoot, RUNWAY_API_SOURCE, } from '../client.js';
3
3
  import { RunwayError } from '../types.js';
4
4
  import { withErrorHandling } from '../utils.js';
5
+ import { wrapUntrusted } from '../untrusted-content.js';
5
6
  const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
6
7
  export function registerTaskTools(server) {
7
8
  // ── Check Task ────────────────────────────────────────────────────────
@@ -30,8 +31,9 @@ export function registerTaskTools(server) {
30
31
  }
31
32
  else if (result.status === 'FAILED') {
32
33
  response.ok = false;
33
- response.error = result.failure || 'Generation failed.';
34
- response.failure_code = result.failureCode;
34
+ response.error = result.failure
35
+ ? wrapUntrusted(result.failure, RUNWAY_API_SOURCE) : 'Generation failed.';
36
+ response.failure_code = wrapUntrusted(result.failureCode, RUNWAY_API_SOURCE);
35
37
  }
36
38
  return JSON.stringify(response);
37
39
  }));
@@ -76,7 +78,8 @@ export function registerTaskTools(server) {
76
78
  if (result.status === 'FAILED') {
77
79
  return JSON.stringify({
78
80
  ok: false, task_id: result.id, status: 'FAILED',
79
- error: result.failure || 'Generation failed.', failure_code: result.failureCode,
81
+ error: result.failure ? wrapUntrusted(result.failure, RUNWAY_API_SOURCE) : 'Generation failed.',
82
+ failure_code: wrapUntrusted(result.failureCode, RUNWAY_API_SOURCE),
80
83
  elapsed_seconds: Math.round((Date.now() - startTime) / 1000),
81
84
  });
82
85
  }
@@ -5,13 +5,13 @@ export function registerVideoTools(server) {
5
5
  // ── Image-to-Video ────────────────────────────────────────────────────
6
6
  server.registerTool('generate_video_from_image', {
7
7
  description: 'Animate a still image into a video. Supports first-frame (and optionally last-frame) keyframe control. ' +
8
- 'MODELS: gen4.5 (flagship), gen4_turbo (fast/cheap), veo3.1 (best quality + audio), veo3.1_fast, veo3 (deprecated upstream). ' +
8
+ 'MODELS: gen4.5 (flagship), gen4_turbo (fast/cheap), veo3.1 (best quality + audio), veo3.1_fast. ' +
9
9
  'WORKFLOW: Returns task_id → poll with check_runway_task or use wait_for_runway_task.',
10
10
  inputSchema: z.object({
11
11
  prompt_image: z.string().describe('First frame image. HTTPS URL, Runway URI, or local file path.'),
12
12
  last_frame_image: z.string().optional().describe('Optional last frame image for transition.'),
13
13
  prompt_text: z.string().optional().describe('Describe the desired motion.'),
14
- model: z.enum(['gen4.5', 'gen4_turbo', 'veo3.1', 'veo3.1_fast', 'veo3']).optional().describe('Default: gen4_turbo.'),
14
+ model: z.enum(['gen4.5', 'gen4_turbo', 'veo3.1', 'veo3.1_fast']).optional().describe('Default: gen4_turbo.'),
15
15
  ratio: z.enum(['1280:720', '720:1280', '960:960', '1104:832', '832:1104', '1584:672']).optional().describe('Output resolution. Default: 1280:720.'),
16
16
  duration: z.number().optional().describe('Seconds. gen4: 2-10 (default 5). veo: 4,6,8 (default 8).'),
17
17
  audio: z.boolean().optional().describe('Generate audio (veo models only). Default: true.'),
@@ -61,11 +61,11 @@ export function registerVideoTools(server) {
61
61
  // ── Text-to-Video ─────────────────────────────────────────────────────
62
62
  server.registerTool('generate_video_from_text', {
63
63
  description: 'Create a video entirely from a text description. ' +
64
- 'MODELS: gen4.5 (flagship), veo3.1 (best + audio), veo3.1_fast, veo3 (deprecated upstream). ' +
64
+ 'MODELS: gen4.5 (flagship), veo3.1 (best + audio), veo3.1_fast. ' +
65
65
  'WORKFLOW: Returns task_id → poll or use wait_for_runway_task.',
66
66
  inputSchema: z.object({
67
- prompt_text: z.string().describe('Detailed video description. Max 1000 chars.'),
68
- model: z.enum(['gen4.5', 'veo3.1', 'veo3.1_fast', 'veo3']).optional().describe('Default: gen4.5.'),
67
+ prompt_text: z.string().max(1000).describe('Detailed video description. Max 1000 chars.'),
68
+ model: z.enum(['gen4.5', 'veo3.1', 'veo3.1_fast']).optional().describe('Default: gen4.5.'),
69
69
  ratio: z.enum(['1280:720', '720:1280']).optional().describe('Output resolution. Default: 1280:720.'),
70
70
  duration: z.number().optional().describe('Seconds. gen4.5: 2-10 (default 5). veo: 4,6,8 (default 8).'),
71
71
  audio: z.boolean().optional().describe('Generate audio (veo models only). Default: true.'),
@@ -50,10 +50,10 @@ export function registerVoiceTools(server) {
50
50
  'MODELS: eleven_multilingual_ttv_v2 (default), eleven_ttv_v3 (newer). ' +
51
51
  'Check status with list_custom_voices. Once READY, use its ID with generate_speech.',
52
52
  inputSchema: z.object({
53
- name: z.string().describe('Name for the voice. Max 100 characters.'),
54
- prompt: z.string().describe('Text description of desired voice. Min 20, max 1000 characters.'),
53
+ name: z.string().min(1).max(100).describe('Name for the voice. Max 100 characters.'),
54
+ prompt: z.string().min(20).max(1000).describe('Text description of desired voice. Min 20, max 1000 characters.'),
55
55
  model: z.enum(['eleven_multilingual_ttv_v2', 'eleven_ttv_v3']).optional().describe('Voice design model. Default: eleven_multilingual_ttv_v2.'),
56
- description: z.string().optional().describe('Optional description for your reference. Max 512 characters.'),
56
+ description: z.string().max(512).optional().describe('Optional description for your reference. Max 512 characters.'),
57
57
  }),
58
58
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
59
59
  }, withErrorHandling(async (args) => {
@@ -75,7 +75,7 @@ export function registerVoiceTools(server) {
75
75
  description: 'Generate a short audio preview of a voice from a text description, without creating it. ' +
76
76
  'Use to audition voice characteristics before committing with create_custom_voice.',
77
77
  inputSchema: z.object({
78
- prompt: z.string().describe('Text description of desired voice. Min 20, max 1000 characters.'),
78
+ prompt: z.string().min(20).max(1000).describe('Text description of desired voice. Min 20, max 1000 characters.'),
79
79
  model: z.enum(['eleven_multilingual_ttv_v2', 'eleven_ttv_v3']).optional().describe('Voice design model. Default: eleven_multilingual_ttv_v2.'),
80
80
  }),
81
81
  annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: true },
@@ -20,14 +20,37 @@
20
20
  */
21
21
  /**
22
22
  * Wrap a single untrusted string in an `<untrusted-content source="…">`
23
- * envelope, escaping any embedded close-tag variant so the envelope cannot be
24
- * broken out of. `undefined` passes through untouched. Idempotent for the same
25
- * `source`.
23
+ * envelope, escaping any embedded open/close-tag variant so the envelope can
24
+ * neither be broken out of nor have a spoofed nested envelope planted inside.
25
+ *
26
+ * `undefined` and `null` are passed through untouched so callers can apply the wrapper
27
+ * uniformly to optional fields without branching.
28
+ *
29
+ * Idempotent: when `text` is already a properly-shaped envelope for the SAME
30
+ * `source` (starts with the matching OPEN tag, ends with CLOSE, and contains no
31
+ * internal open/close-tag variants), the original string is returned unchanged so
32
+ * `wrapUntrusted(wrapUntrusted(s, src), src) === wrapUntrusted(s, src)`.
26
33
  */
27
- export declare function wrapUntrusted(text: string | undefined, source: string): string | undefined;
34
+ export declare function wrapUntrusted(text: string | null | undefined, source: string): string | undefined;
28
35
  /**
29
- * Recursively wrap every string value reachable inside `value`. Object keys are
30
- * structural and NOT wrapped; non-string leaves pass through unchanged.
36
+ * Strip one `<untrusted-content>` envelope from `text` if present, returning raw
37
+ * strings unchanged. This is intentionally one-layer and idempotent for already
38
+ * raw input so callers can accept either displayed wrapped content or manually
39
+ * authored content.
40
+ */
41
+ export declare function unwrapUntrusted(text: string): string;
42
+ /**
43
+ * Recursively wrap every string key and value reachable inside `value` (strings,
44
+ * arrays, plain-object property keys and values) in an `<untrusted-content>` envelope.
45
+ *
46
+ * Use this when a whole response blob is third-party data and you want to
47
+ * envelope it wholesale rather than enumerate fields. Non-string leaves (numbers,
48
+ * booleans, null) pass through unchanged.
31
49
  */
32
50
  export declare function wrapUntrustedJsonStrings<T>(value: T, source: string): T;
51
+ /**
52
+ * Recursively unwrap every string key and value reachable inside `value`.
53
+ * Non-string leaves pass through unchanged.
54
+ */
55
+ export declare function unwrapUntrustedJsonStrings<T>(value: T): T;
33
56
  //# sourceMappingURL=untrusted-content.d.ts.map
@@ -18,38 +18,80 @@
18
18
  * `untrusted-content` in any connector that talks to an external system; this
19
19
  * file (and the call sites that import from it) is what satisfies that gate.
20
20
  */
21
- const UNTRUSTED_CLOSE_TAG_VARIANT = /<\/untrusted-content\s*>/gi;
22
- const ESCAPED_UNTRUSTED_CLOSE_TAG = '<\\/untrusted-content>';
21
+ // Only the `<` + tag-name prefix is matched. Whitespace, `/` or `>` after the
22
+ // name ends it, so `</untrusted-content/>` and `<untrusted-content/source="x">`
23
+ // read as tags too; the rest of the tag is left as text. Matching never scans
24
+ // ahead for a `>`, so it stays linear on hostile input and nothing in the
25
+ // attributes can evade it. Escaping inserts one `\` after the `<`
26
+ // (`<\untrusted-content`, `<\/untrusted-content`); a prefix that already
27
+ // carries backslashes gains one more, so unwrapping restores the text exactly.
28
+ const UNTRUSTED_TAG_PREFIX = /<(\\*)(\/?untrusted-content)(?=[\s/>])/gi;
29
+ const ESCAPED_UNTRUSTED_TAG_PREFIX = /<\\(\\*)(\/?untrusted-content)(?=[\s/>])/gi;
30
+ const RAW_UNTRUSTED_TAG_PREFIX = /<\/?untrusted-content(?=[\s/>])/i;
31
+ const UNTRUSTED_ENVELOPE = /^<untrusted-content source="[^"]*">([\s\S]*)<\/untrusted-content>$/;
23
32
  function escapeAttr(s) {
24
33
  return s.replaceAll('&', '&amp;').replaceAll('"', '&quot;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
25
34
  }
26
- function escapeCloseTagSentinels(s) {
27
- return s.replace(UNTRUSTED_CLOSE_TAG_VARIANT, ESCAPED_UNTRUSTED_CLOSE_TAG);
35
+ /**
36
+ * Neutralise every `</untrusted-content …>` and `<untrusted-content …>` variant
37
+ * (case-insensitive; whitespace, `/`, attributes or `>` after the name) inside
38
+ * `s` by escaping its tag-name prefix, so an attacker who controls the wrapped
39
+ * content can neither terminate the envelope early nor spoof a nested open tag
40
+ * that a downstream parser could re-read as a fresh envelope. An LLM parsing
41
+ * the markup plausibly accepts attribute-bearing close forms such as
42
+ * `</untrusted-content foo>` — escaping the prefix covers them whatever follows.
43
+ */
44
+ function escapeTagSentinels(s) {
45
+ return s.replace(UNTRUSTED_TAG_PREFIX, '<\\$1$2');
46
+ }
47
+ function unescapeTagSentinels(s) {
48
+ return s.replace(ESCAPED_UNTRUSTED_TAG_PREFIX, '<$1$2');
28
49
  }
29
50
  /**
30
51
  * Wrap a single untrusted string in an `<untrusted-content source="…">`
31
- * envelope, escaping any embedded close-tag variant so the envelope cannot be
32
- * broken out of. `undefined` passes through untouched. Idempotent for the same
33
- * `source`.
52
+ * envelope, escaping any embedded open/close-tag variant so the envelope can
53
+ * neither be broken out of nor have a spoofed nested envelope planted inside.
54
+ *
55
+ * `undefined` and `null` are passed through untouched so callers can apply the wrapper
56
+ * uniformly to optional fields without branching.
57
+ *
58
+ * Idempotent: when `text` is already a properly-shaped envelope for the SAME
59
+ * `source` (starts with the matching OPEN tag, ends with CLOSE, and contains no
60
+ * internal open/close-tag variants), the original string is returned unchanged so
61
+ * `wrapUntrusted(wrapUntrusted(s, src), src) === wrapUntrusted(s, src)`.
34
62
  */
35
63
  export function wrapUntrusted(text, source) {
36
- if (text === undefined)
64
+ if (text === undefined || text === null)
37
65
  return undefined;
38
66
  const open = `<untrusted-content source="${escapeAttr(source)}">`;
39
67
  const close = '</untrusted-content>';
40
68
  if (text.startsWith(open) && text.endsWith(close) && text.length >= open.length + close.length) {
41
69
  const inner = text.slice(open.length, text.length - close.length);
42
- if (!UNTRUSTED_CLOSE_TAG_VARIANT.test(inner)) {
43
- UNTRUSTED_CLOSE_TAG_VARIANT.lastIndex = 0;
70
+ if (!RAW_UNTRUSTED_TAG_PREFIX.test(inner)) {
44
71
  return text;
45
72
  }
46
- UNTRUSTED_CLOSE_TAG_VARIANT.lastIndex = 0;
47
73
  }
48
- return `${open}${escapeCloseTagSentinels(text)}${close}`;
74
+ return `${open}${escapeTagSentinels(text)}${close}`;
49
75
  }
50
76
  /**
51
- * Recursively wrap every string value reachable inside `value`. Object keys are
52
- * structural and NOT wrapped; non-string leaves pass through unchanged.
77
+ * Strip one `<untrusted-content>` envelope from `text` if present, returning raw
78
+ * strings unchanged. This is intentionally one-layer and idempotent for already
79
+ * raw input so callers can accept either displayed wrapped content or manually
80
+ * authored content.
81
+ */
82
+ export function unwrapUntrusted(text) {
83
+ const match = UNTRUSTED_ENVELOPE.exec(text);
84
+ if (!match)
85
+ return text;
86
+ return unescapeTagSentinels(match[1]);
87
+ }
88
+ /**
89
+ * Recursively wrap every string key and value reachable inside `value` (strings,
90
+ * arrays, plain-object property keys and values) in an `<untrusted-content>` envelope.
91
+ *
92
+ * Use this when a whole response blob is third-party data and you want to
93
+ * envelope it wholesale rather than enumerate fields. Non-string leaves (numbers,
94
+ * booleans, null) pass through unchanged.
53
95
  */
54
96
  export function wrapUntrustedJsonStrings(value, source) {
55
97
  if (typeof value === 'string') {
@@ -59,7 +101,29 @@ export function wrapUntrustedJsonStrings(value, source) {
59
101
  return value.map((item) => wrapUntrustedJsonStrings(item, source));
60
102
  }
61
103
  if (value && typeof value === 'object') {
62
- return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, wrapUntrustedJsonStrings(item, source)]));
104
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [
105
+ wrapUntrusted(key, source) ?? key,
106
+ wrapUntrustedJsonStrings(item, source),
107
+ ]));
108
+ }
109
+ return value;
110
+ }
111
+ /**
112
+ * Recursively unwrap every string key and value reachable inside `value`.
113
+ * Non-string leaves pass through unchanged.
114
+ */
115
+ export function unwrapUntrustedJsonStrings(value) {
116
+ if (typeof value === 'string') {
117
+ return unwrapUntrusted(value);
118
+ }
119
+ if (Array.isArray(value)) {
120
+ return value.map((item) => unwrapUntrustedJsonStrings(item));
121
+ }
122
+ if (value && typeof value === 'object') {
123
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [
124
+ unwrapUntrusted(key),
125
+ unwrapUntrustedJsonStrings(item),
126
+ ]));
63
127
  }
64
128
  return value;
65
129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindstone/mcp-server-runway",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "mcpName": "io.github.mindstone/mcp-server-runway",
5
5
  "description": "Runway ML MCP server for Model Context Protocol hosts — AI video, image, audio generation, custom voices, task management",
6
6
  "license": "FSL-1.1-MIT",