@mindstone/mcp-server-runway 0.7.0 → 0.8.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,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.7.0](./CHANGELOG.md) · [npm](https://www.npmjs.com/package/@mindstone/mcp-server-runway)
10
+ - **Version:** [0.8.0](./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
@@ -180,3 +180,7 @@ list, stops the read.
180
180
  Clients that do not negotiate this extension keep the connector's existing
181
181
  standalone file restrictions. This extension changes input-read permissions;
182
182
  existing output destinations, upload formats, size limits and file checks apply.
183
+
184
+ ### Host-authorised local saves
185
+
186
+ When a host negotiates experimental `files/writeModes` version 1, declared save destinations use the canonical file or parent folder authorised for that concrete argument in the call's `files/writeMode` metadata. The host's path permissions apply instead of the connector's standalone path policy. File type, size, identity, exclusive-create and overwrite mechanics still apply. Clients that do not negotiate this protocol, or select standalone mode, retain the existing sandbox.
package/dist/client.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type FileWriteContext } from './file-write-context.js';
1
2
  import { type FileReadContext } from './file-read-context.js';
2
3
  /** Envelope source label for Runway-authored text (error bodies, task failures). */
3
4
  export declare const RUNWAY_API_SOURCE = "runway-api";
@@ -27,7 +28,7 @@ export declare function assertPathInAllowedRoot(input: string): string;
27
28
  * directory if missing so the default `~/Downloads/runway-mcp` works
28
29
  * out-of-the-box.
29
30
  */
30
- export declare function assertDownloadPathInRoot(outputPath: string): {
31
+ export declare function assertDownloadPathInRoot(outputPath: string, context?: FileWriteContext): {
31
32
  resolved: string;
32
33
  root: string;
33
34
  };
package/dist/client.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { centralWritePath, isAuthorisedWriteParent } from './file-write-context.js';
1
2
  import { centralReadPath } from './file-read-context.js';
2
3
  /**
3
4
  * Runway API HTTP client.
@@ -190,44 +191,56 @@ function isPathInDenyList(resolvedAbs) {
190
191
  * directory if missing so the default `~/Downloads/runway-mcp` works
191
192
  * out-of-the-box.
192
193
  */
193
- export function assertDownloadPathInRoot(outputPath) {
194
- const lexicalRoot = getDownloadRoot();
195
- // Auto-create the configured root so the default just works. Tolerate
196
- // failures here — they'll surface later when we try to canonicalise it.
197
- try {
198
- fs.mkdirSync(lexicalRoot, { recursive: true });
199
- }
200
- catch {
201
- /* tolerate; realpath below will fail with a clear error */
202
- }
203
- const realRoot = fs.realpathSync(lexicalRoot);
204
- const lexical = path.resolve(outputPath);
205
- const lexicalParent = path.dirname(lexical);
206
- const denyMessage = `Output path is outside the RUNWAY_DOWNLOAD_ROOT sandbox: ${outputPath}`;
207
- const denyResolution = `Set ${RUNWAY_DOWNLOAD_ROOT_ENV} to a directory that contains the target file, ` +
208
- `or pick an output_path inside ${realRoot}.`;
209
- const isUnder = (p, root) => p === root || p.startsWith(root + path.sep);
210
- // (1) Lexical check — catches `..` traversal and "completely outside"
211
- // paths regardless of filesystem state.
212
- if (!isUnder(lexicalParent, lexicalRoot) && !isUnder(lexicalParent, realRoot)) {
213
- throw new RunwayError(denyMessage, 'OUTPUT_OUTSIDE_DOWNLOAD_ROOT', denyResolution);
214
- }
215
- // (2) Realpath check on the parent dir — catches symlink-escape.
216
- let realParent;
217
- try {
218
- realParent = fs.realpathSync(lexicalParent);
219
- }
220
- catch {
221
- throw new RunwayError(`Parent directory does not exist or is not accessible: ${lexicalParent}`, 'OUTPUT_PARENT_NOT_FOUND', `Create ${lexicalParent} first, or pick an output_path inside ${realRoot}.`);
222
- }
223
- if (!isUnder(realParent, realRoot)) {
224
- throw new RunwayError(denyMessage, 'OUTPUT_OUTSIDE_DOWNLOAD_ROOT', denyResolution);
194
+ export function assertDownloadPathInRoot(outputPath, context) {
195
+ const allowed = centralWritePath(context, outputPath, ['output_path']);
196
+ let resolved;
197
+ let realRoot;
198
+ if (allowed === undefined) {
199
+ const lexicalRoot = getDownloadRoot();
200
+ // Auto-create the configured root so the default just works. Tolerate
201
+ // failures here — they'll surface later when we try to canonicalise it.
202
+ try {
203
+ fs.mkdirSync(lexicalRoot, { recursive: true });
204
+ }
205
+ catch {
206
+ /* tolerate; realpath below will fail with a clear error */
207
+ }
208
+ realRoot = fs.realpathSync(lexicalRoot);
209
+ const lexical = path.resolve(outputPath);
210
+ const lexicalParent = path.dirname(lexical);
211
+ const denyMessage = `Output path is outside the RUNWAY_DOWNLOAD_ROOT sandbox: ${outputPath}`;
212
+ const denyResolution = `Set ${RUNWAY_DOWNLOAD_ROOT_ENV} to a directory that contains the target file, ` +
213
+ `or pick an output_path inside ${realRoot}.`;
214
+ const isUnder = (p, root) => p === root || p.startsWith(root + path.sep);
215
+ // (1) Lexical check — catches `..` traversal and "completely outside"
216
+ // paths regardless of filesystem state.
217
+ if (!isUnder(lexicalParent, lexicalRoot) && !isUnder(lexicalParent, realRoot)) {
218
+ throw new RunwayError(denyMessage, 'OUTPUT_OUTSIDE_DOWNLOAD_ROOT', denyResolution);
219
+ }
220
+ // (2) Realpath check on the parent dir — catches symlink-escape.
221
+ let realParent;
222
+ try {
223
+ realParent = fs.realpathSync(lexicalParent);
224
+ }
225
+ catch {
226
+ throw new RunwayError(`Parent directory does not exist or is not accessible: ${lexicalParent}`, 'OUTPUT_PARENT_NOT_FOUND', `Create ${lexicalParent} first, or pick an output_path inside ${realRoot}.`);
227
+ }
228
+ if (!isUnder(realParent, realRoot)) {
229
+ throw new RunwayError(denyMessage, 'OUTPUT_OUTSIDE_DOWNLOAD_ROOT', denyResolution);
230
+ }
231
+ resolved = path.join(realParent, path.basename(lexical));
232
+ // (3) Static deny-list — applies even when nominally inside the root.
233
+ const denied = isPathInDenyList(resolved);
234
+ if (denied.hit) {
235
+ throw new RunwayError(`Output path matches the sensitive deny-list and is refused: ${outputPath}`, 'OUTPUT_PATH_DENY_LISTED', `Refused: ${denied.reason}. Paths under ~/.ssh, ~/.aws, /etc, and shell rc files (~/.bashrc, ~/.zshrc) cannot be overwritten by Runway downloads even when ${RUNWAY_DOWNLOAD_ROOT_ENV} would otherwise permit it.`);
236
+ }
225
237
  }
226
- const resolved = path.join(realParent, path.basename(lexical));
227
- // (3) Static deny-list — applies even when nominally inside the root.
228
- const denied = isPathInDenyList(resolved);
229
- if (denied.hit) {
230
- throw new RunwayError(`Output path matches the sensitive deny-list and is refused: ${outputPath}`, 'OUTPUT_PATH_DENY_LISTED', `Refused: ${denied.reason}. Paths under ~/.ssh, ~/.aws, /etc, and shell rc files (~/.bashrc, ~/.zshrc) cannot be overwritten by Runway downloads even when ${RUNWAY_DOWNLOAD_ROOT_ENV} would otherwise permit it.`);
238
+ else {
239
+ resolved = allowed;
240
+ realRoot = path.dirname(allowed);
241
+ if (!isAuthorisedWriteParent(realRoot)) {
242
+ throw new RunwayError(`Authorised parent directory is missing, inaccessible or changed: ${realRoot}`, 'OUTPUT_PARENT_NOT_FOUND', 'Create the destination folder if needed, then retry the call to authorise it again.');
243
+ }
231
244
  }
232
245
  // (4) Refuse to write through a non-regular-file existing target.
233
246
  //
@@ -0,0 +1,73 @@
1
+ import { z } from 'zod';
2
+ /** Negotiation is connection-scoped; authority belongs to one SDK request. */
3
+ export declare const FILE_WRITE_CAPABILITIES: {
4
+ experimental: {
5
+ 'files/writeModes': {
6
+ version: number;
7
+ };
8
+ };
9
+ };
10
+ export declare function fileReadWriteCapabilities(readCapabilities: {
11
+ experimental: Record<string, unknown>;
12
+ }, experimental?: Record<string, unknown>): {
13
+ experimental: {
14
+ 'files/writeModes': {
15
+ version: number;
16
+ };
17
+ };
18
+ };
19
+ /** A missing or redirected parent is mapped to the connector's own error. */
20
+ export declare function isAuthorisedWriteParent(parent: string): boolean;
21
+ export declare const writeModeSchema: z.ZodDiscriminatedUnion<"mode", [z.ZodObject<{
22
+ version: z.ZodLiteral<1>;
23
+ mode: z.ZodLiteral<"central">;
24
+ writes: z.ZodArray<z.ZodObject<{
25
+ location: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
26
+ rawPath: z.ZodString;
27
+ canonicalPath: z.ZodEffects<z.ZodString, string, string>;
28
+ target: z.ZodEnum<["file", "parent"]>;
29
+ }, "strict", z.ZodTypeAny, {
30
+ location: (string | number)[];
31
+ rawPath: string;
32
+ canonicalPath: string;
33
+ target: "parent" | "file";
34
+ }, {
35
+ location: (string | number)[];
36
+ rawPath: string;
37
+ canonicalPath: string;
38
+ target: "parent" | "file";
39
+ }>, "many">;
40
+ }, "strict", z.ZodTypeAny, {
41
+ version: 1;
42
+ mode: "central";
43
+ writes: {
44
+ location: (string | number)[];
45
+ rawPath: string;
46
+ canonicalPath: string;
47
+ target: "parent" | "file";
48
+ }[];
49
+ }, {
50
+ version: 1;
51
+ mode: "central";
52
+ writes: {
53
+ location: (string | number)[];
54
+ rawPath: string;
55
+ canonicalPath: string;
56
+ target: "parent" | "file";
57
+ }[];
58
+ }>, z.ZodObject<{
59
+ version: z.ZodLiteral<1>;
60
+ mode: z.ZodLiteral<"standalone">;
61
+ }, "strict", z.ZodTypeAny, {
62
+ version: 1;
63
+ mode: "standalone";
64
+ }, {
65
+ version: 1;
66
+ mode: "standalone";
67
+ }>]>;
68
+ export type FileWriteContext = z.infer<typeof writeModeSchema>;
69
+ /** Pass SDK extra here, never model arguments or arguments._meta. */
70
+ export declare function fileWriteContext(capabilities: unknown, extra: unknown): FileWriteContext;
71
+ /** For parent outputs the canonical path is the authorised folder itself. */
72
+ export declare function centralWritePath(context: FileWriteContext | undefined, rawPath: string, location: (string | number)[], target?: 'file' | 'parent'): string | undefined;
73
+ //# sourceMappingURL=file-write-context.d.ts.map
@@ -0,0 +1,50 @@
1
+ import { z } from 'zod';
2
+ import { isAbsolute } from 'node:path';
3
+ import { realpathSync } from 'node:fs';
4
+ /** Negotiation is connection-scoped; authority belongs to one SDK request. */
5
+ export const FILE_WRITE_CAPABILITIES = { experimental: { 'files/writeModes': { version: 1 } } };
6
+ export function fileReadWriteCapabilities(readCapabilities, experimental = {}) {
7
+ return { experimental: { ...readCapabilities.experimental, ...FILE_WRITE_CAPABILITIES.experimental, ...experimental } };
8
+ }
9
+ /** A missing or redirected parent is mapped to the connector's own error. */
10
+ export function isAuthorisedWriteParent(parent) {
11
+ try {
12
+ return realpathSync(parent) === parent;
13
+ }
14
+ catch {
15
+ return false;
16
+ }
17
+ }
18
+ const locationSchema = z.array(z.union([z.string(), z.number().int().nonnegative()]));
19
+ const allowedWriteSchema = z.object({
20
+ location: locationSchema, rawPath: z.string(), canonicalPath: z.string().refine(isAbsolute),
21
+ target: z.enum(['file', 'parent']),
22
+ }).strict();
23
+ export const writeModeSchema = z.discriminatedUnion('mode', [
24
+ z.object({ version: z.literal(1), mode: z.literal('central'), writes: z.array(allowedWriteSchema) }).strict(),
25
+ z.object({ version: z.literal(1), mode: z.literal('standalone') }).strict(),
26
+ ]);
27
+ const capabilitiesSchema = z.object({ experimental: z.object({
28
+ 'files/writeModes': z.object({ version: z.literal(1) }).passthrough(),
29
+ }).passthrough() }).passthrough();
30
+ const extraSchema = z.object({ _meta: z.object({ 'files/writeMode': writeModeSchema }).passthrough() }).passthrough();
31
+ /** Pass SDK extra here, never model arguments or arguments._meta. */
32
+ export function fileWriteContext(capabilities, extra) {
33
+ if (!capabilitiesSchema.safeParse(capabilities).success)
34
+ return { version: 1, mode: 'standalone' };
35
+ const parsed = extraSchema.safeParse(extra);
36
+ if (!parsed.success)
37
+ throw new Error('Negotiated file writes require valid request files/writeMode metadata.');
38
+ return parsed.data._meta['files/writeMode'];
39
+ }
40
+ /** For parent outputs the canonical path is the authorised folder itself. */
41
+ export function centralWritePath(context, rawPath, location, target = 'file') {
42
+ if (!context || context.mode === 'standalone')
43
+ return undefined;
44
+ const matches = context.writes.filter(write => write.rawPath === rawPath && write.target === target &&
45
+ write.location.length === location.length && write.location.every((part, index) => part === location[index]));
46
+ if (matches.length !== 1)
47
+ throw new Error('Central file write requires exactly one allowed concrete operand.');
48
+ return matches[0].canonicalPath;
49
+ }
50
+ //# sourceMappingURL=file-write-context.js.map
package/dist/server.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { fileReadWriteCapabilities } from './file-write-context.js';
1
2
  import { FILE_READ_CAPABILITIES } from './file-read-context.js';
2
3
  import { createRequire } from 'node:module';
3
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
@@ -19,7 +20,7 @@ export function createServer() {
19
20
  const server = new RunwayMcpServer({
20
21
  name: 'runway-mcp-server',
21
22
  version: pkg.version,
22
- }, { capabilities: FILE_READ_CAPABILITIES });
23
+ }, { capabilities: fileReadWriteCapabilities(FILE_READ_CAPABILITIES) });
23
24
  registerConfigureTools(server);
24
25
  registerVideoTools(server);
25
26
  registerImageTools(server);
@@ -1,7 +1,7 @@
1
1
  import { RunwayError } from '../types.js';
2
2
  import { IMAGE_TO_VIDEO, TEXT_TO_VIDEO, TEXT_TO_IMAGE } from './resold-specs.generated.js';
3
- // Models Runway resells from other makers. Each one rejects request fields it
4
- // does not list (the API's schemas set additionalProperties: false), so the
3
+ // Models Runway resells from other makers. Most of their API schemas reject
4
+ // request fields they do not list (additionalProperties: false), so the
5
5
  // connector sends a resold model only the fields its own spec allows, and
6
6
  // refuses any other option with a plain message naming the model, before any
7
7
  // upload or request. The fields and limits come from Runway's published API
@@ -1,3 +1,4 @@
1
+ import { fileWriteContext } from '../file-write-context.js';
1
2
  import { randomUUID } from 'crypto';
2
3
  import * as path from 'path';
3
4
  import { centralReadPath, fileReadContext } from '../file-read-context.js';
@@ -117,19 +118,21 @@ export function registerTaskTools(server) {
117
118
  }));
118
119
  // ── Download Output ───────────────────────────────────────────────────
119
120
  server.registerTool('download_runway_output', {
121
+ _meta: { 'files/writeOutputs': { version: 1, outputs: [{ selector: ['output_path'], target: 'file', expandTilde: false }] } },
120
122
  description: 'Download a Runway output (video, image, audio) to a local file. ' +
121
123
  'Use after a task succeeds to save the output locally. ' +
122
- 'output_path MUST live inside RUNWAY_DOWNLOAD_ROOT (default ~/Downloads/runway-mcp). ' +
123
- 'Sensitive paths (~/.ssh, ~/.aws, /etc, ~/.bashrc, ~/.zshrc) are refused even when the root would otherwise permit them. ' +
124
+ 'When connected to a host that authorizes file writes, its path permission decision applies to output_path. For standalone clients, output_path MUST live inside RUNWAY_DOWNLOAD_ROOT (default ~/Downloads/runway-mcp). ' +
125
+ 'For standalone clients, sensitive paths (~/.ssh, ~/.aws, /etc, ~/.bashrc, ~/.zshrc) are refused even when the root would otherwise permit them. ' +
124
126
  'By default, refuses to overwrite an existing file (atomic flags: "wx") — pass overwrite: true to replace it. ' +
125
127
  'An overwrite is staged to a temporary file and moved into place only after the download succeeds, so a failed download leaves the existing file untouched.',
126
128
  inputSchema: z.object({
127
129
  url: z.string().describe('Output URL from a completed task.'),
128
- output_path: z.string().describe('Local file path to save to. Must be inside RUNWAY_DOWNLOAD_ROOT (default ~/Downloads/runway-mcp). Parent directory must exist.'),
130
+ output_path: z.string().describe('Local file path to save to. When connected to a host that authorizes file writes, its path permission decision applies. For standalone clients, must be inside RUNWAY_DOWNLOAD_ROOT (default ~/Downloads/runway-mcp). Parent directory must exist.'),
129
131
  overwrite: z.boolean().optional().describe('If true, replace an existing file at output_path once the download succeeds; a failed download keeps the existing file. Defaults to false (refuses to clobber).'),
130
132
  }),
131
133
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
132
- }, withErrorHandling(async (args) => {
134
+ }, withErrorHandling(async (args, extra) => {
135
+ const writes = fileWriteContext(server.server.getClientCapabilities(), extra);
133
136
  const url = args.url;
134
137
  const outputPath = args.output_path;
135
138
  const overwrite = args.overwrite === true;
@@ -147,7 +150,7 @@ export function registerTaskTools(server) {
147
150
  const fs = await import('fs');
148
151
  let safe;
149
152
  try {
150
- safe = assertDownloadPathInRoot(outputPath);
153
+ safe = assertDownloadPathInRoot(outputPath, writes);
151
154
  }
152
155
  catch (err) {
153
156
  if (err instanceof RunwayError) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindstone/mcp-server-runway",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
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",