@tapedock/mcp 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +49 -2
- package/dist/api/client.d.ts +192 -0
- package/dist/api/client.js +152 -0
- package/dist/auth/credentials.d.ts +42 -0
- package/dist/auth/credentials.js +244 -0
- package/dist/auth/login.d.ts +22 -0
- package/dist/auth/login.js +229 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +145 -0
- package/dist/downloads/manager.d.ts +72 -0
- package/dist/downloads/manager.js +485 -0
- package/dist/lib/format.d.ts +31 -0
- package/dist/lib/format.js +146 -0
- package/dist/server.d.ts +8 -0
- package/dist/server.js +1045 -0
- package/package.json +56 -4
- package/server.json +41 -0
package/dist/server.js
ADDED
|
@@ -0,0 +1,1045 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { VcrApiError } from "./api/client.js";
|
|
4
|
+
import { AuthRequiredError } from "./auth/credentials.js";
|
|
5
|
+
import { ALL_DOWNLOAD_CATEGORIES, } from "./downloads/manager.js";
|
|
6
|
+
import { buildInviteBlurb, buildSessionIcs, formatBytes, parseIsoToMs, parseTimecodeToMs, } from "./lib/format.js";
|
|
7
|
+
// Keep runtime dependency-free from raw-TS @vcr/protocol while enforcing compile-time parity
|
|
8
|
+
const QUALITY_TIERS = ["1080p", "4k"];
|
|
9
|
+
const MARKER_COLORS = ["Blue", "Green", "Red", "Yellow"];
|
|
10
|
+
const QualityTierSchema = z.enum(QUALITY_TIERS);
|
|
11
|
+
const MarkerColorSchema = z.enum(MARKER_COLORS);
|
|
12
|
+
function okResult(payload) {
|
|
13
|
+
return {
|
|
14
|
+
content: [{ type: "text", text: JSON.stringify(payload, null, 2) }],
|
|
15
|
+
structuredContent: payload,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function errorResult(err) {
|
|
19
|
+
if (err instanceof AuthRequiredError) {
|
|
20
|
+
return {
|
|
21
|
+
isError: true,
|
|
22
|
+
content: [{ type: "text", text: err.message }],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (err instanceof VcrApiError) {
|
|
26
|
+
const scopeHint = err.requiredScope
|
|
27
|
+
? ` (requires OAuth scope "${err.requiredScope}" — re-run \`vcr-mcp login\` without \`--read-only\`)`
|
|
28
|
+
: "";
|
|
29
|
+
return {
|
|
30
|
+
isError: true,
|
|
31
|
+
content: [{ type: "text", text: `API error (${err.status}): ${err.message}${scopeHint}` }],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
isError: true,
|
|
36
|
+
content: [{ type: "text", text: err instanceof Error ? err.message : String(err) }],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async function runTool(fn) {
|
|
40
|
+
try {
|
|
41
|
+
return okResult(await fn());
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
return errorResult(err);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const InviteOutputSchema = z.object({
|
|
48
|
+
id: z.string(),
|
|
49
|
+
guestName: z.string().nullable(),
|
|
50
|
+
inviteUrl: z.string(),
|
|
51
|
+
createdAt: z.number(),
|
|
52
|
+
blurb: z.string().optional(),
|
|
53
|
+
});
|
|
54
|
+
const RoomOutputSchema = z.object({
|
|
55
|
+
id: z.string(),
|
|
56
|
+
slug: z.string(),
|
|
57
|
+
name: z.string(),
|
|
58
|
+
isLocked: z.boolean(),
|
|
59
|
+
defaultQuality: QualityTierSchema,
|
|
60
|
+
archivedAt: z.number().nullable(),
|
|
61
|
+
createdAt: z.number(),
|
|
62
|
+
hostUrl: z.string(),
|
|
63
|
+
guestInviteUrl: z.string().nullable(),
|
|
64
|
+
});
|
|
65
|
+
const DownloadFileOutputSchema = z.object({
|
|
66
|
+
name: z.string(),
|
|
67
|
+
category: z.enum(["bundle", "audio", "video", "screen"]),
|
|
68
|
+
byteSize: z.number(),
|
|
69
|
+
downloadedBytes: z.number(),
|
|
70
|
+
status: z.enum(["pending", "downloading", "completed", "skipped", "failed"]),
|
|
71
|
+
localPath: z.string(),
|
|
72
|
+
error: z.string().optional(),
|
|
73
|
+
});
|
|
74
|
+
const DownloadJobOutputSchema = z.object({
|
|
75
|
+
downloadId: z.string(),
|
|
76
|
+
sessionId: z.string(),
|
|
77
|
+
sessionTitle: z.string(),
|
|
78
|
+
mode: z.enum(["foreground", "background", "dry_run"]),
|
|
79
|
+
status: z.enum(["running", "completed", "failed", "dry_run"]),
|
|
80
|
+
targetDir: z.string(),
|
|
81
|
+
totalBytes: z.number(),
|
|
82
|
+
totalSizeFormatted: z.string(),
|
|
83
|
+
remainingBytes: z.number(),
|
|
84
|
+
remainingSizeFormatted: z.string(),
|
|
85
|
+
downloadedBytes: z.number(),
|
|
86
|
+
startedAtMs: z.number(),
|
|
87
|
+
completedAtMs: z.number().nullable(),
|
|
88
|
+
files: z.array(DownloadFileOutputSchema),
|
|
89
|
+
error: z.string().optional(),
|
|
90
|
+
});
|
|
91
|
+
function formatJobOutput(job) {
|
|
92
|
+
return {
|
|
93
|
+
...job,
|
|
94
|
+
totalSizeFormatted: formatBytes(job.totalBytes),
|
|
95
|
+
remainingSizeFormatted: formatBytes(job.remainingBytes),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export function createVcrMcpServer(deps) {
|
|
99
|
+
const { api, downloads } = deps;
|
|
100
|
+
const server = new McpServer({
|
|
101
|
+
name: "video-call-recorder",
|
|
102
|
+
version: "0.1.0",
|
|
103
|
+
});
|
|
104
|
+
// 1. get_host_status
|
|
105
|
+
server.registerTool("get_host_status", {
|
|
106
|
+
title: "Get Host Status",
|
|
107
|
+
description: "Inspect the authenticated Host account, server origin, granted OAuth scopes, Room/Session counts, and current monthly Usage Ledger summary.",
|
|
108
|
+
inputSchema: {},
|
|
109
|
+
outputSchema: {
|
|
110
|
+
origin: z.string(),
|
|
111
|
+
host: z.object({
|
|
112
|
+
accountId: z.string(),
|
|
113
|
+
email: z.string(),
|
|
114
|
+
name: z.string(),
|
|
115
|
+
isFreeAccount: z.boolean(),
|
|
116
|
+
}),
|
|
117
|
+
scopes: z.array(z.string()),
|
|
118
|
+
counts: z.object({
|
|
119
|
+
activeRooms: z.number(),
|
|
120
|
+
archivedRooms: z.number(),
|
|
121
|
+
plannedSessions: z.number(),
|
|
122
|
+
recordedSessions: z.number(),
|
|
123
|
+
}),
|
|
124
|
+
usageSummary: z.object({
|
|
125
|
+
monthlyCogsUsd: z.number(),
|
|
126
|
+
totalSessions: z.number(),
|
|
127
|
+
}),
|
|
128
|
+
},
|
|
129
|
+
annotations: {
|
|
130
|
+
title: "Get Host Status",
|
|
131
|
+
readOnlyHint: true,
|
|
132
|
+
destructiveHint: false,
|
|
133
|
+
idempotentHint: true,
|
|
134
|
+
openWorldHint: true,
|
|
135
|
+
},
|
|
136
|
+
}, async () => runTool(async () => {
|
|
137
|
+
const [me, roomsResp, sessionsResp] = await Promise.all([
|
|
138
|
+
api.getAuthMe(),
|
|
139
|
+
api.listRooms(),
|
|
140
|
+
api.listSessions(),
|
|
141
|
+
]);
|
|
142
|
+
if (!me.authenticated || !me.user) {
|
|
143
|
+
throw new AuthRequiredError(api.origin);
|
|
144
|
+
}
|
|
145
|
+
const activeRooms = roomsResp.rooms.filter((r) => !r.archivedAt).length;
|
|
146
|
+
const archivedRooms = roomsResp.rooms.length - activeRooms;
|
|
147
|
+
return {
|
|
148
|
+
origin: api.origin,
|
|
149
|
+
host: {
|
|
150
|
+
accountId: me.user.accountId,
|
|
151
|
+
email: me.user.email,
|
|
152
|
+
name: me.user.name,
|
|
153
|
+
isFreeAccount: Boolean(me.user.isFreeAccount),
|
|
154
|
+
},
|
|
155
|
+
scopes: me.scopes ?? [],
|
|
156
|
+
counts: {
|
|
157
|
+
activeRooms,
|
|
158
|
+
archivedRooms,
|
|
159
|
+
plannedSessions: sessionsResp.plannedSessions.length,
|
|
160
|
+
recordedSessions: sessionsResp.sessions.length,
|
|
161
|
+
},
|
|
162
|
+
usageSummary: {
|
|
163
|
+
monthlyCogsUsd: sessionsResp.usageSummary.monthlyCogsUsd,
|
|
164
|
+
totalSessions: sessionsResp.usageSummary.totalSessions,
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}));
|
|
168
|
+
// 2. list_rooms
|
|
169
|
+
server.registerTool("list_rooms", {
|
|
170
|
+
title: "List Rooms",
|
|
171
|
+
description: "List persistent Rooms owned by the Host, including Host enter URLs and reusable Guest invite URLs.",
|
|
172
|
+
inputSchema: {
|
|
173
|
+
includeArchived: z
|
|
174
|
+
.boolean()
|
|
175
|
+
.default(false)
|
|
176
|
+
.describe("Include archived Rooms in the result."),
|
|
177
|
+
},
|
|
178
|
+
outputSchema: {
|
|
179
|
+
rooms: z.array(RoomOutputSchema),
|
|
180
|
+
},
|
|
181
|
+
annotations: {
|
|
182
|
+
title: "List Rooms",
|
|
183
|
+
readOnlyHint: true,
|
|
184
|
+
destructiveHint: false,
|
|
185
|
+
idempotentHint: true,
|
|
186
|
+
openWorldHint: true,
|
|
187
|
+
},
|
|
188
|
+
}, async ({ includeArchived }) => runTool(async () => {
|
|
189
|
+
const resp = await api.listRooms();
|
|
190
|
+
const filtered = includeArchived
|
|
191
|
+
? resp.rooms
|
|
192
|
+
: resp.rooms.filter((r) => !r.archivedAt);
|
|
193
|
+
return {
|
|
194
|
+
rooms: filtered.map((r) => ({
|
|
195
|
+
id: r.id,
|
|
196
|
+
slug: r.slug,
|
|
197
|
+
name: r.name,
|
|
198
|
+
isLocked: r.isLocked,
|
|
199
|
+
defaultQuality: r.defaultQuality,
|
|
200
|
+
archivedAt: r.archivedAt ?? null,
|
|
201
|
+
createdAt: r.createdAt,
|
|
202
|
+
hostUrl: `${api.origin}/host/room/${r.id}`,
|
|
203
|
+
guestInviteUrl: r.inviteUrl ?? null,
|
|
204
|
+
})),
|
|
205
|
+
};
|
|
206
|
+
}));
|
|
207
|
+
// 3. create_room
|
|
208
|
+
server.registerTool("create_room", {
|
|
209
|
+
title: "Create Room",
|
|
210
|
+
description: "Create a new persistent Room with a reusable Guest invite link.",
|
|
211
|
+
inputSchema: {
|
|
212
|
+
name: z.string().trim().min(1).max(100).describe("Display name of the Room."),
|
|
213
|
+
defaultQuality: QualityTierSchema.default("1080p").describe("Default local recording video quality for Sessions in this Room."),
|
|
214
|
+
},
|
|
215
|
+
outputSchema: {
|
|
216
|
+
room: RoomOutputSchema,
|
|
217
|
+
},
|
|
218
|
+
annotations: {
|
|
219
|
+
title: "Create Room",
|
|
220
|
+
readOnlyHint: false,
|
|
221
|
+
destructiveHint: false,
|
|
222
|
+
idempotentHint: false,
|
|
223
|
+
openWorldHint: true,
|
|
224
|
+
},
|
|
225
|
+
}, async ({ name, defaultQuality }) => runTool(async () => {
|
|
226
|
+
const resp = await api.createRoom({ name, defaultQuality });
|
|
227
|
+
const r = resp.room;
|
|
228
|
+
return {
|
|
229
|
+
room: {
|
|
230
|
+
id: r.id,
|
|
231
|
+
slug: r.slug,
|
|
232
|
+
name: r.name,
|
|
233
|
+
isLocked: r.isLocked,
|
|
234
|
+
defaultQuality: r.defaultQuality,
|
|
235
|
+
archivedAt: r.archivedAt ?? null,
|
|
236
|
+
createdAt: r.createdAt,
|
|
237
|
+
hostUrl: `${api.origin}/host/room/${r.id}`,
|
|
238
|
+
guestInviteUrl: r.inviteUrl ?? null,
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
}));
|
|
242
|
+
// 4. update_room
|
|
243
|
+
server.registerTool("update_room", {
|
|
244
|
+
title: "Update Room",
|
|
245
|
+
description: "Lock/unlock a Room, archive/restore it, and/or rotate its reusable Guest invite link.",
|
|
246
|
+
inputSchema: {
|
|
247
|
+
roomId: z.string().min(1).describe("Room ID (e.g. room_...)."),
|
|
248
|
+
lock: z.boolean().optional().describe("Set Room lock state (true blocks new Guests)."),
|
|
249
|
+
archive: z.boolean().optional().describe("Archive (true) or restore (false) the Room."),
|
|
250
|
+
rotateInviteLink: z
|
|
251
|
+
.boolean()
|
|
252
|
+
.optional()
|
|
253
|
+
.describe("Generate a new reusable Guest invite link (revokes the previous Room link)."),
|
|
254
|
+
},
|
|
255
|
+
outputSchema: {
|
|
256
|
+
roomId: z.string(),
|
|
257
|
+
isLocked: z.boolean().optional(),
|
|
258
|
+
archivedAt: z.number().nullable().optional(),
|
|
259
|
+
guestInviteUrl: z.string().optional(),
|
|
260
|
+
},
|
|
261
|
+
annotations: {
|
|
262
|
+
title: "Update Room",
|
|
263
|
+
readOnlyHint: false,
|
|
264
|
+
destructiveHint: false,
|
|
265
|
+
idempotentHint: true,
|
|
266
|
+
openWorldHint: true,
|
|
267
|
+
},
|
|
268
|
+
}, async ({ roomId, lock, archive, rotateInviteLink }) => runTool(async () => {
|
|
269
|
+
if (lock === undefined && archive === undefined && !rotateInviteLink) {
|
|
270
|
+
throw new Error("Provide at least one of: lock, archive, or rotateInviteLink.");
|
|
271
|
+
}
|
|
272
|
+
const out = { roomId };
|
|
273
|
+
if (lock !== undefined) {
|
|
274
|
+
const r = await api.setRoomLock(roomId, lock);
|
|
275
|
+
out.isLocked = r.isLocked;
|
|
276
|
+
}
|
|
277
|
+
if (archive !== undefined) {
|
|
278
|
+
const r = await api.setRoomArchived(roomId, archive);
|
|
279
|
+
out.archivedAt = r.archivedAt;
|
|
280
|
+
}
|
|
281
|
+
if (rotateInviteLink) {
|
|
282
|
+
const r = await api.rotateRoomLink(roomId);
|
|
283
|
+
out.guestInviteUrl = r.inviteUrl;
|
|
284
|
+
}
|
|
285
|
+
return out;
|
|
286
|
+
}));
|
|
287
|
+
// 5. plan_session
|
|
288
|
+
server.registerTool("plan_session", {
|
|
289
|
+
title: "Plan Session",
|
|
290
|
+
description: "Plan an upcoming recording Session inside a Room (or create a new Room), minting a generic Session Invite plus optional personalized Guest invites, ready-to-paste invite blurbs, and optional .ics calendar text.",
|
|
291
|
+
inputSchema: {
|
|
292
|
+
title: z.string().trim().min(1).max(160).describe("Title of the planned Session."),
|
|
293
|
+
roomId: z
|
|
294
|
+
.string()
|
|
295
|
+
.optional()
|
|
296
|
+
.describe("Existing active Room ID. Optional if you only have one active Room or pass newRoomName."),
|
|
297
|
+
newRoomName: z
|
|
298
|
+
.string()
|
|
299
|
+
.trim()
|
|
300
|
+
.min(1)
|
|
301
|
+
.max(100)
|
|
302
|
+
.optional()
|
|
303
|
+
.describe("Create a new Room with this name for the Session."),
|
|
304
|
+
scheduledStartIso: z
|
|
305
|
+
.string()
|
|
306
|
+
.optional()
|
|
307
|
+
.describe("Optional ISO-8601 start timestamp (e.g. '2026-12-01T17:00:00Z')."),
|
|
308
|
+
guestNames: z
|
|
309
|
+
.array(z.string().trim().min(1).max(80))
|
|
310
|
+
.max(12)
|
|
311
|
+
.optional()
|
|
312
|
+
.describe("Optional list of Guest names to mint personalized Session Invite links for."),
|
|
313
|
+
includeIcs: z
|
|
314
|
+
.boolean()
|
|
315
|
+
.default(false)
|
|
316
|
+
.describe("Include an .ics calendar invite string (requires scheduledStartIso)."),
|
|
317
|
+
},
|
|
318
|
+
outputSchema: {
|
|
319
|
+
session: z.object({
|
|
320
|
+
id: z.string(),
|
|
321
|
+
roomId: z.string(),
|
|
322
|
+
title: z.string(),
|
|
323
|
+
qualityTier: QualityTierSchema,
|
|
324
|
+
status: z.literal("planned"),
|
|
325
|
+
scheduledStartAtMs: z.number().nullable(),
|
|
326
|
+
scheduledStartIso: z.string().nullable(),
|
|
327
|
+
hostUrl: z.string(),
|
|
328
|
+
genericInvite: InviteOutputSchema.nullable(),
|
|
329
|
+
guestInvites: z.array(InviteOutputSchema),
|
|
330
|
+
}),
|
|
331
|
+
ics: z.string().nullable(),
|
|
332
|
+
},
|
|
333
|
+
annotations: {
|
|
334
|
+
title: "Plan Session",
|
|
335
|
+
readOnlyHint: false,
|
|
336
|
+
destructiveHint: false,
|
|
337
|
+
idempotentHint: false,
|
|
338
|
+
openWorldHint: true,
|
|
339
|
+
},
|
|
340
|
+
}, async ({ title, roomId, newRoomName, scheduledStartIso, guestNames, includeIcs }) => runTool(async () => {
|
|
341
|
+
const scheduledStartAtMs = scheduledStartIso
|
|
342
|
+
? parseIsoToMs(scheduledStartIso, "scheduledStartIso")
|
|
343
|
+
: null;
|
|
344
|
+
const [{ session }, me, roomsResp] = await Promise.all([
|
|
345
|
+
api.planSession({
|
|
346
|
+
roomId,
|
|
347
|
+
newRoomName,
|
|
348
|
+
title,
|
|
349
|
+
scheduledStartAtMs,
|
|
350
|
+
guestNames,
|
|
351
|
+
}),
|
|
352
|
+
api.getAuthMe().catch(() => null),
|
|
353
|
+
includeIcs ? api.listRooms().catch(() => null) : Promise.resolve(null),
|
|
354
|
+
]);
|
|
355
|
+
const hostName = me?.user?.name?.trim() || "Host";
|
|
356
|
+
const roomName = roomsResp?.rooms.find((r) => r.id === session.roomId)?.name ||
|
|
357
|
+
newRoomName ||
|
|
358
|
+
"Recording Room";
|
|
359
|
+
const genericInvite = session.genericInvite
|
|
360
|
+
? {
|
|
361
|
+
...session.genericInvite,
|
|
362
|
+
blurb: buildInviteBlurb({
|
|
363
|
+
sessionTitle: session.title,
|
|
364
|
+
hostName,
|
|
365
|
+
guestName: null,
|
|
366
|
+
scheduledStartAtMs: session.scheduledStartAtMs,
|
|
367
|
+
inviteUrl: session.genericInvite.inviteUrl,
|
|
368
|
+
}),
|
|
369
|
+
}
|
|
370
|
+
: null;
|
|
371
|
+
const guestInvites = session.guestInvites.map((inv) => ({
|
|
372
|
+
...inv,
|
|
373
|
+
blurb: buildInviteBlurb({
|
|
374
|
+
sessionTitle: session.title,
|
|
375
|
+
hostName,
|
|
376
|
+
guestName: inv.guestName,
|
|
377
|
+
scheduledStartAtMs: session.scheduledStartAtMs,
|
|
378
|
+
inviteUrl: inv.inviteUrl,
|
|
379
|
+
}),
|
|
380
|
+
}));
|
|
381
|
+
const ics = includeIcs && session.scheduledStartAtMs && genericInvite
|
|
382
|
+
? buildSessionIcs({
|
|
383
|
+
sessionId: session.id,
|
|
384
|
+
sessionTitle: session.title,
|
|
385
|
+
hostName,
|
|
386
|
+
roomName,
|
|
387
|
+
scheduledStartAtMs: session.scheduledStartAtMs,
|
|
388
|
+
inviteUrl: genericInvite.inviteUrl,
|
|
389
|
+
})
|
|
390
|
+
: null;
|
|
391
|
+
return {
|
|
392
|
+
session: {
|
|
393
|
+
id: session.id,
|
|
394
|
+
roomId: session.roomId,
|
|
395
|
+
title: session.title,
|
|
396
|
+
qualityTier: session.qualityTier,
|
|
397
|
+
status: "planned",
|
|
398
|
+
scheduledStartAtMs: session.scheduledStartAtMs,
|
|
399
|
+
scheduledStartIso: session.scheduledStartAtMs
|
|
400
|
+
? new Date(session.scheduledStartAtMs).toISOString()
|
|
401
|
+
: null,
|
|
402
|
+
hostUrl: `${api.origin}/host/room/${session.roomId}/session/${session.id}`,
|
|
403
|
+
genericInvite,
|
|
404
|
+
guestInvites,
|
|
405
|
+
},
|
|
406
|
+
ics,
|
|
407
|
+
};
|
|
408
|
+
}));
|
|
409
|
+
// 6. update_planned_session
|
|
410
|
+
server.registerTool("update_planned_session", {
|
|
411
|
+
title: "Update Planned Session",
|
|
412
|
+
description: "Update the title and/or scheduled start time of an upcoming planned Session.",
|
|
413
|
+
inputSchema: {
|
|
414
|
+
sessionId: z.string().min(1).describe("Planned Session ID."),
|
|
415
|
+
title: z.string().trim().min(1).max(160).optional().describe("New Session title."),
|
|
416
|
+
scheduledStartIso: z
|
|
417
|
+
.string()
|
|
418
|
+
.nullable()
|
|
419
|
+
.optional()
|
|
420
|
+
.describe("New ISO-8601 timestamp, or null to clear the scheduled time."),
|
|
421
|
+
},
|
|
422
|
+
outputSchema: {
|
|
423
|
+
ok: z.boolean(),
|
|
424
|
+
sessionId: z.string(),
|
|
425
|
+
title: z.string(),
|
|
426
|
+
scheduledStartAtMs: z.number().nullable(),
|
|
427
|
+
scheduledStartIso: z.string().nullable(),
|
|
428
|
+
},
|
|
429
|
+
annotations: {
|
|
430
|
+
title: "Update Planned Session",
|
|
431
|
+
readOnlyHint: false,
|
|
432
|
+
destructiveHint: false,
|
|
433
|
+
idempotentHint: true,
|
|
434
|
+
openWorldHint: true,
|
|
435
|
+
},
|
|
436
|
+
}, async ({ sessionId, title, scheduledStartIso }) => runTool(async () => {
|
|
437
|
+
if (title === undefined && scheduledStartIso === undefined) {
|
|
438
|
+
throw new Error("Provide title and/or scheduledStartIso.");
|
|
439
|
+
}
|
|
440
|
+
const payload = {};
|
|
441
|
+
if (title !== undefined)
|
|
442
|
+
payload.title = title;
|
|
443
|
+
if (scheduledStartIso !== undefined) {
|
|
444
|
+
payload.scheduledStartAtMs =
|
|
445
|
+
scheduledStartIso === null ? null : parseIsoToMs(scheduledStartIso);
|
|
446
|
+
}
|
|
447
|
+
const res = await api.updatePlannedSession(sessionId, payload);
|
|
448
|
+
return {
|
|
449
|
+
ok: res.ok,
|
|
450
|
+
sessionId,
|
|
451
|
+
title: res.title,
|
|
452
|
+
scheduledStartAtMs: res.scheduledStartAtMs,
|
|
453
|
+
scheduledStartIso: res.scheduledStartAtMs
|
|
454
|
+
? new Date(res.scheduledStartAtMs).toISOString()
|
|
455
|
+
: null,
|
|
456
|
+
};
|
|
457
|
+
}));
|
|
458
|
+
// 7. cancel_planned_session
|
|
459
|
+
server.registerTool("cancel_planned_session", {
|
|
460
|
+
title: "Cancel Planned Session",
|
|
461
|
+
description: "Cancel an upcoming planned Session and clear any staged Room state.",
|
|
462
|
+
inputSchema: {
|
|
463
|
+
sessionId: z.string().min(1).describe("Planned Session ID to cancel."),
|
|
464
|
+
},
|
|
465
|
+
outputSchema: {
|
|
466
|
+
ok: z.boolean(),
|
|
467
|
+
sessionId: z.string(),
|
|
468
|
+
},
|
|
469
|
+
annotations: {
|
|
470
|
+
title: "Cancel Planned Session",
|
|
471
|
+
readOnlyHint: false,
|
|
472
|
+
destructiveHint: true,
|
|
473
|
+
idempotentHint: true,
|
|
474
|
+
openWorldHint: true,
|
|
475
|
+
},
|
|
476
|
+
}, async ({ sessionId }) => runTool(async () => {
|
|
477
|
+
const res = await api.cancelPlannedSession(sessionId);
|
|
478
|
+
return { ok: res.ok, sessionId };
|
|
479
|
+
}));
|
|
480
|
+
// 8. manage_session_invites
|
|
481
|
+
server.registerTool("manage_session_invites", {
|
|
482
|
+
title: "Manage Session Invites",
|
|
483
|
+
description: "Add a personalized Guest Session Invite, rename a Guest invite, rotate an invite link, or revoke an invite on a planned Session.",
|
|
484
|
+
inputSchema: {
|
|
485
|
+
action: z
|
|
486
|
+
.enum(["add", "rename", "rotate", "revoke"])
|
|
487
|
+
.describe("Invite operation to perform."),
|
|
488
|
+
sessionId: z
|
|
489
|
+
.string()
|
|
490
|
+
.optional()
|
|
491
|
+
.describe("Planned Session ID (required for action='add')."),
|
|
492
|
+
inviteId: z
|
|
493
|
+
.string()
|
|
494
|
+
.optional()
|
|
495
|
+
.describe("Session Invite ID (required for 'rename', 'rotate', 'revoke')."),
|
|
496
|
+
guestName: z
|
|
497
|
+
.string()
|
|
498
|
+
.trim()
|
|
499
|
+
.min(1)
|
|
500
|
+
.max(80)
|
|
501
|
+
.optional()
|
|
502
|
+
.describe("Guest display name (required for 'add' and 'rename')."),
|
|
503
|
+
},
|
|
504
|
+
outputSchema: {
|
|
505
|
+
action: z.enum(["add", "rename", "rotate", "revoke"]),
|
|
506
|
+
ok: z.boolean(),
|
|
507
|
+
inviteId: z.string().optional(),
|
|
508
|
+
guestName: z.string().optional(),
|
|
509
|
+
inviteUrl: z.string().optional(),
|
|
510
|
+
blurb: z.string().optional(),
|
|
511
|
+
},
|
|
512
|
+
annotations: {
|
|
513
|
+
title: "Manage Session Invites",
|
|
514
|
+
readOnlyHint: false,
|
|
515
|
+
destructiveHint: false,
|
|
516
|
+
idempotentHint: false,
|
|
517
|
+
openWorldHint: true,
|
|
518
|
+
},
|
|
519
|
+
}, async ({ action, sessionId, inviteId, guestName }) => runTool(async () => {
|
|
520
|
+
if (action === "add") {
|
|
521
|
+
if (!sessionId || !guestName) {
|
|
522
|
+
throw new Error("action='add' requires both sessionId and guestName.");
|
|
523
|
+
}
|
|
524
|
+
const [{ invite }, detail, me] = await Promise.all([
|
|
525
|
+
api.addSessionInvite(sessionId, guestName),
|
|
526
|
+
api.getSession(sessionId).catch(() => null),
|
|
527
|
+
api.getAuthMe().catch(() => null),
|
|
528
|
+
]);
|
|
529
|
+
return {
|
|
530
|
+
action,
|
|
531
|
+
ok: true,
|
|
532
|
+
inviteId: invite.id,
|
|
533
|
+
guestName: invite.guestName ?? guestName,
|
|
534
|
+
inviteUrl: invite.inviteUrl,
|
|
535
|
+
blurb: buildInviteBlurb({
|
|
536
|
+
sessionTitle: detail?.session.title || "Recording Session",
|
|
537
|
+
hostName: me?.user?.name?.trim() || "Host",
|
|
538
|
+
guestName: invite.guestName,
|
|
539
|
+
scheduledStartAtMs: detail?.session.scheduledStartAtMs ?? null,
|
|
540
|
+
inviteUrl: invite.inviteUrl,
|
|
541
|
+
}),
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
if (!inviteId) {
|
|
545
|
+
throw new Error(`action='${action}' requires inviteId.`);
|
|
546
|
+
}
|
|
547
|
+
if (action === "rename") {
|
|
548
|
+
if (!guestName)
|
|
549
|
+
throw new Error("action='rename' requires guestName.");
|
|
550
|
+
const res = await api.renameSessionInvite(inviteId, guestName);
|
|
551
|
+
return { action, ok: res.ok, inviteId, guestName: res.guestName };
|
|
552
|
+
}
|
|
553
|
+
if (action === "rotate") {
|
|
554
|
+
const [res, me] = await Promise.all([
|
|
555
|
+
api.rotateSessionInvite(inviteId),
|
|
556
|
+
api.getAuthMe().catch(() => null),
|
|
557
|
+
]);
|
|
558
|
+
return {
|
|
559
|
+
action,
|
|
560
|
+
ok: res.ok,
|
|
561
|
+
inviteId,
|
|
562
|
+
...(res.guestName ? { guestName: res.guestName } : {}),
|
|
563
|
+
inviteUrl: res.inviteUrl,
|
|
564
|
+
blurb: buildInviteBlurb({
|
|
565
|
+
sessionTitle: res.sessionTitle || "Recording Session",
|
|
566
|
+
hostName: me?.user?.name?.trim() || "Host",
|
|
567
|
+
guestName: res.guestName ?? null,
|
|
568
|
+
scheduledStartAtMs: res.scheduledStartAtMs ?? null,
|
|
569
|
+
inviteUrl: res.inviteUrl,
|
|
570
|
+
}),
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
const res = await api.revokeSessionInvite(inviteId);
|
|
574
|
+
return { action, ok: res.ok, inviteId };
|
|
575
|
+
}));
|
|
576
|
+
// 9. list_sessions
|
|
577
|
+
server.registerTool("list_sessions", {
|
|
578
|
+
title: "List Sessions",
|
|
579
|
+
description: "List upcoming planned Sessions and/or recorded Sessions, with optional Room/status filters and Usage Ledger summary.",
|
|
580
|
+
inputSchema: {
|
|
581
|
+
filter: z
|
|
582
|
+
.enum(["all", "planned", "recorded"])
|
|
583
|
+
.default("all")
|
|
584
|
+
.describe("Return all Sessions, only upcoming planned Sessions, or only recorded Sessions."),
|
|
585
|
+
roomId: z.string().optional().describe("Filter by Room ID."),
|
|
586
|
+
status: z
|
|
587
|
+
.string()
|
|
588
|
+
.optional()
|
|
589
|
+
.describe("Filter recorded Sessions by exact status (e.g. 'ready', 'processing', 'uploading')."),
|
|
590
|
+
limit: z.number().int().min(1).max(100).default(25).describe("Maximum Sessions per list."),
|
|
591
|
+
},
|
|
592
|
+
outputSchema: {
|
|
593
|
+
plannedSessions: z.array(z.object({
|
|
594
|
+
id: z.string(),
|
|
595
|
+
roomId: z.string(),
|
|
596
|
+
title: z.string(),
|
|
597
|
+
qualityTier: QualityTierSchema,
|
|
598
|
+
scheduledStartAtMs: z.number().nullable(),
|
|
599
|
+
scheduledStartIso: z.string().nullable(),
|
|
600
|
+
hostUrl: z.string(),
|
|
601
|
+
genericInviteUrl: z.string().nullable(),
|
|
602
|
+
guestInviteCount: z.number(),
|
|
603
|
+
})),
|
|
604
|
+
recordedSessions: z.array(z.object({
|
|
605
|
+
id: z.string(),
|
|
606
|
+
roomId: z.string(),
|
|
607
|
+
title: z.string(),
|
|
608
|
+
qualityTier: QualityTierSchema,
|
|
609
|
+
status: z.string(),
|
|
610
|
+
startedAtMs: z.number(),
|
|
611
|
+
durationMs: z.number(),
|
|
612
|
+
mediaDeletedAt: z.number().nullable(),
|
|
613
|
+
syncQaPass: z.boolean().nullable(),
|
|
614
|
+
})),
|
|
615
|
+
usageSummary: z.object({
|
|
616
|
+
monthlyCogsUsd: z.number(),
|
|
617
|
+
totalSessions: z.number(),
|
|
618
|
+
}),
|
|
619
|
+
},
|
|
620
|
+
annotations: {
|
|
621
|
+
title: "List Sessions",
|
|
622
|
+
readOnlyHint: true,
|
|
623
|
+
destructiveHint: false,
|
|
624
|
+
idempotentHint: true,
|
|
625
|
+
openWorldHint: true,
|
|
626
|
+
},
|
|
627
|
+
}, async ({ filter, roomId, status, limit }) => runTool(async () => {
|
|
628
|
+
const resp = await api.listSessions();
|
|
629
|
+
const planned = filter === "recorded"
|
|
630
|
+
? []
|
|
631
|
+
: resp.plannedSessions
|
|
632
|
+
.filter((p) => !roomId || p.roomId === roomId)
|
|
633
|
+
.slice(0, limit)
|
|
634
|
+
.map((p) => ({
|
|
635
|
+
id: p.id,
|
|
636
|
+
roomId: p.roomId,
|
|
637
|
+
title: p.title,
|
|
638
|
+
qualityTier: p.qualityTier,
|
|
639
|
+
scheduledStartAtMs: p.scheduledStartAtMs,
|
|
640
|
+
scheduledStartIso: p.scheduledStartAtMs
|
|
641
|
+
? new Date(p.scheduledStartAtMs).toISOString()
|
|
642
|
+
: null,
|
|
643
|
+
hostUrl: `${api.origin}/host/room/${p.roomId}/session/${p.id}`,
|
|
644
|
+
genericInviteUrl: p.genericInvite?.inviteUrl ?? null,
|
|
645
|
+
guestInviteCount: p.guestInvites.length,
|
|
646
|
+
}));
|
|
647
|
+
const recorded = filter === "planned"
|
|
648
|
+
? []
|
|
649
|
+
: resp.sessions
|
|
650
|
+
.filter((s) => (!roomId || s.roomId === roomId) && (!status || s.status === status))
|
|
651
|
+
.slice(0, limit)
|
|
652
|
+
.map((s) => ({
|
|
653
|
+
id: s.id,
|
|
654
|
+
roomId: s.roomId,
|
|
655
|
+
title: s.title,
|
|
656
|
+
qualityTier: s.qualityTier,
|
|
657
|
+
status: s.status,
|
|
658
|
+
startedAtMs: s.startedAtMs,
|
|
659
|
+
durationMs: s.durationMs,
|
|
660
|
+
mediaDeletedAt: s.mediaDeletedAt,
|
|
661
|
+
syncQaPass: s.syncQaPass,
|
|
662
|
+
}));
|
|
663
|
+
return {
|
|
664
|
+
plannedSessions: planned,
|
|
665
|
+
recordedSessions: recorded,
|
|
666
|
+
usageSummary: {
|
|
667
|
+
monthlyCogsUsd: resp.usageSummary.monthlyCogsUsd,
|
|
668
|
+
totalSessions: resp.usageSummary.totalSessions,
|
|
669
|
+
},
|
|
670
|
+
};
|
|
671
|
+
}));
|
|
672
|
+
// 10. get_session
|
|
673
|
+
server.registerTool("get_session", {
|
|
674
|
+
title: "Get Session Details",
|
|
675
|
+
description: "Inspect a single planned or recorded Session: status, Participants, Markers (with NDF timecodes), Sync Report, post-processing jobs, Usage Ledger, Session Invites (if planned), and export file inventory. Raw 1-hour presigned R2 URLs are omitted by default.",
|
|
676
|
+
inputSchema: {
|
|
677
|
+
sessionId: z.string().min(1).describe("Session ID (e.g. sess_...)."),
|
|
678
|
+
includeDownloadUrls: z
|
|
679
|
+
.boolean()
|
|
680
|
+
.default(false)
|
|
681
|
+
.describe("Include raw 1-hour presigned R2 download URLs (omit unless explicitly needed)."),
|
|
682
|
+
},
|
|
683
|
+
outputSchema: {
|
|
684
|
+
session: z.object({
|
|
685
|
+
id: z.string(),
|
|
686
|
+
roomId: z.string(),
|
|
687
|
+
title: z.string(),
|
|
688
|
+
qualityTier: QualityTierSchema,
|
|
689
|
+
status: z.string(),
|
|
690
|
+
scheduledStartAtMs: z.number().nullable(),
|
|
691
|
+
startedAtMs: z.number(),
|
|
692
|
+
endedAtMs: z.number().nullable(),
|
|
693
|
+
durationMs: z.number(),
|
|
694
|
+
mediaDeletedAt: z.number().nullable(),
|
|
695
|
+
syncQaPass: z.boolean().nullable(),
|
|
696
|
+
}),
|
|
697
|
+
guidance: z.string(),
|
|
698
|
+
participants: z.array(z.object({
|
|
699
|
+
id: z.string(),
|
|
700
|
+
participantId: z.string(),
|
|
701
|
+
displayName: z.string(),
|
|
702
|
+
role: z.string(),
|
|
703
|
+
})),
|
|
704
|
+
markers: z.array(z.object({
|
|
705
|
+
id: z.string(),
|
|
706
|
+
timeMs: z.number(),
|
|
707
|
+
timecode: z.string(),
|
|
708
|
+
color: MarkerColorSchema,
|
|
709
|
+
label: z.string(),
|
|
710
|
+
note: z.string(),
|
|
711
|
+
})),
|
|
712
|
+
jobs: z.array(z.object({
|
|
713
|
+
id: z.string(),
|
|
714
|
+
status: z.string(),
|
|
715
|
+
attempt: z.number(),
|
|
716
|
+
errorMessage: z.string().nullable(),
|
|
717
|
+
startedAt: z.number(),
|
|
718
|
+
completedAt: z.number().nullable(),
|
|
719
|
+
})),
|
|
720
|
+
ledger: z.array(z.object({
|
|
721
|
+
qualityTier: z.string(),
|
|
722
|
+
sessionDurationMs: z.number(),
|
|
723
|
+
recordedParticipantMs: z.number(),
|
|
724
|
+
rawBytesUploaded: z.number(),
|
|
725
|
+
exportBytesGenerated: z.number(),
|
|
726
|
+
estimatedCogsUsd: z.number(),
|
|
727
|
+
})),
|
|
728
|
+
syncReport: z.unknown().nullable(),
|
|
729
|
+
genericInvite: InviteOutputSchema.nullable().optional(),
|
|
730
|
+
guestInvites: z.array(InviteOutputSchema).optional(),
|
|
731
|
+
totalExportBytes: z.number(),
|
|
732
|
+
totalExportSizeFormatted: z.string(),
|
|
733
|
+
files: z.array(z.object({
|
|
734
|
+
name: z.string(),
|
|
735
|
+
category: z.enum(["bundle", "audio", "video", "screen"]),
|
|
736
|
+
byteSize: z.number(),
|
|
737
|
+
sizeFormatted: z.string(),
|
|
738
|
+
downloadUrl: z.string().optional(),
|
|
739
|
+
})),
|
|
740
|
+
},
|
|
741
|
+
annotations: {
|
|
742
|
+
title: "Get Session Details",
|
|
743
|
+
readOnlyHint: true,
|
|
744
|
+
destructiveHint: false,
|
|
745
|
+
idempotentHint: true,
|
|
746
|
+
openWorldHint: true,
|
|
747
|
+
},
|
|
748
|
+
}, async ({ sessionId, includeDownloadUrls }) => runTool(async () => {
|
|
749
|
+
const detail = await api.getSession(sessionId);
|
|
750
|
+
const s = detail.session;
|
|
751
|
+
const totalExportBytes = detail.files.reduce((sum, f) => sum + f.byteSize, 0);
|
|
752
|
+
let guidance = "Session exports are ready. Use download_session to save Tracks locally.";
|
|
753
|
+
if (s.mediaDeletedAt) {
|
|
754
|
+
guidance = "Media files for this Session were permanently deleted; only metadata and Markers remain.";
|
|
755
|
+
}
|
|
756
|
+
else if (s.status === "planned") {
|
|
757
|
+
guidance = "Session is planned. Share Session Invite links or enter the Room as Host to start recording.";
|
|
758
|
+
}
|
|
759
|
+
else if (s.status === "cancelled") {
|
|
760
|
+
guidance = "This planned Session was cancelled.";
|
|
761
|
+
}
|
|
762
|
+
else if (s.status === "recording") {
|
|
763
|
+
guidance = "Session is currently recording live.";
|
|
764
|
+
}
|
|
765
|
+
else if (s.status === "uploading") {
|
|
766
|
+
guidance =
|
|
767
|
+
"Tracks are still uploading. Poll get_session again shortly, or call process_session_now to process available Tracks early.";
|
|
768
|
+
}
|
|
769
|
+
else if (s.status === "awaiting_unlock") {
|
|
770
|
+
guidance =
|
|
771
|
+
"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
|
+
}
|
|
773
|
+
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'.";
|
|
776
|
+
}
|
|
777
|
+
else if (s.status === "failed") {
|
|
778
|
+
guidance =
|
|
779
|
+
"Post-processing failed. Inspect jobs[].errorMessage and call process_session_now to retry.";
|
|
780
|
+
}
|
|
781
|
+
return {
|
|
782
|
+
session: {
|
|
783
|
+
id: s.id,
|
|
784
|
+
roomId: s.roomId,
|
|
785
|
+
title: s.title,
|
|
786
|
+
qualityTier: s.qualityTier,
|
|
787
|
+
status: s.status,
|
|
788
|
+
scheduledStartAtMs: s.scheduledStartAtMs ?? null,
|
|
789
|
+
startedAtMs: s.startedAtMs,
|
|
790
|
+
endedAtMs: s.endedAtMs,
|
|
791
|
+
durationMs: s.durationMs,
|
|
792
|
+
mediaDeletedAt: s.mediaDeletedAt,
|
|
793
|
+
syncQaPass: s.syncQaPass,
|
|
794
|
+
},
|
|
795
|
+
guidance,
|
|
796
|
+
participants: detail.participants.map((p) => ({
|
|
797
|
+
id: p.id,
|
|
798
|
+
participantId: p.participantId,
|
|
799
|
+
displayName: p.displayName,
|
|
800
|
+
role: p.role,
|
|
801
|
+
})),
|
|
802
|
+
markers: detail.markers.map((m) => ({
|
|
803
|
+
id: m.id,
|
|
804
|
+
timeMs: m.timeMs,
|
|
805
|
+
timecode: m.timecode,
|
|
806
|
+
color: m.color,
|
|
807
|
+
label: m.label,
|
|
808
|
+
note: m.note,
|
|
809
|
+
})),
|
|
810
|
+
jobs: detail.jobs.map((j) => ({
|
|
811
|
+
id: j.id,
|
|
812
|
+
status: j.status,
|
|
813
|
+
attempt: j.attempt,
|
|
814
|
+
errorMessage: j.errorMessage,
|
|
815
|
+
startedAt: j.startedAt,
|
|
816
|
+
completedAt: j.completedAt,
|
|
817
|
+
})),
|
|
818
|
+
ledger: detail.ledger.map((l) => ({
|
|
819
|
+
qualityTier: l.qualityTier,
|
|
820
|
+
sessionDurationMs: l.sessionDurationMs,
|
|
821
|
+
recordedParticipantMs: l.recordedParticipantMs,
|
|
822
|
+
rawBytesUploaded: l.rawBytesUploaded,
|
|
823
|
+
exportBytesGenerated: l.exportBytesGenerated,
|
|
824
|
+
estimatedCogsUsd: l.estimatedCogsUsd,
|
|
825
|
+
})),
|
|
826
|
+
syncReport: detail.syncReport,
|
|
827
|
+
...(detail.genericInvite !== undefined ? { genericInvite: detail.genericInvite } : {}),
|
|
828
|
+
...(detail.guestInvites !== undefined ? { guestInvites: detail.guestInvites } : {}),
|
|
829
|
+
totalExportBytes,
|
|
830
|
+
totalExportSizeFormatted: formatBytes(totalExportBytes),
|
|
831
|
+
files: detail.files.map((f) => ({
|
|
832
|
+
name: f.name,
|
|
833
|
+
category: f.category,
|
|
834
|
+
byteSize: f.byteSize,
|
|
835
|
+
sizeFormatted: formatBytes(f.byteSize),
|
|
836
|
+
...(includeDownloadUrls ? { downloadUrl: f.downloadUrl } : {}),
|
|
837
|
+
})),
|
|
838
|
+
};
|
|
839
|
+
}));
|
|
840
|
+
// 11. add_marker
|
|
841
|
+
server.registerTool("add_marker", {
|
|
842
|
+
title: "Add Marker",
|
|
843
|
+
description: "Add a timestamped Marker to a recorded Session (accepts timecode like '00:14:32' or timeMs) and instantly regenerate session.otio, markers.edl, and markers.json.",
|
|
844
|
+
inputSchema: {
|
|
845
|
+
sessionId: z.string().min(1).describe("Recorded Session ID."),
|
|
846
|
+
timeMs: z
|
|
847
|
+
.number()
|
|
848
|
+
.int()
|
|
849
|
+
.min(0)
|
|
850
|
+
.optional()
|
|
851
|
+
.describe("Timestamp in milliseconds from 00:00:00. Provide either timeMs or timecode."),
|
|
852
|
+
timecode: z
|
|
853
|
+
.string()
|
|
854
|
+
.optional()
|
|
855
|
+
.describe("Human-readable timestamp ('HH:MM:SS', 'MM:SS', or seconds)."),
|
|
856
|
+
label: z.string().trim().min(1).max(160).describe("Short Marker label."),
|
|
857
|
+
color: MarkerColorSchema.default("Blue").describe("Timeline Marker color (Blue=Highlight, Green=Quote, Red=Cut, Yellow=Chapter)."),
|
|
858
|
+
note: z.string().max(1000).default("").describe("Optional longer editorial note."),
|
|
859
|
+
},
|
|
860
|
+
outputSchema: {
|
|
861
|
+
ok: z.boolean(),
|
|
862
|
+
id: z.string(),
|
|
863
|
+
timeMs: z.number(),
|
|
864
|
+
},
|
|
865
|
+
annotations: {
|
|
866
|
+
title: "Add Marker",
|
|
867
|
+
readOnlyHint: false,
|
|
868
|
+
destructiveHint: false,
|
|
869
|
+
idempotentHint: false,
|
|
870
|
+
openWorldHint: true,
|
|
871
|
+
},
|
|
872
|
+
}, async ({ sessionId, timeMs, timecode, label, color, note }) => runTool(async () => {
|
|
873
|
+
if (timeMs === undefined && !timecode) {
|
|
874
|
+
throw new Error("Provide either timeMs or timecode (e.g. '00:14:32').");
|
|
875
|
+
}
|
|
876
|
+
const resolvedMs = timeMs !== undefined ? timeMs : parseTimecodeToMs(timecode);
|
|
877
|
+
const res = await api.addMarker(sessionId, {
|
|
878
|
+
timeMs: resolvedMs,
|
|
879
|
+
color,
|
|
880
|
+
label,
|
|
881
|
+
note,
|
|
882
|
+
});
|
|
883
|
+
return { ok: res.ok, id: res.id, timeMs: resolvedMs };
|
|
884
|
+
}));
|
|
885
|
+
// 12. delete_marker
|
|
886
|
+
server.registerTool("delete_marker", {
|
|
887
|
+
title: "Delete Marker",
|
|
888
|
+
description: "Delete a Marker from a recorded Session and immediately regenerate export metadata.",
|
|
889
|
+
inputSchema: {
|
|
890
|
+
sessionId: z.string().min(1).describe("Recorded Session ID."),
|
|
891
|
+
markerId: z.string().min(1).describe("Marker ID to remove."),
|
|
892
|
+
},
|
|
893
|
+
outputSchema: {
|
|
894
|
+
ok: z.boolean(),
|
|
895
|
+
sessionId: z.string(),
|
|
896
|
+
markerId: z.string(),
|
|
897
|
+
},
|
|
898
|
+
annotations: {
|
|
899
|
+
title: "Delete Marker",
|
|
900
|
+
readOnlyHint: false,
|
|
901
|
+
destructiveHint: true,
|
|
902
|
+
idempotentHint: true,
|
|
903
|
+
openWorldHint: true,
|
|
904
|
+
},
|
|
905
|
+
}, async ({ sessionId, markerId }) => runTool(async () => {
|
|
906
|
+
const res = await api.deleteMarker(sessionId, markerId);
|
|
907
|
+
return { ok: res.ok, sessionId, markerId };
|
|
908
|
+
}));
|
|
909
|
+
// 13. process_session_now
|
|
910
|
+
server.registerTool("process_session_now", {
|
|
911
|
+
title: "Process Session Now",
|
|
912
|
+
description: "Trigger post-processing early (or retry after failure) on an uploading or failed Session.",
|
|
913
|
+
inputSchema: {
|
|
914
|
+
sessionId: z.string().min(1).describe("Session ID to process."),
|
|
915
|
+
forcePartial: z
|
|
916
|
+
.boolean()
|
|
917
|
+
.default(true)
|
|
918
|
+
.describe("Proceed even if some Participant uploads are incomplete."),
|
|
919
|
+
onlyParticipantIds: z
|
|
920
|
+
.array(z.string().min(1))
|
|
921
|
+
.max(16)
|
|
922
|
+
.optional()
|
|
923
|
+
.describe("Optional subset of Participant IDs to include."),
|
|
924
|
+
},
|
|
925
|
+
outputSchema: {
|
|
926
|
+
ok: z.boolean(),
|
|
927
|
+
jobId: z.string().optional(),
|
|
928
|
+
error: z.string().optional(),
|
|
929
|
+
},
|
|
930
|
+
annotations: {
|
|
931
|
+
title: "Process Session Now",
|
|
932
|
+
readOnlyHint: false,
|
|
933
|
+
destructiveHint: false,
|
|
934
|
+
idempotentHint: false,
|
|
935
|
+
openWorldHint: true,
|
|
936
|
+
},
|
|
937
|
+
}, async ({ sessionId, forcePartial, onlyParticipantIds }) => runTool(async () => {
|
|
938
|
+
const res = await api.processSessionNow(sessionId, {
|
|
939
|
+
forcePartial,
|
|
940
|
+
onlyParticipantIds,
|
|
941
|
+
});
|
|
942
|
+
if (!res.ok) {
|
|
943
|
+
throw new Error(res.error || "Failed to start post-processing.");
|
|
944
|
+
}
|
|
945
|
+
return res;
|
|
946
|
+
}));
|
|
947
|
+
// 14. download_session
|
|
948
|
+
server.registerTool("download_session", {
|
|
949
|
+
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.",
|
|
951
|
+
inputSchema: {
|
|
952
|
+
sessionId: z.string().min(1).describe("Ready Session ID to download."),
|
|
953
|
+
destinationDir: z
|
|
954
|
+
.string()
|
|
955
|
+
.optional()
|
|
956
|
+
.describe("Base destination directory (defaults to TAPEDOCK_DOWNLOAD_DIR or ~/Downloads/tapedock)."),
|
|
957
|
+
createSubfolder: z
|
|
958
|
+
.boolean()
|
|
959
|
+
.default(true)
|
|
960
|
+
.describe("Create a flat <YYYY-MM-DD>_<title>_<shortId>/ subfolder (recommended for editor auto-linking)."),
|
|
961
|
+
categories: z
|
|
962
|
+
.array(z.enum(["bundle", "audio", "video", "screen"]))
|
|
963
|
+
.default(ALL_DOWNLOAD_CATEGORIES)
|
|
964
|
+
.describe("File categories to download."),
|
|
965
|
+
overwrite: z
|
|
966
|
+
.boolean()
|
|
967
|
+
.default(false)
|
|
968
|
+
.describe("Re-download files even if an exact byteSize match already exists on disk."),
|
|
969
|
+
dryRun: z
|
|
970
|
+
.boolean()
|
|
971
|
+
.default(false)
|
|
972
|
+
.describe("Preview planned vs. skipped files and total GB without writing to disk."),
|
|
973
|
+
mode: z
|
|
974
|
+
.enum(["auto", "foreground", "background"])
|
|
975
|
+
.default("auto")
|
|
976
|
+
.describe("'auto' runs foreground <= 100 MB and background > 100 MB to avoid 60s client timeouts."),
|
|
977
|
+
},
|
|
978
|
+
outputSchema: DownloadJobOutputSchema.shape,
|
|
979
|
+
annotations: {
|
|
980
|
+
title: "Download Session",
|
|
981
|
+
readOnlyHint: false,
|
|
982
|
+
destructiveHint: false,
|
|
983
|
+
idempotentHint: true,
|
|
984
|
+
openWorldHint: true,
|
|
985
|
+
},
|
|
986
|
+
}, async (args, extra) => runTool(async () => {
|
|
987
|
+
const progressToken = extra._meta?.progressToken;
|
|
988
|
+
const job = await downloads.startDownload({
|
|
989
|
+
sessionId: args.sessionId,
|
|
990
|
+
destinationDir: args.destinationDir,
|
|
991
|
+
createSubfolder: args.createSubfolder,
|
|
992
|
+
categories: args.categories,
|
|
993
|
+
overwrite: args.overwrite,
|
|
994
|
+
dryRun: args.dryRun,
|
|
995
|
+
mode: args.mode,
|
|
996
|
+
}, {
|
|
997
|
+
signal: extra.signal,
|
|
998
|
+
onProgress: progressToken !== undefined
|
|
999
|
+
? async ({ downloadedBytes, totalBytes, message }) => {
|
|
1000
|
+
await extra.sendNotification({
|
|
1001
|
+
method: "notifications/progress",
|
|
1002
|
+
params: {
|
|
1003
|
+
progressToken,
|
|
1004
|
+
progress: downloadedBytes,
|
|
1005
|
+
total: totalBytes,
|
|
1006
|
+
message,
|
|
1007
|
+
},
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
: undefined,
|
|
1011
|
+
});
|
|
1012
|
+
return formatJobOutput(job);
|
|
1013
|
+
}));
|
|
1014
|
+
// 15. get_download_status
|
|
1015
|
+
server.registerTool("get_download_status", {
|
|
1016
|
+
title: "Get Download Status",
|
|
1017
|
+
description: "Inspect progress, per-file state, and completion status for a background download_session transfer (or list all transfers in this MCP server process).",
|
|
1018
|
+
inputSchema: {
|
|
1019
|
+
downloadId: z
|
|
1020
|
+
.string()
|
|
1021
|
+
.optional()
|
|
1022
|
+
.describe("Specific downloadId returned by download_session; omit to list all transfers."),
|
|
1023
|
+
},
|
|
1024
|
+
outputSchema: {
|
|
1025
|
+
jobs: z.array(DownloadJobOutputSchema),
|
|
1026
|
+
},
|
|
1027
|
+
annotations: {
|
|
1028
|
+
title: "Get Download Status",
|
|
1029
|
+
readOnlyHint: true,
|
|
1030
|
+
destructiveHint: false,
|
|
1031
|
+
idempotentHint: true,
|
|
1032
|
+
openWorldHint: false,
|
|
1033
|
+
},
|
|
1034
|
+
}, async ({ downloadId }) => runTool(async () => {
|
|
1035
|
+
if (downloadId) {
|
|
1036
|
+
const job = downloads.getJob(downloadId);
|
|
1037
|
+
if (!job) {
|
|
1038
|
+
throw new Error(`Download job "${downloadId}" not found in this MCP server session.`);
|
|
1039
|
+
}
|
|
1040
|
+
return { jobs: [formatJobOutput(job)] };
|
|
1041
|
+
}
|
|
1042
|
+
return { jobs: downloads.listJobs().map((j) => formatJobOutput(j)) };
|
|
1043
|
+
}));
|
|
1044
|
+
return server;
|
|
1045
|
+
}
|