@clipy/mcp 0.16.1 → 0.17.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.
Files changed (3) hide show
  1. package/README.md +9 -0
  2. package/dist/index.js +300 -29
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -141,6 +141,15 @@ support@clipy.online.
141
141
  | `list_context_documents` | List the user's **context documents** — YouTube videos and local video files they imported with `clipy context import`, so agents can read them. A separate library from their own screen recordings. |
142
142
  | `get_context_document` | One context document's metadata: source, duration, tags, the server's classification (video type, whether visual evidence is needed, planned moments), and which transcript/frames exist. Not the transcript itself. |
143
143
  | `read_context_document` | Read a context document as compiled markdown — header, metadata, then the timestamped transcript with frame captions interleaved. Takes `startMs`/`endMs` so you can walk a two-hour video section by section instead of flooding your context. |
144
+ | `update_recording` | Rename a recording or edit its description (needs `recordings:write`). |
145
+ | `organize_recording` | File into a folder and add or remove tags (needs `recordings:write`). |
146
+ | `set_recording_privacy` | Switch the share link between public, restricted and private. Never invites or emails anyone (needs `recordings:write`). |
147
+ | `list_folders` / `create_folder` | Folders with ids; create is idempotent by name. |
148
+ | `list_comments` | The comment thread: timestamped comments, replies, resolved state. Author names only (needs `comments:read`). |
149
+ | `add_comment` | Comment at a moment or reply, as the key's owner. Everyone in the thread is notified (needs `comments:write`). |
150
+ | `get_analytics` | Views, unique viewers, completion and who watched (needs `analytics:read`). Free accounts get the totals only. |
151
+ | `upload_video` | Upload a WebM, MP4 or QuickTime `.mov` from this machine and get its share and agent-context links (needs `ingest`). |
152
+ | `delete_recording` | **Permanently** delete a recording. `confirm` must repeat the id (needs `recordings:delete`, from `clipy login --allow-delete`). |
144
153
  | `replace_transcript` | **Replace a recording's transcript** with text you author (needs the `ingest` scope). Call `get_transcript` first and pass its `revision`; stale replacements are rejected instead of overwriting a concurrent edit. The summary regenerates automatically. Marked as agent-edited, never passed off as speech-to-text. |
145
154
 
146
155
  Read tools accept a recording's **public id** (the slug in its share URL) or the full
package/dist/index.js CHANGED
@@ -64,7 +64,7 @@ const CLI_CONFIG = readCliConfig();
64
64
  const API_URL = (process.env.CLIPY_API_URL || CLI_CONFIG.apiUrl || "https://clipy.online").replace(/\/+$/, "");
65
65
  const API_KEY = process.env.CLIPY_API_KEY || CLI_CONFIG.apiKey;
66
66
  const API_KEY_SOURCE = process.env.CLIPY_API_KEY ? "env CLIPY_API_KEY" : CLI_CONFIG.apiKey ? cliConfigPath() : null;
67
- const SERVER_VERSION = "0.16.1";
67
+ const SERVER_VERSION = "0.17.0";
68
68
  /** Every keyless failure points at the same two fixes, cheapest one first. */
69
69
  const MISSING_KEY_MESSAGE = `No Clipy credential. Run \`clipy login\` in a terminal — it writes ${cliConfigPath()}, which this server reads — ` +
70
70
  `or mint a key at ${API_URL}/settings/api-keys and set CLIPY_API_KEY in your MCP client config. ` +
@@ -93,8 +93,13 @@ function actionableApiError(status, message, path) {
93
93
  switch (status) {
94
94
  case 401:
95
95
  return `${message} (HTTP 401 — the Clipy credential ${API_KEY_SOURCE ? `read from ${API_KEY_SOURCE}` : "is missing and"} is invalid, expired, or revoked.) Fix it, then retry: run \`clipy login\` in a terminal to approve this device (it writes ${cliConfigPath()}, which this server reads), or mint a key at ${API_URL}/settings/api-keys and set CLIPY_API_KEY in your MCP client config. Either way the credential is read at startup, so restart the MCP client afterwards. Retrying this call unchanged will fail identically.`;
96
- case 403:
96
+ case 403: {
97
+ const scope = Object.keys(SCOPE_GRANTS).find((s) => message.includes(s));
98
+ if (scope) {
99
+ return `${message} (HTTP 403.) The key lacks "${scope}": ${SCOPE_GRANTS[scope]} at ${API_URL}/settings/api-keys, then restart the MCP client. Retrying with the same key cannot succeed.`;
100
+ }
97
101
  return `${message} (HTTP 403 — the API key is valid but lacks the scope this call needs, or the resource belongs to another account.) ${/\/edit(\?|$)/.test(path) ? 'Video editing (get_edit_transcript, edit_recording) needs a key with the "recordings:write" permission' : 'Write tools need a key with the "ingest" permission'}; mint one at ${API_URL}/settings/api-keys. Retrying with the same key cannot succeed.`;
102
+ }
98
103
  case 404:
99
104
  return `${message} (HTTP 404.) ${notFoundHint}`;
100
105
  case 429:
@@ -252,21 +257,83 @@ async function apiPostJson(path, payload, method = "POST") {
252
257
  }
253
258
  if (!res.ok) {
254
259
  const msg = (typeof body.error === "string" && body.error) || `Clipy API error ${res.status}`;
260
+ // Status and code ride on every error so callers can tell an explicit
261
+ // refusal from an ambiguous failure (see completionWasAmbiguous).
262
+ const detail = { status: res.status, ...(typeof body.code === "string" ? { code: body.code } : {}) };
255
263
  if (res.status === 403) {
256
- throw new Error(/\/edit$/.test(path)
264
+ throw Object.assign(new Error(/\/edit$/.test(path)
257
265
  ? `${msg}\nedit_recording needs an API key with the "recordings:write" permission. ` +
258
266
  `Mint one at ${API_URL}/settings/api-keys.`
259
267
  : `${msg}\nThe record tool needs an API key with the "ingest" permission. ` +
260
- `Mint one at ${API_URL}/settings/api-keys (check "Record & upload").`);
268
+ `Mint one at ${API_URL}/settings/api-keys (check "Record & upload").`), detail);
261
269
  }
262
- throw new Error(msg);
270
+ throw Object.assign(new Error(msg), detail);
263
271
  }
264
272
  return body;
265
273
  }
266
274
  throw new Error(`request failed after retries (${path})`);
267
275
  }
276
+ /** The scope a v1 write needs, named in the 403 so the agent can tell the user exactly what to grant. */
277
+ const SCOPE_GRANTS = {
278
+ "recordings:write": 'run `clipy login` again, or mint a key with "Edit recordings"',
279
+ "comments:read": 'run `clipy login` again, or mint a key with "Read comments"',
280
+ "comments:write": 'run `clipy login` again, or mint a key with "Comment"',
281
+ "analytics:read": 'run `clipy login` again, or mint a key with "View analytics"',
282
+ "recordings:delete": 'run `clipy login --allow-delete`, or mint a key with "Delete recordings"',
283
+ ingest: 'run `clipy login` again, or mint a key with "Record & upload"',
284
+ };
285
+ /**
286
+ * One attempt at a v1 write (PATCH/PUT/POST/DELETE). Never retried: posting a
287
+ * comment twice is worse than reporting a transient failure.
288
+ */
289
+ async function apiSend(method, path, payload) {
290
+ if (!API_KEY)
291
+ throw new Error(MISSING_KEY_MESSAGE);
292
+ const controller = new AbortController();
293
+ const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
294
+ let res;
295
+ let text;
296
+ try {
297
+ res = await fetch(`${API_URL}${path}`, {
298
+ method,
299
+ headers: {
300
+ Authorization: `Bearer ${API_KEY}`,
301
+ Accept: "application/json",
302
+ "User-Agent": `clipy-mcp/${SERVER_VERSION}`,
303
+ ...(payload !== undefined ? { "Content-Type": "application/json" } : {}),
304
+ },
305
+ body: payload !== undefined ? JSON.stringify(payload) : undefined,
306
+ signal: controller.signal,
307
+ });
308
+ text = await res.text();
309
+ }
310
+ catch (e) {
311
+ throw new Error(e.name === "AbortError" ? `request timed out (${path})` : e.message);
312
+ }
313
+ finally {
314
+ clearTimeout(timer);
315
+ }
316
+ let body = {};
317
+ try {
318
+ body = text ? JSON.parse(text) : {};
319
+ }
320
+ catch {
321
+ body = { raw: text };
322
+ }
323
+ if (!res.ok) {
324
+ const msg = (typeof body.error === "string" && body.error) || `Clipy API error ${res.status}`;
325
+ if (res.status === 403) {
326
+ const scope = Object.keys(SCOPE_GRANTS).find((s) => msg.includes(s));
327
+ if (scope) {
328
+ throw new Error(`${msg}\nThe key lacks "${scope}": ${SCOPE_GRANTS[scope]} at ${API_URL}/settings/api-keys, then restart the MCP client. Retrying with the same key cannot succeed.`);
329
+ }
330
+ }
331
+ throw new Error(actionableApiError(res.status, msg, path));
332
+ }
333
+ return body;
334
+ }
268
335
  /** Upload one raw-upload chunk as multipart/form-data, retrying transient 429/5xx. */
269
- async function apiPostChunk(recordingId, uploadToken, partNumber, bytes) {
336
+ async function apiPostChunk(recordingId, uploadToken, partNumber, bytes, container = "webm") {
270
337
  if (!API_KEY)
271
338
  throw new Error(MISSING_KEY_MESSAGE);
272
339
  for (let attempt = 1; attempt <= 4; attempt++) {
@@ -277,7 +344,7 @@ async function apiPostChunk(recordingId, uploadToken, partNumber, bytes) {
277
344
  form.append("recordingId", recordingId);
278
345
  form.append("uploadToken", uploadToken);
279
346
  form.append("partNumber", String(partNumber));
280
- form.append("file", new Blob([part], { type: "video/webm" }), `part-${partNumber}.webm`);
347
+ form.append("file", new Blob([part], { type: container === "mp4" ? "video/mp4" : "video/webm" }), `part-${partNumber}.${container}`);
281
348
  const controller = new AbortController();
282
349
  const timer = setTimeout(() => controller.abort(), 120_000);
283
350
  let res;
@@ -324,23 +391,28 @@ async function loadChromium() {
324
391
  throw new Error("The record tool needs Playwright (a headless browser). Install it in the environment " +
325
392
  "running this MCP server: npm install -g playwright && npx playwright install chromium");
326
393
  }
327
- /** WebM files start with the EBML magic; refuse to upload corrupt captures. */
328
- function validateWebmFile(videoPath) {
329
- const size = statSync(videoPath).size;
330
- if (size === 0)
331
- throw new Error("recording produced an empty file");
394
+ /** WebM starts with the EBML magic; MP4 and QuickTime .mov carry `ftyp` at byte 4. */
395
+ function validateVideoFile(videoPath) {
396
+ const stat = statSync(videoPath);
397
+ if (!stat.isFile())
398
+ throw new Error(`not a file: ${videoPath}`);
399
+ if (stat.size === 0)
400
+ throw new Error("the video file is empty");
332
401
  const fd = openSync(videoPath, "r");
333
402
  try {
334
- const head = Buffer.alloc(4);
335
- readSync(fd, head, 0, 4, 0);
336
- if (!(head[0] === 0x1a && head[1] === 0x45 && head[2] === 0xdf && head[3] === 0xa3)) {
337
- throw new Error("recording file is not valid WebM (corrupt capture?)");
403
+ const head = Buffer.alloc(8);
404
+ const read = readSync(fd, head, 0, 8, 0);
405
+ if (read >= 4 && head[0] === 0x1a && head[1] === 0x45 && head[2] === 0xdf && head[3] === 0xa3) {
406
+ return { sizeBytes: stat.size, container: "webm" };
338
407
  }
408
+ if (read >= 8 && head.subarray(4, 8).toString("ascii") === "ftyp") {
409
+ return { sizeBytes: stat.size, container: "mp4" };
410
+ }
411
+ throw new Error("the file is not WebM or MP4 (a QuickTime .mov also works)");
339
412
  }
340
413
  finally {
341
414
  closeSync(fd);
342
415
  }
343
- return size;
344
416
  }
345
417
  /** Diagnostic line to stderr (the only channel a stdio MCP server can log to
346
418
  * without corrupting the protocol on stdout). */
@@ -928,12 +1000,12 @@ async function openCaptureContext(chromium, opts) {
928
1000
  return { context, page, browser };
929
1001
  }
930
1002
  /**
931
- * Streams a captured WebM through the raw-upload pipeline
932
- * (initiate → chunks → finalize → complete). Shared by the one-shot `record`
933
- * tool and the session tools. Aborts the server-side session on failure.
1003
+ * Streams a WebM or MP4 through the raw-upload pipeline
1004
+ * (initiate → chunks → finalize → complete). Shared by the `record` tool, the
1005
+ * session tools and `upload_video`. Aborts the server-side session on failure.
934
1006
  */
935
- async function uploadCapturedWebm(opts) {
936
- const sizeBytes = validateWebmFile(opts.videoPath);
1007
+ async function uploadVideoFile(opts) {
1008
+ const { sizeBytes, container } = validateVideoFile(opts.videoPath);
937
1009
  const recordingId = randomUUID();
938
1010
  let uploadToken = "";
939
1011
  let publicId = "";
@@ -941,7 +1013,7 @@ async function uploadCapturedWebm(opts) {
941
1013
  const init = await apiPostJson("/api/videos/raw-upload/initiate", {
942
1014
  recordingId,
943
1015
  createVideoRow: true,
944
- sourcePlatform: "web",
1016
+ sourcePlatform: "mcp",
945
1017
  sourceVersion: `mcp/${SERVER_VERSION}`,
946
1018
  });
947
1019
  uploadToken = String(init.uploadToken ?? "");
@@ -958,7 +1030,7 @@ async function uploadCapturedWebm(opts) {
958
1030
  const bytesRead = readSync(fd, buffer, 0, PART_SIZE, offset);
959
1031
  if (bytesRead <= 0)
960
1032
  break;
961
- await apiPostChunk(recordingId, uploadToken, partNumber, buffer.subarray(0, bytesRead));
1033
+ await apiPostChunk(recordingId, uploadToken, partNumber, buffer.subarray(0, bytesRead), container);
962
1034
  offset += bytesRead;
963
1035
  partNumber++;
964
1036
  }
@@ -972,8 +1044,10 @@ async function uploadCapturedWebm(opts) {
972
1044
  uploadToken,
973
1045
  name: opts.name,
974
1046
  description: opts.description,
975
- sourcePlatform: "web",
1047
+ sourcePlatform: "mcp",
976
1048
  sourceVersion: `mcp/${SERVER_VERSION}`,
1049
+ ...(opts.nameIsUserProvided && opts.name ? { nameIsUserProvided: true } : {}),
1050
+ ...(opts.accessMode ? { accessMode: opts.accessMode } : {}),
977
1051
  ...(opts.recordingKind ? { recordingKind: opts.recordingKind } : {}),
978
1052
  ...(opts.narration && (opts.narration.text || opts.narration.notes?.length)
979
1053
  ? { narration: opts.narration }
@@ -982,13 +1056,50 @@ async function uploadCapturedWebm(opts) {
982
1056
  uploadToken = ""; // completed — nothing to abort
983
1057
  }
984
1058
  catch (e) {
1059
+ // A /complete whose responses were all lost may still have committed; the
1060
+ // server then refuses the abort as already_attached, which proves the
1061
+ // recording exists. Reporting failure would invite a duplicate upload.
1062
+ // An explicit answer from the route (503 access_mode_pending, queue_pending,
1063
+ // claim_pending) is not a success, but the recording exists: the error
1064
+ // names it so the agent never uploads the file again.
1065
+ // A coded pending answer already says the recording exists or is being
1066
+ // committed: name it directly, without depending on an abort that could
1067
+ // itself fail, and without aborting a commit still in flight.
1068
+ const code = e.code;
1069
+ if (publicId && code === "access_mode_pending") {
1070
+ throw new Error(`Uploaded as ${publicId}, but the requested sharing (${opts.accessMode ?? "default"}) could not be applied, so it may still be readable at the account's default access. Do not upload again: call set_recording_privacy with id "${publicId}" to set it.`);
1071
+ }
1072
+ if (publicId && code && PENDING_COMPLETION_CODES.has(code)) {
1073
+ throw new Error(`Uploaded as ${publicId}, but the server did not confirm its completion (${e.message}). Do not upload again: the recording exists; check it with get_recording id "${publicId}".`);
1074
+ }
1075
+ let attached = false;
985
1076
  if (uploadToken) {
986
- await apiPostJson("/api/videos/raw-upload/abort", { recordingId, uploadToken }).catch(() => { });
1077
+ await apiPostJson("/api/videos/raw-upload/abort", { recordingId, uploadToken }).catch((abortError) => {
1078
+ attached = abortError.code === "already_attached";
1079
+ });
1080
+ }
1081
+ if (!publicId || !attached)
1082
+ throw e;
1083
+ if (!completionWasAmbiguous(e)) {
1084
+ throw new Error(`Uploaded as ${publicId}, but the server did not confirm its completion (${e.message}). Do not upload again: the recording exists; check it with get_recording id "${publicId}".`);
987
1085
  }
988
- throw e;
989
1086
  }
990
1087
  return { publicId, sizeBytes };
991
1088
  }
1089
+ /**
1090
+ * Whether a failed /complete may have committed unseen: no HTTP response at
1091
+ * all (network error, timeout), or a 502/504 from the gateway in front of the
1092
+ * app. Every answer the route itself gives (503 access_mode_pending, a 500
1093
+ * that marked the recording failed) is explicit and never a success.
1094
+ */
1095
+ /** /complete answers that mean the recording exists or is being committed. */
1096
+ const PENDING_COMPLETION_CODES = new Set(["access_mode_pending", "queue_pending", "claim_pending"]);
1097
+ function completionWasAmbiguous(error) {
1098
+ const { status, code } = error;
1099
+ if (typeof status !== "number")
1100
+ return true;
1101
+ return !code && (status === 502 || status === 504);
1102
+ }
992
1103
  function ok(data) {
993
1104
  return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
994
1105
  }
@@ -1912,7 +2023,7 @@ server.tool("record", "Record a web app HEADLESSLY and upload it as a Clipy reco
1912
2023
  text: n.text.trim(),
1913
2024
  }));
1914
2025
  const allNotes = [...autoNotes, ...userNotes].sort((a, b) => a.startMs - b.startMs);
1915
- const uploaded = await uploadCapturedWebm({
2026
+ const uploaded = await uploadVideoFile({
1916
2027
  videoPath,
1917
2028
  name,
1918
2029
  description,
@@ -2027,7 +2138,7 @@ function finishSession(session, mode) {
2027
2138
  if (verificationNote)
2028
2139
  collected.unshift({ startMs: 0, text: verificationNote });
2029
2140
  const notes = collected.sort((a, b) => a.startMs - b.startMs);
2030
- const uploaded = await uploadCapturedWebm({
2141
+ const uploaded = await uploadVideoFile({
2031
2142
  videoPath,
2032
2143
  name: session.name,
2033
2144
  description: session.description,
@@ -2868,6 +2979,166 @@ server.tool("read_context_document", "Read a context document as compiled markdo
2868
2979
  return fail(e.message);
2869
2980
  }
2870
2981
  });
2982
+ // ---------------------------------------------------------------------------
2983
+ // Library management: the write half the hosted server already had (update,
2984
+ // organize, sharing, folders), plus comments, analytics, upload and delete.
2985
+ // ---------------------------------------------------------------------------
2986
+ function recordingPath(id, sub = "") {
2987
+ return `/api/v1/recordings/${encodeURIComponent(normalizeId(id))}${sub}`;
2988
+ }
2989
+ server.tool("update_recording", "Rename a recording or rewrite its description. Renaming also stops Clipy's auto-titling from overwriting the name later. Pass description: null to clear it. Needs a key with recordings:write.", {
2990
+ id: recordingIdSchema,
2991
+ name: z.string().min(1).max(200).optional().describe("The new title. Omit to leave the title alone."),
2992
+ description: z.string().max(5000).nullable().optional().describe("The new description, or null to clear it."),
2993
+ }, { title: "Update a Clipy recording", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true }, async ({ id, name, description }) => {
2994
+ try {
2995
+ const body = {};
2996
+ if (name !== undefined)
2997
+ body.name = name;
2998
+ if (description !== undefined)
2999
+ body.description = description;
3000
+ if (Object.keys(body).length === 0)
3001
+ return fail("Pass name and/or description.");
3002
+ return ok(await apiSend("PATCH", recordingPath(id), body));
3003
+ }
3004
+ catch (e) {
3005
+ return fail(e.message);
3006
+ }
3007
+ });
3008
+ server.tool("organize_recording", "File a recording into a folder and/or change its tags. Get folder ids from list_folders (or create_folder); pass folderId: null to unfile it. Needs recordings:write.", {
3009
+ id: recordingIdSchema,
3010
+ folderId: z.string().nullable().optional().describe("Destination folder id from list_folders, or null to unfile."),
3011
+ addTags: z.array(z.string()).optional().describe("Tags to add (max 20 on a recording)."),
3012
+ removeTags: z.array(z.string()).optional().describe("Tags to remove."),
3013
+ }, { title: "Organize a Clipy recording", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false }, async ({ id, folderId, addTags, removeTags }) => {
3014
+ try {
3015
+ const body = {};
3016
+ if (folderId !== undefined)
3017
+ body.folderId = folderId;
3018
+ if (addTags)
3019
+ body.addTags = addTags;
3020
+ if (removeTags)
3021
+ body.removeTags = removeTags;
3022
+ return ok(await apiSend("PATCH", recordingPath(id, "/organize"), body));
3023
+ }
3024
+ catch (e) {
3025
+ return fail(e.message);
3026
+ }
3027
+ });
3028
+ server.tool("set_recording_privacy", "Change who can open a recording's share link: 'public' (anyone with the link), 'restricted' (only the people and domains already on its list), or 'private' (owner only). It never invites or emails anyone. Confirm with the user before making a private recording public. Needs recordings:write.", {
3029
+ id: recordingIdSchema,
3030
+ mode: z.enum(["public", "restricted", "private"]),
3031
+ }, { title: "Change a Clipy recording’s sharing", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true }, async ({ id, mode }) => {
3032
+ try {
3033
+ return ok(await apiSend("PUT", recordingPath(id, "/access"), { mode }));
3034
+ }
3035
+ catch (e) {
3036
+ return fail(e.message);
3037
+ }
3038
+ });
3039
+ server.tool("list_folders", "List the user's folders with ids and item counts. Call this before organize_recording to turn a folder name into its id.", {}, { title: "List Clipy folders", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false }, async () => {
3040
+ try {
3041
+ return ok(await api("/api/v1/folders"));
3042
+ }
3043
+ catch (e) {
3044
+ return fail(e.message);
3045
+ }
3046
+ });
3047
+ server.tool("create_folder", "Create a folder. If one with that name exists it is returned instead (the response's `created` says which). Needs recordings:write.", { name: z.string().min(1).max(60) }, { title: "Create a Clipy folder", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false }, async ({ name }) => {
3048
+ try {
3049
+ return ok(await apiSend("POST", "/api/v1/folders", { name }));
3050
+ }
3051
+ catch (e) {
3052
+ return fail(e.message);
3053
+ }
3054
+ });
3055
+ server.tool("list_comments", "Read the comment thread on a recording: top-level comments with the moment they point at (timestampMs), replies (parentCommentId), and resolved state. Use it to see what reviewers flagged. Author names only. Needs comments:read.", { id: recordingIdSchema }, { title: "List comments on a recording", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false }, async ({ id }) => {
3056
+ try {
3057
+ return ok(await api(recordingPath(id, "/comments")));
3058
+ }
3059
+ catch (e) {
3060
+ return fail(e.message);
3061
+ }
3062
+ });
3063
+ server.tool("add_comment", "Post a comment on a recording the user owns, under the user's name: a new comment pinned to timestampMs, or a reply when parentCommentId is given. Everyone in the thread is notified, so show the user the exact text and get their go-ahead first. Needs comments:write.", {
3064
+ id: recordingIdSchema,
3065
+ body: z.string().min(1).max(2000).describe("The comment text."),
3066
+ timestampMs: z.number().int().min(0).optional().describe("Where in the video the comment points (new comments)."),
3067
+ parentCommentId: z.string().optional().describe("Reply to this comment from list_comments."),
3068
+ }, { title: "Comment on a Clipy recording", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true }, async ({ id, body, timestampMs, parentCommentId }) => {
3069
+ try {
3070
+ const payload = parentCommentId
3071
+ ? { kind: "reply", body, parentCommentId }
3072
+ : { kind: "comment", body, timestampMs: timestampMs ?? 0 };
3073
+ return ok(await apiSend("POST", recordingPath(id, "/comments"), payload));
3074
+ }
3075
+ catch (e) {
3076
+ return fail(e.message);
3077
+ }
3078
+ });
3079
+ server.tool("get_analytics", "Who watched a recording and how far: opens, unique viewers, plays, average completion, retention, viewers by name, breakdowns. Pro feature; a free account gets gated:true with the totals only. Needs analytics:read.", {
3080
+ id: recordingIdSchema,
3081
+ rangeDays: z.number().int().min(1).max(365).optional().describe("Days in the daily series (default 30). Every other figure is lifetime."),
3082
+ }, { title: "Get recording analytics", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false }, async ({ id, rangeDays }) => {
3083
+ try {
3084
+ return ok(await api(`${recordingPath(id, "/analytics")}${rangeDays ? `?range=${rangeDays}` : ""}`));
3085
+ }
3086
+ catch (e) {
3087
+ return fail(e.message);
3088
+ }
3089
+ });
3090
+ server.tool("upload_video", "Upload a video file from this machine (WebM, MP4, or QuickTime .mov) to the user's Clipy library and return its share link and agent-context link. Processing (transcript, summary, key moments) starts automatically; call wait_for_artifacts next if you need them. Counts toward the user's recording allowance. Needs a key with ingest.", {
3091
+ path: z.string().describe("Absolute path of the video file."),
3092
+ name: z.string().min(1).max(200).optional().describe("Title. Defaults to the file name."),
3093
+ description: z.string().max(5000).optional(),
3094
+ type: z.string().optional().describe("What the video is: bug, feature, demo, walkthrough, feedback, discussion or other."),
3095
+ access: z.enum(["public", "restricted", "private"]).optional().describe("Who can open the link. Omit for the account default."),
3096
+ }, { title: "Upload a video to Clipy", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true }, async ({ path, name, description, type, access }) => {
3097
+ try {
3098
+ const videoPath = resolve(path);
3099
+ if (!existsSync(videoPath))
3100
+ return fail(`No such file: ${videoPath}`);
3101
+ let recordingKind;
3102
+ if (type) {
3103
+ recordingKind = normalizeRecordingKind(type) ?? undefined;
3104
+ if (!recordingKind)
3105
+ return fail(`type "${type}" is not a recording kind (bug, feature, demo, walkthrough, feedback, discussion, other).`);
3106
+ }
3107
+ const title = name ?? basename(videoPath).replace(/\.[^.]+$/, "");
3108
+ const uploaded = await uploadVideoFile({
3109
+ videoPath,
3110
+ name: title,
3111
+ nameIsUserProvided: name !== undefined,
3112
+ description,
3113
+ recordingKind,
3114
+ accessMode: access,
3115
+ });
3116
+ return ok({
3117
+ publicId: uploaded.publicId,
3118
+ shareUrl: `${API_URL}/video/${uploaded.publicId}`,
3119
+ contextUrl: `${API_URL}/video/${uploaded.publicId}.arec`,
3120
+ sizeBytes: uploaded.sizeBytes,
3121
+ });
3122
+ }
3123
+ catch (e) {
3124
+ return fail(e.message);
3125
+ }
3126
+ });
3127
+ server.tool("delete_recording", "PERMANENTLY delete a recording: video, transcript, summary, key moments and comments. There is no trash and no undo. Only call this when the user explicitly asked to delete this specific recording, and repeat its id in `confirm`. Needs a key with recordings:delete (`clipy login --allow-delete`).", {
3128
+ id: recordingIdSchema,
3129
+ confirm: z.string().describe("The recording's public id again. Must match `id` exactly."),
3130
+ }, { title: "Permanently delete a Clipy recording", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false }, async ({ id, confirm }) => {
3131
+ try {
3132
+ const publicId = normalizeId(id);
3133
+ if (normalizeId(confirm) !== publicId) {
3134
+ return fail("confirm must repeat the recording's id exactly. Nothing was deleted.");
3135
+ }
3136
+ return ok(await apiSend("DELETE", `${recordingPath(publicId)}?confirm=${encodeURIComponent(publicId)}`));
3137
+ }
3138
+ catch (e) {
3139
+ return fail(e.message);
3140
+ }
3141
+ });
2871
3142
  async function main() {
2872
3143
  const transport = new StdioServerTransport();
2873
3144
  await server.connect(transport);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clipy/mcp",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "mcpName": "online.clipy/mcp",
5
5
  "description": "Model Context Protocol (MCP) server for Clipy \u2014 give Claude, Cursor, and other AI agents read access to your screen recordings' transcripts, AI summaries, and key moments with frames.",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "build": "tsc",
34
34
  "prepublishOnly": "npm run build",
35
35
  "start": "node dist/index.js",
36
- "test": "npm run build && node scripts/agent-readiness.test.mjs && node scripts/arec-range.test.mjs && node scripts/browser-diagnostics.test.mjs"
36
+ "test": "npm run build && node scripts/agent-readiness.test.mjs && node scripts/arec-range.test.mjs && node scripts/browser-diagnostics.test.mjs && node scripts/library-tools.test.mjs"
37
37
  },
38
38
  "dependencies": {
39
39
  "@modelcontextprotocol/sdk": "^1.12.0",