@clipy/mcp 0.8.4 → 0.8.5

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 +27 -0
  2. package/dist/index.js +63 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -174,6 +174,33 @@ cross-origin auth). For a full identity, pass `userDataDir` — Chrome's **user-
174
174
 
175
175
  `storageState` and `userDataDir` are mutually exclusive; `profileDirectory` requires `userDataDir`.
176
176
 
177
+ ### Check the camera before you work
178
+
179
+ `record` and `start_recording` both return a `source` object describing **what is actually
180
+ being recorded**, resolved fresh at start time — the post-redirect `url`, the page `title`,
181
+ and the recording `viewport`:
182
+
183
+ ```json
184
+ "source": {
185
+ "kind": "headless_browser",
186
+ "title": "Orders — Admin",
187
+ "url": "https://app.example.com/orders",
188
+ "viewport": { "width": 1280, "height": 720 }
189
+ }
190
+ ```
191
+
192
+ Compare it against the surface your driver is acting on **before** doing minutes of work.
193
+ This exists because driver-attested evidence proves what the *driver* observed and nothing
194
+ ties it to what the *camera* saw — it's entirely possible to produce truthful marks over
195
+ footage of the wrong thing. **Clipy will never focus or foreground a window or tab for you**;
196
+ pointing the driver and the camera at the same surface is the caller's job.
197
+
198
+ `kind` is always `headless_browser` here: these tools record a headless page Clipy owns.
199
+ Capturing a real application window or display is CLI-only
200
+ (`clipy record --source mac-screen --window "<app>"`), so no window id or window title is
201
+ reported — an empty or invented one would be exactly the kind of false confidence this
202
+ field exists to prevent.
203
+
177
204
  ### Evidence on a marker: two provenances
178
205
 
179
206
  `add_marker` can carry evidence in exactly one of two provenances — they are tallied and rendered
package/dist/index.js CHANGED
@@ -33,7 +33,7 @@ import { Readable } from "node:stream";
33
33
  import { pipeline } from "node:stream/promises";
34
34
  const API_URL = (process.env.CLIPY_API_URL || "https://clipy.online").replace(/\/+$/, "");
35
35
  const API_KEY = process.env.CLIPY_API_KEY;
36
- const SERVER_VERSION = "0.8.4";
36
+ const SERVER_VERSION = "0.8.5";
37
37
  // The key is checked lazily (per tool call, not at startup) so the server can
38
38
  // start and answer introspection (initialize / tools/list) in keyless
39
39
  // environments like directory health checks.
@@ -709,6 +709,53 @@ function profileCopyDisclosure(copy, userDataDir) {
709
709
  ...(copy.skipped.length ? { skippedEntries: copy.skipped } : {}),
710
710
  };
711
711
  }
712
+ // --- Resolved capture source ------------------------------------------------
713
+ // Field finding (0.8.5): a window capture whose driver was driving a BACKGROUND
714
+ // TAB of that window produced perfectly truthful driver-attested marks over
715
+ // footage of the wrong tab. Attested evidence proves what the DRIVER observed;
716
+ // nothing tied it to what the CAMERA saw. The fix is to report the RESOLVED
717
+ // capture source at start time so a caller can compare it against the surface it
718
+ // is driving BEFORE doing minutes of work.
719
+ //
720
+ // REJECTED FIX — do not reopen: having the recorder foreground/activate the
721
+ // target window or tab. That fails the any-driver gate and re-imports the
722
+ // browser-ownership premise deliberately removed in 0.8.3. Clipy is a recorder;
723
+ // it reports what the camera sees and never moves the camera for you.
724
+ //
725
+ // This server only ever captures a headless Chromium page it owns — the
726
+ // window/display (mac-screen) path is CLI-only — so there is no window id or
727
+ // window title to report here. Rather than emit a {kind,id,title} shell with
728
+ // invented or empty values (exactly the false-identity failure this exists to
729
+ // prevent), we report what IS true of a headless capture: the RESOLVED post-
730
+ // redirect URL, the page title, and the recording viewport.
731
+ /** Resolve what the camera is actually pointed at, read fresh at start time —
732
+ * never a stale or caller-supplied value. */
733
+ async function resolveHeadlessSource(page, viewport) {
734
+ let url = "";
735
+ try {
736
+ url = page.url();
737
+ }
738
+ catch {
739
+ url = "";
740
+ }
741
+ let title = "";
742
+ try {
743
+ // Bounded: a wedged page must not hold up the tool result.
744
+ title = (await withTimeout(page.title(), 2_000, "title read timed out")).trim().slice(0, 200);
745
+ }
746
+ catch {
747
+ title = "";
748
+ }
749
+ return {
750
+ kind: "headless_browser",
751
+ ...(title ? { title } : {}),
752
+ url,
753
+ viewport: { width: viewport.width, height: viewport.height },
754
+ note: "This is the surface Clipy is recording. Compare it with what your driver is acting on — " +
755
+ "matching it is YOUR job: Clipy never focuses or foregrounds a window or tab. " +
756
+ "Window/display capture (a real app window) is CLI-only: clipy record --source mac-screen.",
757
+ };
758
+ }
712
759
  /** First line of an error message, trimmed — keeps annotations/logs one-line. */
713
760
  function firstLine(message) {
714
761
  return (message ?? "").split("\n")[0].trim();
@@ -1290,7 +1337,7 @@ server.tool("get_agent_context", "ONE-CALL CONTEXT BUNDLE for a recording: metad
1290
1337
  return fail(e.message);
1291
1338
  }
1292
1339
  });
1293
- server.tool("record", "Record a web app HEADLESSLY and upload it as a Clipy recording, then return its share link + agent-context URL. Use this to capture the outcome of work you just did — e.g. after building a feature, record the running app so it can be shared or read back. Opens the given URL in a headless Chromium (works in cloud sandboxes, no display needed), records for `durationSeconds`, and streams the video into Clipy's pipeline. Set `type` so the summary reads the recording correctly, `viewports` to sweep multiple screen sizes into one video, and `storageState`/`initScript`/`userDataDir` to record behind a login. Requires (1) Playwright installed in this MCP server's environment (`npm i -g playwright && npx playwright install chromium`) and (2) the CLIPY_API_KEY to carry the 'ingest' scope. Recording the REAL Mac screen or a specific window (ScreenCaptureKit, real logged-in browser) is CLI-only — `clipy record --source mac-screen --window \"<app>\"` — and not available via MCP. Quick per-cookie / per-localStorage-key injection (the CLI's `--cookie` / `--local-storage`) is a CLI-only convenience; `storageState` covers the same need here. Auth note: `storageState` seeds exactly what it contains (cookies + localStorage) but can't reproduce a whole browser identity (IndexedDB, service workers, some cross-origin auth); for those, produce a storageState via an interactive `npx playwright open --save-storage=state.json <login-url>` first, or use `userDataDir` pointed at a DEDICATED (never live) profile directory. After it returns, call wait_for_artifacts then get_agent_context to read the transcript/summary.", {
1340
+ server.tool("record", "Record a web app HEADLESSLY and upload it as a Clipy recording, then return its share link + agent-context URL. Use this to capture the outcome of work you just did — e.g. after building a feature, record the running app so it can be shared or read back. Opens the given URL in a headless Chromium (works in cloud sandboxes, no display needed), records for `durationSeconds`, and streams the video into Clipy's pipeline. Set `type` so the summary reads the recording correctly, `viewports` to sweep multiple screen sizes into one video, and `storageState`/`initScript`/`userDataDir` to record behind a login. Requires (1) Playwright installed in this MCP server's environment (`npm i -g playwright && npx playwright install chromium`) and (2) the CLIPY_API_KEY to carry the 'ingest' scope. Recording the REAL Mac screen or a specific window (ScreenCaptureKit, real logged-in browser) is CLI-only — `clipy record --source mac-screen --window \"<app>\"` — and not available via MCP. Quick per-cookie / per-localStorage-key injection (the CLI's `--cookie` / `--local-storage`) is a CLI-only convenience; `storageState` covers the same need here. The result reports the RESOLVED capture source (`source`: the post-redirect URL, page title and viewport actually being recorded) — compare it against the surface your driver is acting on BEFORE doing minutes of work, because Clipy will never focus or foreground a window or tab for you. Auth note: `storageState` seeds exactly what it contains (cookies + localStorage) but can't reproduce a whole browser identity (IndexedDB, service workers, some cross-origin auth); for those, produce a storageState via an interactive `npx playwright open --save-storage=state.json <login-url>` first, or use `userDataDir` pointed at a DEDICATED (never live) profile directory. After it returns, call wait_for_artifacts then get_agent_context to read the transcript/summary.", {
1294
1341
  url: z.string().describe("The http(s) URL to open and record (e.g. http://localhost:3000)."),
1295
1342
  durationSeconds: z
1296
1343
  .number()
@@ -1425,6 +1472,7 @@ server.tool("record", "Record a web app HEADLESSLY and upload it as a Clipy reco
1425
1472
  let publicId = "";
1426
1473
  let sizeBytes = 0;
1427
1474
  const autoNotes = [];
1475
+ let capturedSource;
1428
1476
  try {
1429
1477
  // ── Capture ──
1430
1478
  let videoPath;
@@ -1453,6 +1501,9 @@ server.tool("record", "Record a web app HEADLESSLY and upload it as a Clipy reco
1453
1501
  if (i === 0) {
1454
1502
  await waitForFirstPaint(page, frame);
1455
1503
  captureStart = Date.now();
1504
+ // Resolve the capture source once the first real frame is up, so the
1505
+ // reported URL/title are post-redirect truth, not the requested URL.
1506
+ capturedSource = await resolveHeadlessSource(page, frame);
1456
1507
  }
1457
1508
  if (viewports) {
1458
1509
  autoNotes.push({
@@ -1529,6 +1580,7 @@ server.tool("record", "Record a web app HEADLESSLY and upload it as a Clipy reco
1529
1580
  agentContextUrl: `${API_URL}/api/agent-context/${publicId}`,
1530
1581
  sizeBytes,
1531
1582
  recordedSeconds: forSec * passes.length,
1583
+ ...(capturedSource ? { source: capturedSource } : {}),
1532
1584
  ...(recordingKind ? { recordingKind } : {}),
1533
1585
  ...(viewports ? { viewports: passes.map((p) => p.label) } : {}),
1534
1586
  ...(profileCopy ? { profileCopy: profileCopyDisclosure(profileCopy, userDataDir) } : {}),
@@ -1650,7 +1702,7 @@ function finishSession(session, mode) {
1650
1702
  })();
1651
1703
  return session.finishing;
1652
1704
  }
1653
- server.tool("start_recording", "Start a RECORDING SESSION: opens the given URL in a headless Chromium that keeps recording in the background while you continue working. Use add_marker to narrate (and optionally ASSERT on-screen state) at each step, add_chapter for before/after boundaries, then stop_recording to upload and get the share link. Set `type` for the recording kind, `storageState`/`initScript` to record behind a login, and `exposeCdp` to get a CDP endpoint you can drive with your own Playwright while it records. The session auto-stops and uploads by itself at maxSeconds (default 600) so a forgotten session can never run away. One session at a time. Requires Playwright + an ingest-scoped CLIPY_API_KEY (like the record tool). Recording the REAL Mac screen or a specific window (ScreenCaptureKit, real logged-in browser) is CLI-only — `clipy session start --source mac-screen --window \"<app>\"` — and not available via MCP. Quick per-cookie / per-localStorage-key injection (the CLI's `--cookie` / `--local-storage`) is CLI-only — use `storageState` here; and backdating a mark by a relative offset (the CLI's `--ago`) is CLI-only — use add_marker's `atSeconds`.", {
1705
+ server.tool("start_recording", "Start a RECORDING SESSION: opens the given URL in a headless Chromium that keeps recording in the background while you continue working. Use add_marker to narrate (and optionally ASSERT on-screen state) at each step, add_chapter for before/after boundaries, then stop_recording to upload and get the share link. Set `type` for the recording kind, `storageState`/`initScript` to record behind a login, and `exposeCdp` to get a CDP endpoint you can drive with your own Playwright while it records. The session auto-stops and uploads by itself at maxSeconds (default 600) so a forgotten session can never run away. One session at a time. Requires Playwright + an ingest-scoped CLIPY_API_KEY (like the record tool). Recording the REAL Mac screen or a specific window (ScreenCaptureKit, real logged-in browser) is CLI-only — `clipy session start --source mac-screen --window \"<app>\"` — and not available via MCP. Quick per-cookie / per-localStorage-key injection (the CLI's `--cookie` / `--local-storage`) is CLI-only — use `storageState` here; and backdating a mark by a relative offset (the CLI's `--ago`) is CLI-only — use add_marker's `atSeconds`. The result reports the RESOLVED capture source (`source`: the post-redirect URL, page title and viewport actually being recorded) — compare it against the surface your driver is acting on BEFORE doing minutes of work, because Clipy will never focus or foreground a window or tab for you. This call waits for the initial navigation to settle before replying (bounded by the same 30s page-load timeout) so that reported source is measured rather than guessed — recording and the auto-stop rail both start immediately, so only the reply waits.", {
1654
1706
  url: z.string().describe("The http(s) URL to open and record (e.g. http://localhost:3000)."),
1655
1707
  name: z.string().optional().describe("Optional title for the recording."),
1656
1708
  description: z.string().optional().describe("Optional description for the recording."),
@@ -1897,11 +1949,15 @@ server.tool("start_recording", "Start a RECORDING SESSION: opens the given URL i
1897
1949
  }));
1898
1950
  activeSession = session;
1899
1951
  autoStoppedResult = null;
1900
- page
1901
- .goto(target.href, { waitUntil: "load", timeout: 30_000 })
1902
- .catch(() => {
1952
+ // AWAITED (changed in 0.8.5): the result reports the RESOLVED capture
1953
+ // source, which can only be read after navigation settles. The recording
1954
+ // is already running and the auto-stop rail is already armed, so this only
1955
+ // delays the reply — bounded by the same 30s goto timeout, and a timeout
1956
+ // still yields whatever the page actually is rather than a guess.
1957
+ await page.goto(target.href, { waitUntil: "load", timeout: 30_000 }).catch(() => {
1903
1958
  // slow SPA — the recording is running regardless
1904
1959
  });
1960
+ const capturedSource = await resolveHeadlessSource(page, { width: w, height: h });
1905
1961
  // Describe the CDP outcome precisely: disabled-by-env, requested-but-
1906
1962
  // unreachable, or ready with the endpoints + driver gotchas.
1907
1963
  const cdpResult = cdpHttpUrl
@@ -1914,6 +1970,7 @@ server.tool("start_recording", "Start a RECORDING SESSION: opens the given URL i
1914
1970
  return ok({
1915
1971
  state: "recording",
1916
1972
  url: target.href,
1973
+ source: capturedSource,
1917
1974
  maxSeconds: maxSec,
1918
1975
  ...(recordingKind ? { recordingKind } : {}),
1919
1976
  ...(profileCopy ? { profileCopy: profileCopyDisclosure(profileCopy, userDataDir) } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clipy/mcp",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "mcpName": "online.clipy/mcp",
5
5
  "description": "Model Context Protocol (MCP) server for Clipy — 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",