@tapedock/mcp 0.1.0 → 0.1.1

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.
@@ -23,6 +23,8 @@ export interface DownloadJobSnapshot {
23
23
  startedAtMs: number;
24
24
  completedAtMs: number | null;
25
25
  files: DownloadFileState[];
26
+ /** Local-path DaVinci Resolve timeline, written once the job completes and session.otio is on disk. */
27
+ resolveOtioPath?: string;
26
28
  error?: string;
27
29
  }
28
30
  export interface DownloadSessionInput {
@@ -6,6 +6,7 @@ import * as path from "node:path";
6
6
  import { Readable, Transform } from "node:stream";
7
7
  import { pipeline } from "node:stream/promises";
8
8
  import { buildSessionFolderName, formatBytes } from "../lib/format.js";
9
+ import { buildLocalResolveOtio } from "./resolve-otio.js";
9
10
  export const ALL_DOWNLOAD_CATEGORIES = ["bundle", "audio", "video", "screen"];
10
11
  const SAFE_EXPORT_FILENAME_RE = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;
11
12
  const DEFAULT_AUTO_FOREGROUND_BYTES = 100 * 1024 * 1024; // 100 MB
@@ -14,6 +15,8 @@ const DEFAULT_CONCURRENCY = 2;
14
15
  const MAX_FILE_RETRIES = 3;
15
16
  const PROGRESS_THROTTLE_MS = 1500;
16
17
  const MAX_STORED_JOBS = 50;
18
+ const SESSION_OTIO_FILENAME = "session.otio";
19
+ const RESOLVE_OTIO_FILENAME = "session.resolve.otio";
17
20
  export function resolveDefaultDownloadDir() {
18
21
  const fromEnv = process.env.TAPEDOCK_DOWNLOAD_DIR?.trim() || process.env.VCR_DOWNLOAD_DIR?.trim();
19
22
  if (fromEnv)
@@ -63,6 +66,24 @@ async function abortableSleep(ms, signal) {
63
66
  signal?.addEventListener("abort", onAbort, { once: true });
64
67
  });
65
68
  }
69
+ /**
70
+ * Best-effort: a missing or malformed session.otio must never fail a download that
71
+ * already landed every Track, so any error here just means no Resolve timeline.
72
+ */
73
+ async function writeLocalResolveOtio(targetDir) {
74
+ const resolvePath = path.join(targetDir, RESOLVE_OTIO_FILENAME);
75
+ const tmpPath = `${resolvePath}.${randomBytes(4).toString("hex")}.tmp`;
76
+ try {
77
+ const otioJson = await fs.readFile(path.join(targetDir, SESSION_OTIO_FILENAME), "utf8");
78
+ await fs.writeFile(tmpPath, buildLocalResolveOtio(otioJson, targetDir), { mode: 0o644 });
79
+ await fs.rename(tmpPath, resolvePath);
80
+ return resolvePath;
81
+ }
82
+ catch {
83
+ await fs.unlink(tmpPath).catch(() => { });
84
+ return undefined;
85
+ }
86
+ }
66
87
  class PresignedUrlExpiredError extends Error {
67
88
  failedUrl;
68
89
  constructor(failedUrl) {
@@ -341,6 +362,9 @@ export class DownloadManager {
341
362
  job.downloadedBytes = job.files.reduce((sum, f) => sum + f.downloadedBytes, 0);
342
363
  await emitProgress("Complete", true);
343
364
  finished = true;
365
+ const resolveOtioPath = await writeLocalResolveOtio(job.targetDir);
366
+ if (resolveOtioPath)
367
+ job.resolveOtioPath = resolveOtioPath;
344
368
  job.status = "completed";
345
369
  job.completedAtMs = Date.now();
346
370
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Turn a downloaded `session.otio` into a DaVinci Resolve 21 timeline whose media
3
+ * references point at absolute paths inside `targetDir`, so File → Import → Timeline
4
+ * links every Track without a relink pass. Throws on malformed JSON, a non-Timeline
5
+ * root, or any `target_url` that resolves outside `targetDir`.
6
+ */
7
+ export declare function buildLocalResolveOtio(otioJson: string, targetDir: string): string;
@@ -0,0 +1,68 @@
1
+ import * as path from "node:path";
2
+ const URL_SCHEME_RE = /^[a-z][a-z0-9+.-]*:\/\//i;
3
+ const ITEM_SCHEMAS = new Set(["Stack", "Track", "Clip", "Gap"]);
4
+ function isObject(value) {
5
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6
+ }
7
+ function schemaName(node) {
8
+ const schema = node.OTIO_SCHEMA;
9
+ return typeof schema === "string" ? (schema.split(".")[0] ?? null) : null;
10
+ }
11
+ function localizeTargetUrl(targetUrl, resolvedDir) {
12
+ if (URL_SCHEME_RE.test(targetUrl)) {
13
+ throw new Error(`Non-local target_url rejected: "${targetUrl}"`);
14
+ }
15
+ const resolved = path.resolve(resolvedDir, targetUrl);
16
+ if (!resolved.startsWith(resolvedDir + path.sep)) {
17
+ throw new Error(`Path traversal rejected for target_url "${targetUrl}"`);
18
+ }
19
+ return resolved;
20
+ }
21
+ function normalize(value, resolvedDir) {
22
+ if (Array.isArray(value)) {
23
+ for (const item of value)
24
+ normalize(item, resolvedDir);
25
+ return;
26
+ }
27
+ if (!isObject(value))
28
+ return;
29
+ const schema = schemaName(value);
30
+ if (schema === "Clip") {
31
+ // Legacy Clip.2 carried a single `media_reference`; Resolve 21 only reads the keyed map.
32
+ if ("media_reference" in value && !("media_references" in value)) {
33
+ value.media_references = { DEFAULT_MEDIA: value.media_reference };
34
+ delete value.media_reference;
35
+ }
36
+ if ("media_references" in value) {
37
+ value.active_media_reference_key ??= "DEFAULT_MEDIA";
38
+ }
39
+ }
40
+ if (schema !== null && ITEM_SCHEMAS.has(schema)) {
41
+ value.metadata ??= {};
42
+ value.effects ??= [];
43
+ value.markers ??= [];
44
+ value.enabled ??= true;
45
+ }
46
+ if (schema === "Timeline" || schema === "ExternalReference") {
47
+ value.metadata ??= {};
48
+ }
49
+ if (schema === "ExternalReference" && typeof value.target_url === "string") {
50
+ value.target_url = localizeTargetUrl(value.target_url, resolvedDir);
51
+ }
52
+ for (const child of Object.values(value))
53
+ normalize(child, resolvedDir);
54
+ }
55
+ /**
56
+ * Turn a downloaded `session.otio` into a DaVinci Resolve 21 timeline whose media
57
+ * references point at absolute paths inside `targetDir`, so File → Import → Timeline
58
+ * links every Track without a relink pass. Throws on malformed JSON, a non-Timeline
59
+ * root, or any `target_url` that resolves outside `targetDir`.
60
+ */
61
+ export function buildLocalResolveOtio(otioJson, targetDir) {
62
+ const timeline = JSON.parse(otioJson);
63
+ if (!isObject(timeline) || schemaName(timeline) !== "Timeline") {
64
+ throw new Error("session.otio root is not an OTIO Timeline.");
65
+ }
66
+ normalize(timeline, path.resolve(targetDir));
67
+ return JSON.stringify(timeline, null, 2) + "\n";
68
+ }
package/dist/server.d.ts CHANGED
@@ -5,4 +5,5 @@ export interface VcrMcpServerDeps {
5
5
  api: VcrApiClient;
6
6
  downloads: DownloadManager;
7
7
  }
8
+ export declare const MCP_SERVER_VERSION: string;
8
9
  export declare function createVcrMcpServer(deps: VcrMcpServerDeps): McpServer;
package/dist/server.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { readFileSync } from "node:fs";
1
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
3
  import { z } from "zod";
3
4
  import { VcrApiError } from "./api/client.js";
@@ -8,6 +9,7 @@ import { buildInviteBlurb, buildSessionIcs, formatBytes, parseIsoToMs, parseTime
8
9
  const QUALITY_TIERS = ["1080p", "4k"];
9
10
  const MARKER_COLORS = ["Blue", "Green", "Red", "Yellow"];
10
11
  const QualityTierSchema = z.enum(QUALITY_TIERS);
12
+ const STALE_PROCESSING_JOB_MS = 15 * 60 * 1000;
11
13
  const MarkerColorSchema = z.enum(MARKER_COLORS);
12
14
  function okResult(payload) {
13
15
  return {
@@ -86,6 +88,7 @@ const DownloadJobOutputSchema = z.object({
86
88
  startedAtMs: z.number(),
87
89
  completedAtMs: z.number().nullable(),
88
90
  files: z.array(DownloadFileOutputSchema),
91
+ resolveOtioPath: z.string().optional(),
89
92
  error: z.string().optional(),
90
93
  });
91
94
  function formatJobOutput(job) {
@@ -95,11 +98,13 @@ function formatJobOutput(job) {
95
98
  remainingSizeFormatted: formatBytes(job.remainingBytes),
96
99
  };
97
100
  }
101
+ const PACKAGE_JSON = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
102
+ export const MCP_SERVER_VERSION = PACKAGE_JSON.version ?? "0.0.0";
98
103
  export function createVcrMcpServer(deps) {
99
104
  const { api, downloads } = deps;
100
105
  const server = new McpServer({
101
106
  name: "video-call-recorder",
102
- version: "0.1.0",
107
+ version: MCP_SERVER_VERSION,
103
108
  });
104
109
  // 1. get_host_status
105
110
  server.registerTool("get_host_status", {
@@ -771,8 +776,26 @@ export function createVcrMcpServer(deps) {
771
776
  "All raw Tracks are uploaded and awaiting Host unlock in the Dashboard (via Recording Credit or Pay-As-You-Go). MCP agents cannot initiate payments — share the Dashboard link with the Host.";
772
777
  }
773
778
  else if (s.status === "processing") {
774
- guidance =
775
- "Modal FFmpeg post-processing is running (typically 1–5 minutes). Poll get_session again until status is 'ready' or 'ready_partial'.";
779
+ const latestJob = detail.jobs[0];
780
+ const runningMs = latestJob ? Date.now() - latestJob.startedAt : 0;
781
+ if (latestJob && runningMs >= STALE_PROCESSING_JOB_MS && detail.files.length === 0) {
782
+ const minutes = Math.floor(runningMs / 60_000);
783
+ guidance = `Post-processing job ${latestJob.id} has been running for ${minutes} minutes without finishing (normal runs take 1–5 minutes). The remote Modal worker may have timed out or hit a billing/capacity limit. Call process_session_now to retry, or check the Modal logs for this job.`;
784
+ }
785
+ else {
786
+ guidance =
787
+ "Modal FFmpeg post-processing is running (typically 1–5 minutes). Poll get_session again until status is 'ready' or 'ready_partial'.";
788
+ }
789
+ }
790
+ else if (s.status === "ready" || s.status === "ready_partial") {
791
+ guidance = [
792
+ s.status === "ready_partial"
793
+ ? "Session exports are ready, but some Tracks failed to conform (see syncReport.tracks)."
794
+ : "Session exports are ready.",
795
+ "Plan edits from syncReport: activeSpeechRanges and liveVideoRanges for the rough cut, integratedLufs and truePeakDbfs for loudness, warnings for sync or capture problems, and screenClips (chronological) for screen-share inserts.",
796
+ 'Call download_session with categories: ["bundle", "audio"] first to transcribe and plan the cut before pulling multi-GB video.',
797
+ "download_session also writes session.resolve.otio with absolute local paths for one-click DaVinci Resolve import (File → Import → Timeline).",
798
+ ].join(" ");
776
799
  }
777
800
  else if (s.status === "failed") {
778
801
  guidance =
@@ -947,7 +970,7 @@ export function createVcrMcpServer(deps) {
947
970
  // 14. download_session
948
971
  server.registerTool("download_session", {
949
972
  title: "Download Session",
950
- description: "Download exported Tracks and timeline bundles (.otio/.edl/.json) into a flat local folder with atomic .part streaming, HTTP Range resume, exact byteSize skipping, and automatic presigned URL refresh. Under mode='auto', pulls <= 100 MB run foreground with progress notifications while multi-GB pulls launch in background and return a downloadId for get_download_status.",
973
+ description: "Download exported Tracks and timeline bundles (.otio/.edl/.json) into a flat local folder with atomic .part streaming, HTTP Range resume, exact byteSize skipping, and automatic presigned URL refresh. When session.otio is on disk after the pull, also writes session.resolve.otio with absolute local paths (returned as resolveOtioPath) for one-click DaVinci Resolve import. To inspect or transcribe first, pass categories: [\"bundle\", \"audio\"] and fetch the multi-GB .mov video later. Under mode='auto', pulls <= 100 MB run foreground with progress notifications while larger pulls run in the background of this MCP server process and return a downloadId for get_download_status; they stop if the process exits, so short-lived or one-shot CLI invocations should pass mode: \"foreground\".",
951
974
  inputSchema: {
952
975
  sessionId: z.string().min(1).describe("Ready Session ID to download."),
953
976
  destinationDir: z
@@ -961,7 +984,7 @@ export function createVcrMcpServer(deps) {
961
984
  categories: z
962
985
  .array(z.enum(["bundle", "audio", "video", "screen"]))
963
986
  .default(ALL_DOWNLOAD_CATEGORIES)
964
- .describe("File categories to download."),
987
+ .describe('File categories to download. Use ["bundle", "audio"] to inspect or transcribe before pulling multi-GB "video"/"screen" .mov files.'),
965
988
  overwrite: z
966
989
  .boolean()
967
990
  .default(false)
@@ -973,7 +996,7 @@ export function createVcrMcpServer(deps) {
973
996
  mode: z
974
997
  .enum(["auto", "foreground", "background"])
975
998
  .default("auto")
976
- .describe("'auto' runs foreground <= 100 MB and background > 100 MB to avoid 60s client timeouts."),
999
+ .describe("'auto' runs foreground <= 100 MB and background > 100 MB to avoid 60s client timeouts. Background pulls live only as long as this MCP server process, so short-lived or one-shot CLI invocations should pass 'foreground'."),
977
1000
  },
978
1001
  outputSchema: DownloadJobOutputSchema.shape,
979
1002
  annotations: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapedock/mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Official TapeDock MCP server — plan remote video interviews, mint guest invites, drop timeline markers, and stream resumable multi-GB synced exports.",
5
5
  "private": false,
6
6
  "license": "MIT",
@@ -31,8 +31,8 @@
31
31
  "server.json"
32
32
  ],
33
33
  "bin": {
34
- "tapedock-mcp": "./dist/cli.js",
35
- "vcr-mcp": "./dist/cli.js"
34
+ "tapedock-mcp": "dist/cli.js",
35
+ "vcr-mcp": "dist/cli.js"
36
36
  },
37
37
  "exports": {
38
38
  ".": {
package/server.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "https://git.audrow.com/audrow/video-call-recorder",
7
7
  "source": "git"
8
8
  },
9
- "version": "0.1.0",
9
+ "version": "0.1.1",
10
10
  "websiteUrl": "https://tapedock.com/docs/mcp",
11
11
  "remotes": [
12
12
  {
@@ -18,7 +18,7 @@
18
18
  {
19
19
  "registryType": "npm",
20
20
  "identifier": "@tapedock/mcp",
21
- "version": "0.1.0",
21
+ "version": "0.1.1",
22
22
  "transport": {
23
23
  "type": "stdio"
24
24
  },