@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
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
export function normalizeOrigin(raw) {
|
|
2
|
+
const value = (raw?.trim() || "https://rec.audrow.com").replace(/\/+$/, "");
|
|
3
|
+
const parsed = new URL(value);
|
|
4
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
|
|
5
|
+
throw new Error(`Unsupported VCR_ORIGIN protocol: ${parsed.protocol}`);
|
|
6
|
+
}
|
|
7
|
+
return parsed.origin;
|
|
8
|
+
}
|
|
9
|
+
export function parseIsoToMs(iso, fieldName = "scheduledStartIso") {
|
|
10
|
+
const ms = Date.parse(iso);
|
|
11
|
+
if (!Number.isFinite(ms) || ms <= 0) {
|
|
12
|
+
throw new Error(`Invalid ISO-8601 timestamp for ${fieldName}: "${iso}"`);
|
|
13
|
+
}
|
|
14
|
+
return Math.round(ms);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parse a Marker timecode ("HH:MM:SS", "HH:MM:SS.mmm", "MM:SS", or raw seconds like "95.5") into milliseconds.
|
|
18
|
+
*/
|
|
19
|
+
export function parseTimecodeToMs(raw) {
|
|
20
|
+
const cleaned = raw.trim();
|
|
21
|
+
if (!cleaned)
|
|
22
|
+
throw new Error("Timecode cannot be empty.");
|
|
23
|
+
if (/^\d+(\.\d+)?$/.test(cleaned)) {
|
|
24
|
+
const sec = Number(cleaned);
|
|
25
|
+
if (!Number.isFinite(sec) || sec < 0)
|
|
26
|
+
throw new Error(`Invalid timecode: "${raw}"`);
|
|
27
|
+
return Math.round(sec * 1000);
|
|
28
|
+
}
|
|
29
|
+
const parts = cleaned.split(":");
|
|
30
|
+
if (parts.length !== 2 && parts.length !== 3 && parts.length !== 4) {
|
|
31
|
+
throw new Error(`Invalid timecode "${raw}". Expected HH:MM:SS, HH:MM:SS:FF, MM:SS, or seconds.`);
|
|
32
|
+
}
|
|
33
|
+
if (parts.some((p) => !p.trim())) {
|
|
34
|
+
throw new Error(`Invalid timecode "${raw}".`);
|
|
35
|
+
}
|
|
36
|
+
const nums = parts.map((p) => Number(p));
|
|
37
|
+
if (nums.some((n) => !Number.isFinite(n) || n < 0)) {
|
|
38
|
+
throw new Error(`Invalid timecode "${raw}".`);
|
|
39
|
+
}
|
|
40
|
+
const seconds = parts.length === 4
|
|
41
|
+
? nums[0] * 3600 + nums[1] * 60 + nums[2] + nums[3] / 30
|
|
42
|
+
: parts.length === 3
|
|
43
|
+
? nums[0] * 3600 + nums[1] * 60 + nums[2]
|
|
44
|
+
: nums[0] * 60 + nums[1];
|
|
45
|
+
return Math.round(seconds * 1000);
|
|
46
|
+
}
|
|
47
|
+
export function formatBytes(bytes) {
|
|
48
|
+
if (!Number.isFinite(bytes) || bytes < 0)
|
|
49
|
+
return "0 B";
|
|
50
|
+
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
51
|
+
let val = bytes;
|
|
52
|
+
let idx = 0;
|
|
53
|
+
while (val >= 1024 && idx < units.length - 1) {
|
|
54
|
+
val /= 1024;
|
|
55
|
+
idx++;
|
|
56
|
+
}
|
|
57
|
+
return `${val >= 10 || idx === 0 ? val.toFixed(idx === 0 ? 0 : 1) : val.toFixed(2)} ${units[idx]}`;
|
|
58
|
+
}
|
|
59
|
+
export function sanitizeFolderSegment(raw) {
|
|
60
|
+
const cleaned = raw
|
|
61
|
+
.normalize("NFKD")
|
|
62
|
+
.replace(/[\u0300-\u036f]/g, "")
|
|
63
|
+
.replace(/[^a-zA-Z0-9._-]+/g, "_")
|
|
64
|
+
.replace(/^[._-]+|[._-]+$/g, "")
|
|
65
|
+
.slice(0, 64);
|
|
66
|
+
if (!cleaned || cleaned === "." || cleaned === ".." || cleaned.includes("..")) {
|
|
67
|
+
return "session";
|
|
68
|
+
}
|
|
69
|
+
return cleaned;
|
|
70
|
+
}
|
|
71
|
+
export function buildSessionFolderName(session) {
|
|
72
|
+
const ts = session.startedAtMs && session.startedAtMs > 0
|
|
73
|
+
? session.startedAtMs
|
|
74
|
+
: session.createdAt && session.createdAt > 0
|
|
75
|
+
? session.createdAt
|
|
76
|
+
: Date.now();
|
|
77
|
+
const d = new Date(ts);
|
|
78
|
+
const yyyy = d.getUTCFullYear();
|
|
79
|
+
const mm = String(d.getUTCMonth() + 1).padStart(2, "0");
|
|
80
|
+
const dd = String(d.getUTCDate()).padStart(2, "0");
|
|
81
|
+
const titlePart = sanitizeFolderSegment(session.title);
|
|
82
|
+
const shortId = sanitizeFolderSegment(session.id.replace(/^sess_/, "").slice(0, 8));
|
|
83
|
+
return `${yyyy}-${mm}-${dd}_${titlePart}_${shortId}`;
|
|
84
|
+
}
|
|
85
|
+
export function formatScheduledTimeUtc(ms) {
|
|
86
|
+
try {
|
|
87
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
88
|
+
weekday: "short",
|
|
89
|
+
month: "short",
|
|
90
|
+
day: "numeric",
|
|
91
|
+
hour: "numeric",
|
|
92
|
+
minute: "2-digit",
|
|
93
|
+
timeZoneName: "short",
|
|
94
|
+
}).format(new Date(ms));
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return new Date(ms).toISOString();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export function buildInviteBlurb(input) {
|
|
101
|
+
const greeting = input.guestName ? `Hi ${input.guestName}, ` : "Hi, ";
|
|
102
|
+
const whenLine = input.scheduledStartAtMs
|
|
103
|
+
? `\nWhen: ${formatScheduledTimeUtc(input.scheduledStartAtMs)}`
|
|
104
|
+
: "";
|
|
105
|
+
return (`${greeting}you're invited to record "${input.sessionTitle}" with ${input.hostName}.` +
|
|
106
|
+
whenLine +
|
|
107
|
+
`\nJoin link: ${input.inviteUrl}` +
|
|
108
|
+
`\n(No account needed — open in Chrome, Edge, Safari, or Firefox to check your mic & camera.)`);
|
|
109
|
+
}
|
|
110
|
+
function escapeIcsText(raw) {
|
|
111
|
+
return raw
|
|
112
|
+
.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, "")
|
|
113
|
+
.replace(/\\/g, "\\\\")
|
|
114
|
+
.replace(/\r\n|\r|\n/g, "\\n")
|
|
115
|
+
.replace(/,/g, "\\,")
|
|
116
|
+
.replace(/;/g, "\\;");
|
|
117
|
+
}
|
|
118
|
+
function formatIcsUtc(ms) {
|
|
119
|
+
const d = new Date(ms);
|
|
120
|
+
const p = (n) => String(n).padStart(2, "0");
|
|
121
|
+
return `${d.getUTCFullYear()}${p(d.getUTCMonth() + 1)}${p(d.getUTCDate())}T${p(d.getUTCHours())}${p(d.getUTCMinutes())}${p(d.getUTCSeconds())}Z`;
|
|
122
|
+
}
|
|
123
|
+
export function buildSessionIcs(input) {
|
|
124
|
+
const durationMs = (input.durationMinutes ?? 60) * 60_000;
|
|
125
|
+
const dtStart = formatIcsUtc(input.scheduledStartAtMs);
|
|
126
|
+
const dtEnd = formatIcsUtc(input.scheduledStartAtMs + durationMs);
|
|
127
|
+
const dtStamp = formatIcsUtc(Date.now());
|
|
128
|
+
const desc = `Recording Session in ${input.roomName} hosted by ${input.hostName}.\nJoin link: ${input.inviteUrl}`;
|
|
129
|
+
return [
|
|
130
|
+
"BEGIN:VCALENDAR",
|
|
131
|
+
"VERSION:2.0",
|
|
132
|
+
"PRODID:-//TapeDock//Planned Session//EN",
|
|
133
|
+
"CALSCALE:GREGORIAN",
|
|
134
|
+
"BEGIN:VEVENT",
|
|
135
|
+
`UID:${escapeIcsText(input.sessionId)}@tapedock.com`,
|
|
136
|
+
`DTSTAMP:${dtStamp}`,
|
|
137
|
+
`DTSTART:${dtStart}`,
|
|
138
|
+
`DTEND:${dtEnd}`,
|
|
139
|
+
`SUMMARY:${escapeIcsText(`Record: ${input.sessionTitle}`)}`,
|
|
140
|
+
`DESCRIPTION:${escapeIcsText(desc)}`,
|
|
141
|
+
`LOCATION:${escapeIcsText(input.inviteUrl)}`,
|
|
142
|
+
"END:VEVENT",
|
|
143
|
+
"END:VCALENDAR",
|
|
144
|
+
"",
|
|
145
|
+
].join("\r\n");
|
|
146
|
+
}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { VcrApiClient } from "./api/client.js";
|
|
3
|
+
import { DownloadManager } from "./downloads/manager.js";
|
|
4
|
+
export interface VcrMcpServerDeps {
|
|
5
|
+
api: VcrApiClient;
|
|
6
|
+
downloads: DownloadManager;
|
|
7
|
+
}
|
|
8
|
+
export declare function createVcrMcpServer(deps: VcrMcpServerDeps): McpServer;
|