@mindstone/mcp-server-runway 0.3.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/LICENSE +97 -0
- package/README.md +119 -0
- package/dist/auth.d.ts +21 -0
- package/dist/auth.js +29 -0
- package/dist/bridge.d.ts +16 -0
- package/dist/bridge.js +43 -0
- package/dist/client.d.ts +82 -0
- package/dist/client.js +562 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +30 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.js +20 -0
- package/dist/tools/account.d.ts +3 -0
- package/dist/tools/account.js +71 -0
- package/dist/tools/audio.d.ts +3 -0
- package/dist/tools/audio.js +138 -0
- package/dist/tools/configure.d.ts +3 -0
- package/dist/tools/configure.js +46 -0
- package/dist/tools/image.d.ts +3 -0
- package/dist/tools/image.js +52 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.js +8 -0
- package/dist/tools/tasks.d.ts +3 -0
- package/dist/tools/tasks.js +370 -0
- package/dist/tools/video.d.ts +3 -0
- package/dist/tools/video.js +168 -0
- package/dist/tools/voices.d.ts +3 -0
- package/dist/tools/voices.js +85 -0
- package/dist/types.d.ts +117 -0
- package/dist/types.js +123 -0
- package/dist/utils.d.ts +14 -0
- package/dist/utils.js +42 -0
- package/package.json +54 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export declare const RUNWAY_API_BASE = "https://api.dev.runwayml.com/v1";
|
|
2
|
+
export declare const RUNWAY_API_VERSION = "2024-11-06";
|
|
3
|
+
/**
|
|
4
|
+
* Default timeout (ms) for outbound HTTP requests (API + bridge).
|
|
5
|
+
*
|
|
6
|
+
* Runway video generation is async via task polling, so individual HTTP
|
|
7
|
+
* calls (submit + poll) should complete in <5s. The 60s default gives
|
|
8
|
+
* headroom for occasional slow submits under load while still surfacing
|
|
9
|
+
* real upstream outages. Override via `RUNWAY_REQUEST_TIMEOUT_MS`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_REQUEST_TIMEOUT_MS = 60000;
|
|
12
|
+
/**
|
|
13
|
+
* Sanity ceiling on configured timeouts. 30 minutes catches accidental
|
|
14
|
+
* extra zeros in env values.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MAX_REQUEST_TIMEOUT_MS: number;
|
|
17
|
+
/**
|
|
18
|
+
* Timeout (ms) for outbound requests. Reads `RUNWAY_REQUEST_TIMEOUT_MS`
|
|
19
|
+
* at call time, falling back to `DEFAULT_REQUEST_TIMEOUT_MS`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getRequestTimeoutMs(): number;
|
|
22
|
+
/**
|
|
23
|
+
* Default timeout (ms) for the signed-URL upload in `uploadEphemeral`.
|
|
24
|
+
*
|
|
25
|
+
* Calibrated for large (up to 200MB) file uploads rather than quick
|
|
26
|
+
* JSON API calls. A 200MB upload at 5 Mbps takes ~5.3 min before
|
|
27
|
+
* TLS handshake / multipart overhead, so 10 min gives comfortable
|
|
28
|
+
* headroom for typical consumer uplinks. Slower links (or larger files
|
|
29
|
+
* in the future) can raise via `RUNWAY_UPLOAD_TIMEOUT_MS`; the 30-min
|
|
30
|
+
* `MAX_REQUEST_TIMEOUT_MS` ceiling still applies.
|
|
31
|
+
*/
|
|
32
|
+
export declare const DEFAULT_UPLOAD_TIMEOUT_MS = 600000;
|
|
33
|
+
/**
|
|
34
|
+
* Timeout (ms) for the signed-URL upload leg of `uploadEphemeral`.
|
|
35
|
+
* Reads `RUNWAY_UPLOAD_TIMEOUT_MS` at call time, falling back to
|
|
36
|
+
* `DEFAULT_UPLOAD_TIMEOUT_MS`. Validated via the same `parseTimeoutEnv`
|
|
37
|
+
* (positive integer, <= 30 min ceiling).
|
|
38
|
+
*/
|
|
39
|
+
export declare function getUploadTimeoutMs(): number;
|
|
40
|
+
export interface BridgeState {
|
|
41
|
+
port: number;
|
|
42
|
+
token: string;
|
|
43
|
+
}
|
|
44
|
+
export declare class RunwayError extends Error {
|
|
45
|
+
readonly code: string;
|
|
46
|
+
readonly resolution: string;
|
|
47
|
+
constructor(message: string, code: string, resolution: string);
|
|
48
|
+
}
|
|
49
|
+
export interface TaskResponse {
|
|
50
|
+
id: string;
|
|
51
|
+
}
|
|
52
|
+
export interface TaskDetail {
|
|
53
|
+
id: string;
|
|
54
|
+
status: 'PENDING' | 'THROTTLED' | 'RUNNING' | 'SUCCEEDED' | 'FAILED';
|
|
55
|
+
createdAt: string;
|
|
56
|
+
output?: string[];
|
|
57
|
+
failure?: string;
|
|
58
|
+
failureCode?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface OrgResponse {
|
|
61
|
+
tier: {
|
|
62
|
+
maxMonthlyCreditSpend: number;
|
|
63
|
+
models: Record<string, {
|
|
64
|
+
maxConcurrentGenerations: number;
|
|
65
|
+
maxDailyGenerations: number;
|
|
66
|
+
}>;
|
|
67
|
+
};
|
|
68
|
+
creditBalance: number;
|
|
69
|
+
usage: {
|
|
70
|
+
models: Record<string, {
|
|
71
|
+
dailyGenerations: number;
|
|
72
|
+
}>;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export interface UsageResponse {
|
|
76
|
+
results: Array<{
|
|
77
|
+
date: string;
|
|
78
|
+
usedCredits: Array<{
|
|
79
|
+
model: string;
|
|
80
|
+
amount: number;
|
|
81
|
+
}>;
|
|
82
|
+
}>;
|
|
83
|
+
models: string[];
|
|
84
|
+
}
|
|
85
|
+
export interface VoiceItem {
|
|
86
|
+
id: string;
|
|
87
|
+
name: string;
|
|
88
|
+
description?: string;
|
|
89
|
+
createdAt: string;
|
|
90
|
+
status: string;
|
|
91
|
+
}
|
|
92
|
+
export interface VoiceListResponse {
|
|
93
|
+
data: VoiceItem[];
|
|
94
|
+
hasMore: boolean;
|
|
95
|
+
nextCursor?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface VoicePreviewResponse {
|
|
98
|
+
url: string;
|
|
99
|
+
durationSecs: number;
|
|
100
|
+
}
|
|
101
|
+
export interface UploadResponse {
|
|
102
|
+
uploadUrl: string;
|
|
103
|
+
fields: Record<string, string>;
|
|
104
|
+
runwayUri: string;
|
|
105
|
+
}
|
|
106
|
+
export declare const MIME_MAP: Record<string, string>;
|
|
107
|
+
/** Data URI size limits (binary, before base64 expansion) */
|
|
108
|
+
export declare const DATA_URI_BINARY_LIMITS: Record<string, number>;
|
|
109
|
+
export declare const MAX_UPLOAD_BYTES: number;
|
|
110
|
+
export declare const MIN_UPLOAD_BYTES = 512;
|
|
111
|
+
export declare const VOICE_PRESETS: readonly ["Maya", "Arjun", "Serene", "Bernard", "Billy", "Mark", "Clint", "Mabel", "Chad", "Leslie", "Eleanor", "Elias", "Elliot", "Grungle", "Brodie", "Sandra", "Kirk", "Kylie", "Lara", "Lisa", "Malachi", "Marlene", "Martin", "Miriam", "Monster", "Paula", "Pip", "Rusty", "Ragnar", "Xylar", "Maggie", "Jack", "Katie", "Noah", "James", "Rina", "Ella", "Mariah", "Frank", "Claudia", "Niki", "Vincent", "Kendrick", "Myrna", "Tom", "Wanda", "Benjamin", "Kiana", "Rachel"];
|
|
112
|
+
export declare const DUBBING_LANGUAGES: readonly ["en", "hi", "pt", "zh", "es", "fr", "de", "ja", "ar", "ru", "ko", "id", "it", "nl", "tr", "pl", "sv", "fil", "ms", "ro", "uk", "el", "cs", "da", "fi", "bg", "hr", "sk", "ta"];
|
|
113
|
+
/**
|
|
114
|
+
* Resolve an error status code to an actionable resolution string.
|
|
115
|
+
*/
|
|
116
|
+
export declare function getErrorResolution(status: number): string;
|
|
117
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
export const RUNWAY_API_BASE = 'https://api.dev.runwayml.com/v1';
|
|
2
|
+
export const RUNWAY_API_VERSION = '2024-11-06';
|
|
3
|
+
/**
|
|
4
|
+
* Default timeout (ms) for outbound HTTP requests (API + bridge).
|
|
5
|
+
*
|
|
6
|
+
* Runway video generation is async via task polling, so individual HTTP
|
|
7
|
+
* calls (submit + poll) should complete in <5s. The 60s default gives
|
|
8
|
+
* headroom for occasional slow submits under load while still surfacing
|
|
9
|
+
* real upstream outages. Override via `RUNWAY_REQUEST_TIMEOUT_MS`.
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_REQUEST_TIMEOUT_MS = 60_000;
|
|
12
|
+
/**
|
|
13
|
+
* Sanity ceiling on configured timeouts. 30 minutes catches accidental
|
|
14
|
+
* extra zeros in env values.
|
|
15
|
+
*/
|
|
16
|
+
export const MAX_REQUEST_TIMEOUT_MS = 30 * 60 * 1000;
|
|
17
|
+
function parseTimeoutEnv(envVarName, fallbackMs) {
|
|
18
|
+
const raw = process.env[envVarName];
|
|
19
|
+
if (raw === undefined || raw === '')
|
|
20
|
+
return fallbackMs;
|
|
21
|
+
const parsed = Number(raw);
|
|
22
|
+
if (!Number.isFinite(parsed) || !Number.isInteger(parsed) || parsed <= 0) {
|
|
23
|
+
console.error(`[Runway] Ignoring invalid ${envVarName}=${JSON.stringify(raw)} (expected positive integer ms); using default ${fallbackMs}`);
|
|
24
|
+
return fallbackMs;
|
|
25
|
+
}
|
|
26
|
+
if (parsed > MAX_REQUEST_TIMEOUT_MS) {
|
|
27
|
+
console.error(`[Runway] Ignoring ${envVarName}=${parsed} (exceeds max ${MAX_REQUEST_TIMEOUT_MS}ms); using default ${fallbackMs}`);
|
|
28
|
+
return fallbackMs;
|
|
29
|
+
}
|
|
30
|
+
return parsed;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Timeout (ms) for outbound requests. Reads `RUNWAY_REQUEST_TIMEOUT_MS`
|
|
34
|
+
* at call time, falling back to `DEFAULT_REQUEST_TIMEOUT_MS`.
|
|
35
|
+
*/
|
|
36
|
+
export function getRequestTimeoutMs() {
|
|
37
|
+
return parseTimeoutEnv('RUNWAY_REQUEST_TIMEOUT_MS', DEFAULT_REQUEST_TIMEOUT_MS);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Default timeout (ms) for the signed-URL upload in `uploadEphemeral`.
|
|
41
|
+
*
|
|
42
|
+
* Calibrated for large (up to 200MB) file uploads rather than quick
|
|
43
|
+
* JSON API calls. A 200MB upload at 5 Mbps takes ~5.3 min before
|
|
44
|
+
* TLS handshake / multipart overhead, so 10 min gives comfortable
|
|
45
|
+
* headroom for typical consumer uplinks. Slower links (or larger files
|
|
46
|
+
* in the future) can raise via `RUNWAY_UPLOAD_TIMEOUT_MS`; the 30-min
|
|
47
|
+
* `MAX_REQUEST_TIMEOUT_MS` ceiling still applies.
|
|
48
|
+
*/
|
|
49
|
+
export const DEFAULT_UPLOAD_TIMEOUT_MS = 600_000; // 10 min
|
|
50
|
+
/**
|
|
51
|
+
* Timeout (ms) for the signed-URL upload leg of `uploadEphemeral`.
|
|
52
|
+
* Reads `RUNWAY_UPLOAD_TIMEOUT_MS` at call time, falling back to
|
|
53
|
+
* `DEFAULT_UPLOAD_TIMEOUT_MS`. Validated via the same `parseTimeoutEnv`
|
|
54
|
+
* (positive integer, <= 30 min ceiling).
|
|
55
|
+
*/
|
|
56
|
+
export function getUploadTimeoutMs() {
|
|
57
|
+
return parseTimeoutEnv('RUNWAY_UPLOAD_TIMEOUT_MS', DEFAULT_UPLOAD_TIMEOUT_MS);
|
|
58
|
+
}
|
|
59
|
+
export class RunwayError extends Error {
|
|
60
|
+
code;
|
|
61
|
+
resolution;
|
|
62
|
+
constructor(message, code, resolution) {
|
|
63
|
+
super(message);
|
|
64
|
+
this.code = code;
|
|
65
|
+
this.resolution = resolution;
|
|
66
|
+
this.name = 'RunwayError';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
// MIME & size limits
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
export const MIME_MAP = {
|
|
73
|
+
png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', gif: 'image/gif',
|
|
74
|
+
webp: 'image/webp', bmp: 'image/bmp',
|
|
75
|
+
mp4: 'video/mp4', mov: 'video/quicktime', webm: 'video/webm', avi: 'video/x-msvideo',
|
|
76
|
+
mkv: 'video/x-matroska', '3gp': 'video/3gpp',
|
|
77
|
+
mp3: 'audio/mpeg', wav: 'audio/wav', ogg: 'audio/ogg', m4a: 'audio/mp4',
|
|
78
|
+
aac: 'audio/aac', flac: 'audio/flac',
|
|
79
|
+
};
|
|
80
|
+
/** Data URI size limits (binary, before base64 expansion) */
|
|
81
|
+
export const DATA_URI_BINARY_LIMITS = {
|
|
82
|
+
image: 3_300_000,
|
|
83
|
+
video: 12_000_000,
|
|
84
|
+
audio: 12_000_000,
|
|
85
|
+
};
|
|
86
|
+
export const MAX_UPLOAD_BYTES = 200 * 1_048_576;
|
|
87
|
+
export const MIN_UPLOAD_BYTES = 512;
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// Voice presets and language constants
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
export const VOICE_PRESETS = [
|
|
92
|
+
'Maya', 'Arjun', 'Serene', 'Bernard', 'Billy', 'Mark', 'Clint', 'Mabel',
|
|
93
|
+
'Chad', 'Leslie', 'Eleanor', 'Elias', 'Elliot', 'Grungle', 'Brodie',
|
|
94
|
+
'Sandra', 'Kirk', 'Kylie', 'Lara', 'Lisa', 'Malachi', 'Marlene', 'Martin',
|
|
95
|
+
'Miriam', 'Monster', 'Paula', 'Pip', 'Rusty', 'Ragnar', 'Xylar', 'Maggie',
|
|
96
|
+
'Jack', 'Katie', 'Noah', 'James', 'Rina', 'Ella', 'Mariah', 'Frank',
|
|
97
|
+
'Claudia', 'Niki', 'Vincent', 'Kendrick', 'Myrna', 'Tom', 'Wanda',
|
|
98
|
+
'Benjamin', 'Kiana', 'Rachel',
|
|
99
|
+
];
|
|
100
|
+
export const DUBBING_LANGUAGES = [
|
|
101
|
+
'en', 'hi', 'pt', 'zh', 'es', 'fr', 'de', 'ja', 'ar', 'ru', 'ko', 'id',
|
|
102
|
+
'it', 'nl', 'tr', 'pl', 'sv', 'fil', 'ms', 'ro', 'uk', 'el', 'cs', 'da',
|
|
103
|
+
'fi', 'bg', 'hr', 'sk', 'ta',
|
|
104
|
+
];
|
|
105
|
+
/**
|
|
106
|
+
* Resolve an error status code to an actionable resolution string.
|
|
107
|
+
*/
|
|
108
|
+
export function getErrorResolution(status) {
|
|
109
|
+
if (status === 401) {
|
|
110
|
+
return 'Authentication failed. Check your Runway API key. Get one at https://dev.runwayml.com/';
|
|
111
|
+
}
|
|
112
|
+
if (status === 403) {
|
|
113
|
+
return 'Access forbidden. Check your Runway API key and account permissions.';
|
|
114
|
+
}
|
|
115
|
+
if (status === 404) {
|
|
116
|
+
return 'The resource does not exist or was deleted.';
|
|
117
|
+
}
|
|
118
|
+
if (status === 429) {
|
|
119
|
+
return 'Rate limited. Wait a moment and try again.';
|
|
120
|
+
}
|
|
121
|
+
return 'Try again or check https://dev.runwayml.com/';
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=types.js.map
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
type ToolHandler<T> = (args: T, extra: unknown) => Promise<CallToolResult>;
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a tool handler with standard error handling.
|
|
5
|
+
*
|
|
6
|
+
* - On success: returns the string result as a text content block.
|
|
7
|
+
* - On RunwayError: returns a structured JSON error with code and resolution.
|
|
8
|
+
* - On unknown error: returns a generic error message.
|
|
9
|
+
*
|
|
10
|
+
* Secrets are never exposed in error messages.
|
|
11
|
+
*/
|
|
12
|
+
export declare function withErrorHandling<T>(fn: (args: T, extra: unknown) => Promise<string>): ToolHandler<T>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { RunwayError } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a tool handler with standard error handling.
|
|
4
|
+
*
|
|
5
|
+
* - On success: returns the string result as a text content block.
|
|
6
|
+
* - On RunwayError: returns a structured JSON error with code and resolution.
|
|
7
|
+
* - On unknown error: returns a generic error message.
|
|
8
|
+
*
|
|
9
|
+
* Secrets are never exposed in error messages.
|
|
10
|
+
*/
|
|
11
|
+
export function withErrorHandling(fn) {
|
|
12
|
+
return async (args, extra) => {
|
|
13
|
+
try {
|
|
14
|
+
const result = await fn(args, extra);
|
|
15
|
+
return { content: [{ type: 'text', text: result }] };
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (error instanceof RunwayError) {
|
|
19
|
+
return {
|
|
20
|
+
content: [
|
|
21
|
+
{
|
|
22
|
+
type: 'text',
|
|
23
|
+
text: JSON.stringify({
|
|
24
|
+
ok: false,
|
|
25
|
+
error: error.message,
|
|
26
|
+
code: error.code,
|
|
27
|
+
resolution: error.resolution,
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
isError: true,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: 'text', text: JSON.stringify({ ok: false, error: errorMessage }) }],
|
|
37
|
+
isError: true,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=utils.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mindstone/mcp-server-runway",
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"mcpName": "io.github.mindstone/mcp-server-runway",
|
|
5
|
+
"description": "Runway ML MCP server for Model Context Protocol hosts \u2014 AI video, image, audio generation, custom voices, task management",
|
|
6
|
+
"license": "FSL-1.1-MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"mcp-server-runway": "dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"!dist/**/*.map"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/mindstone/mcp-servers.git",
|
|
18
|
+
"directory": "connectors/runway"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/mindstone/mcp-servers/tree/main/connectors/runway",
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc && shx chmod +x dist/index.js",
|
|
26
|
+
"prepare": "npm run build",
|
|
27
|
+
"watch": "tsc --watch",
|
|
28
|
+
"start": "node dist/index.js",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"test:watch": "vitest",
|
|
31
|
+
"test:coverage": "vitest run --coverage"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
35
|
+
"zod": "^3.23.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@mindstone/mcp-test-harness": "file:../../test-harness",
|
|
39
|
+
"@types/node": "^22",
|
|
40
|
+
"@vitest/coverage-v8": "^4.1.3",
|
|
41
|
+
"msw": "^2.13.2",
|
|
42
|
+
"shx": "^0.3.4",
|
|
43
|
+
"typescript": "^5.8.2",
|
|
44
|
+
"vitest": "^4.1.3"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=20.3.0"
|
|
48
|
+
},
|
|
49
|
+
"overrides": {
|
|
50
|
+
"fast-uri": "^3.1.2",
|
|
51
|
+
"hono": "^4.12.18",
|
|
52
|
+
"ip-address": "^10.2.0"
|
|
53
|
+
}
|
|
54
|
+
}
|