@clipy/mcp 0.10.0 → 0.12.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 +30 -24
  2. package/dist/index.js +50 -18
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -13,6 +13,10 @@ recording into a Linear ticket"_ without leaving your agent — and, with the `r
13
13
  tool, **record a web app headlessly** and get it back as a Clipy recording (_"build the
14
14
  feature, then record the outcome"_).
15
15
 
16
+ The canonical cross-surface operating contract is
17
+ **[clipy.online/agents.md](https://clipy.online/agents.md)**. For the exact
18
+ connected MCP version and schemas, use the standard `tools/list` request.
19
+
16
20
  The read tools need the `recordings:read` scope, which every key gets by default. The
17
21
  write tools — `record`, the session tools (`start_recording`, `add_marker`, `add_chapter`,
18
22
  `stop_recording`, `abort_recording`), and `replace_transcript` — additionally need the
@@ -22,39 +26,25 @@ delete anything.
22
26
 
23
27
  ## Setup
24
28
 
25
- This is a headless server process, so it authenticates with a Clipy API key in the
26
- `CLIPY_API_KEY` env var (it looks like `clipy_sk_live_…`). The easiest way to get one is
27
- the Clipy CLI's browser login:
29
+ Log in once with the Clipy CLI:
28
30
 
29
31
  ```bash
30
32
  npx @clipy/cli@latest login
31
33
  ```
32
34
 
33
35
  It opens your browser; click **Approve** once. The key is saved to
34
- `~/.config/clipy/config.json` — copy its `apiKey` value into `CLIPY_API_KEY` when you add
35
- the server below.
36
-
37
- **Prefer to mint one by hand?** Create a key at
38
- **https://clipy.online/settings/api-keys** instead (it's shown only once — copy it
39
- immediately).
36
+ `~/.config/clipy/config.json`, **and this server reads that file** — so there is no key to
37
+ copy anywhere, and no secret ends up in your shell history or your MCP config.
40
38
 
41
39
  Then add the server to your MCP client.
42
40
 
43
- > **Never inline your key into the server's launch command** — e.g.
44
- > `"command": "sh", "args": ["-c", "CLIPY_API_KEY=… npx -y @clipy/mcp"]`. Command-line
45
- > arguments are visible to **every local process** via the process table (`ps`, `/proc`),
46
- > so a key placed there is effectively world-readable on the machine. Always put it in the
47
- > `env` block, exactly as every example below does. (The one-time `claude mcp add --env …` /
48
- > `codex mcp add --env …` helpers below write that `env` block for you — they expose the key
49
- > only in the argv of that single setup command, never in the long-running server's.)
50
-
51
41
  ### Claude Code
52
42
 
53
43
  The `--scope user` flag installs Clipy **globally** for every project. Without it,
54
44
  `claude mcp add` defaults to `local` scope (the current folder only):
55
45
 
56
46
  ```bash
57
- claude mcp add --scope user clipy --env CLIPY_API_KEY=clipy_sk_live_xxx -- npx -y @clipy/mcp
47
+ claude mcp add --scope user clipy -- npx -y @clipy/mcp
58
48
  ```
59
49
 
60
50
  ### Codex
@@ -63,7 +53,7 @@ This writes the server to your global `~/.codex/config.toml`, so it's available
63
53
  Codex session:
64
54
 
65
55
  ```bash
66
- codex mcp add clipy --env CLIPY_API_KEY=clipy_sk_live_xxx -- npx -y @clipy/mcp
56
+ codex mcp add clipy -- npx -y @clipy/mcp
67
57
  ```
68
58
 
69
59
  Or add it to `~/.codex/config.toml` by hand:
@@ -72,7 +62,6 @@ Or add it to `~/.codex/config.toml` by hand:
72
62
  [mcp_servers.clipy]
73
63
  command = "npx"
74
64
  args = ["-y", "@clipy/mcp"]
75
- env = { CLIPY_API_KEY = "clipy_sk_live_xxx" }
76
65
  ```
77
66
 
78
67
  ### Claude Desktop / Cursor / Windsurf
@@ -85,17 +74,35 @@ or the Windsurf MCP config) directly:
85
74
  "mcpServers": {
86
75
  "clipy": {
87
76
  "command": "npx",
88
- "args": ["-y", "@clipy/mcp"],
89
- "env": { "CLIPY_API_KEY": "clipy_sk_live_xxx" }
77
+ "args": ["-y", "@clipy/mcp"]
90
78
  }
91
79
  }
92
80
  }
93
81
  ```
94
82
 
83
+ Add an `"env": { "CLIPY_API_KEY": "clipy_sk_live_xxx" }` block only if you are not using
84
+ `clipy login` on this machine.
85
+
86
+ ### Setting the key explicitly
87
+
88
+ Use `CLIPY_API_KEY` when there is no `clipy login` to read from — CI, a container — or
89
+ when you deliberately want a different key than the logged-in one. An explicit env var
90
+ always wins over the config file. Mint keys at
91
+ **https://clipy.online/settings/api-keys** (shown only once).
92
+
93
+ > **Never inline your key into the server's launch command** — e.g.
94
+ > `"command": "sh", "args": ["-c", "CLIPY_API_KEY=… npx -y @clipy/mcp"]`. Command-line
95
+ > arguments are visible to **every local process** via the process table (`ps`, `/proc`),
96
+ > so a key placed there is effectively world-readable on the machine. Put it in the `env`
97
+ > block instead. (`claude mcp add --env …` / `codex mcp add --env …` write that `env` block
98
+ > for you — they expose the key only in the argv of that single setup command, never in the
99
+ > long-running server's.)
100
+
95
101
  ## Tools
96
102
 
97
103
  | Tool | What it does |
98
104
  | --- | --- |
105
+ | `search_memory` | **Search the whole Clipy memory at once** — every screen recording the user made *and* every video they imported — returning the matching moments with timestamps and a URL that opens at that point. Matching is semantic as well as literal, so "login flow" finds a moment where someone said "the authentication screen". Reach for this first when the user refers to something they showed, recorded, or watched; the per-library tools below each see only half the picture. Each hit carries `kind` (`recording` or `context`) to tell you which tool to read next, a `resolution` saying whether its timestamp is an exact moment or a ~50s span, and a `semantic.status` to check before treating an empty result as "nothing recorded". |
99
106
  | `search_recordings` | Search your recordings by keyword (title + description). |
100
107
  | `list_recordings` | List your most recent recordings. |
101
108
  | `get_recording` | Metadata for one recording (status, duration, transcript/summary status). |
@@ -111,7 +118,6 @@ or the Windsurf MCP config) directly:
111
118
  | `add_chapter` | Drop a `=== CHAPTER: <label> ===` boundary into the active session — split a recording into named sections (ideal for before/after demos). |
112
119
  | `stop_recording` | Finish the session: close the browser, upload, return the share + agent-context URLs. |
113
120
  | `abort_recording` | Discard the active session; nothing is uploaded. |
114
- | `search_memory` | **Search the whole Clipy memory at once** — every screen recording the user made *and* every video they imported — returning the matching moments with timestamps and a URL that opens at that point. Matching is semantic as well as literal, so "login flow" finds a moment where someone said "the authentication screen". Reach for this first when the user refers to something they showed, recorded, or watched; the per-library tools below each see only half the picture. Each hit carries `kind` (`recording` or `context`) to tell you which tool to read next, a `resolution` saying whether its timestamp is an exact moment or a ~50s span, and a `semantic.status` to check before treating an empty result as "nothing recorded". |
115
121
  | `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. |
116
122
  | `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. |
117
123
  | `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. |
@@ -260,7 +266,7 @@ await page.evaluate(() => window.__clipyChapter("AFTER — fix applied"));
260
266
 
261
267
  | Env var | Required | Default | Notes |
262
268
  | --- | --- | --- | --- |
263
- | `CLIPY_API_KEY` | yes | — | Your personal key from `/settings/api-keys`. |
269
+ | `CLIPY_API_KEY` | no | `apiKey` from `~/.config/clipy/config.json` | Your personal key from `/settings/api-keys`. Set it only when `clipy login` has not run on this machine; when set it overrides the config file. |
264
270
  | `CLIPY_API_URL` | no | `https://clipy.online` | Override for self-hosted/staging. |
265
271
 
266
272
  ## Privacy
package/dist/index.js CHANGED
@@ -17,9 +17,15 @@
17
17
  * ("Record & upload"), enforced server-side. A `recordings:read`-only key cannot
18
18
  * create, modify, or delete anything.
19
19
  *
20
- * Config (env):
21
- * CLIPY_API_KEY (required) your personal key
22
- * CLIPY_API_URL (optional) base URL, defaults to https://clipy.online
20
+ * Config, in precedence order:
21
+ * CLIPY_API_KEY / CLIPY_API_URL env vars
22
+ * ~/.config/clipy/config.json written by `clipy login`
23
+ * https://clipy.online default base URL
24
+ *
25
+ * Reading the CLI's config file is what lets an agent finish setup on its own:
26
+ * `clipy login` is the only step that needs a human, and after it the MCP
27
+ * server can be registered with no secret on the command line or in the host's
28
+ * MCP config. Mirrors the CLI's own store (cli/src/index.ts `configPath`).
23
29
  */
24
30
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
25
31
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
@@ -28,19 +34,47 @@ import { MAX_MARKDOWN_CHARS, sliceArecMarkdown } from "./arecRange.js";
28
34
  import { chmodSync, closeSync, cpSync, createWriteStream, existsSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, rmSync, statSync } from "node:fs";
29
35
  import { randomUUID } from "node:crypto";
30
36
  import { createServer } from "node:net";
31
- import { tmpdir } from "node:os";
37
+ import { homedir, tmpdir } from "node:os";
32
38
  import { basename, join, resolve } from "node:path";
33
39
  import { Readable } from "node:stream";
34
40
  import { pipeline } from "node:stream/promises";
35
- const API_URL = (process.env.CLIPY_API_URL || "https://clipy.online").replace(/\/+$/, "");
36
- const API_KEY = process.env.CLIPY_API_KEY;
37
- const SERVER_VERSION = "0.10.0";
41
+ /** `clipy login`'s credential store. Same path the CLI computes. */
42
+ function cliConfigPath() {
43
+ const base = process.env.XDG_CONFIG_HOME?.trim() || join(homedir(), ".config");
44
+ return join(base, "clipy", "config.json");
45
+ }
46
+ function readCliConfig() {
47
+ try {
48
+ const parsed = JSON.parse(readFileSync(cliConfigPath(), "utf8"));
49
+ if (!parsed || typeof parsed !== "object")
50
+ return {};
51
+ const { apiKey, apiUrl } = parsed;
52
+ return {
53
+ apiKey: typeof apiKey === "string" && apiKey ? apiKey : undefined,
54
+ apiUrl: typeof apiUrl === "string" && apiUrl ? apiUrl : undefined,
55
+ };
56
+ }
57
+ catch {
58
+ return {};
59
+ }
60
+ }
61
+ const CLI_CONFIG = readCliConfig();
62
+ const API_URL = (process.env.CLIPY_API_URL || CLI_CONFIG.apiUrl || "https://clipy.online").replace(/\/+$/, "");
63
+ const API_KEY = process.env.CLIPY_API_KEY || CLI_CONFIG.apiKey;
64
+ const API_KEY_SOURCE = process.env.CLIPY_API_KEY ? "env CLIPY_API_KEY" : CLI_CONFIG.apiKey ? cliConfigPath() : null;
65
+ const SERVER_VERSION = "0.12.0";
66
+ /** Every keyless failure points at the same two fixes, cheapest one first. */
67
+ const MISSING_KEY_MESSAGE = `No Clipy credential. Run \`clipy login\` in a terminal — it writes ${cliConfigPath()}, which this server reads — ` +
68
+ `or mint a key at ${API_URL}/settings/api-keys and set CLIPY_API_KEY in your MCP client config. ` +
69
+ "The credential is read at startup, so restart the MCP client afterwards.";
70
+ const MISSING_INGEST_KEY_MESSAGE = `${MISSING_KEY_MESSAGE} This tool additionally needs the key to carry the "ingest" scope.`;
38
71
  // The key is checked lazily (per tool call, not at startup) so the server can
39
72
  // start and answer introspection (initialize / tools/list) in keyless
40
73
  // environments like directory health checks.
41
74
  if (!API_KEY) {
42
- process.stderr.write("[clipy-mcp] CLIPY_API_KEY is not set — tools will error until it is. " +
43
- `Create one at ${API_URL}/settings/api-keys and set it in your MCP client config.\n`);
75
+ process.stderr.write("[clipy-mcp] no Clipy credential found — tools will error until there is one. " +
76
+ `Run \`clipy login\` (writes ${cliConfigPath()}, which this server reads), ` +
77
+ `or mint a key at ${API_URL}/settings/api-keys and set CLIPY_API_KEY.\n`);
44
78
  }
45
79
  const FETCH_TIMEOUT_MS = 20_000;
46
80
  /**
@@ -56,7 +90,7 @@ function actionableApiError(status, message, path) {
56
90
  : "No recording with that id. Call list_recordings or search_recordings first and use a publicId from those results.";
57
91
  switch (status) {
58
92
  case 401:
59
- return `${message} (HTTP 401 — CLIPY_API_KEY is missing, invalid, or revoked.) Fix it, then retry: run \`clipy login\` in a terminal to approve this device, or mint a key at ${API_URL}/settings/api-keys and set CLIPY_API_KEY in your MCP client config (the server reads it at startup, so restart the client after changing it). Retrying this call unchanged will fail identically.`;
93
+ 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.`;
60
94
  case 403:
61
95
  return `${message} (HTTP 403 — the API key is valid but lacks the scope this call needs, or the resource belongs to another account.) Write tools need a key with the "ingest" permission; mint one at ${API_URL}/settings/api-keys. Retrying with the same key cannot succeed.`;
62
96
  case 404:
@@ -74,8 +108,7 @@ function actionableApiError(status, message, path) {
74
108
  /** Calls the Clipy v1 API with the API key. Throws on non-2xx or timeout. */
75
109
  async function api(path) {
76
110
  if (!API_KEY) {
77
- throw new Error(`Missing CLIPY_API_KEY. Create a free API key at ${API_URL}/settings/api-keys ` +
78
- "and set it in your MCP client config, then try again.");
111
+ throw new Error(MISSING_KEY_MESSAGE);
79
112
  }
80
113
  const controller = new AbortController();
81
114
  const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
@@ -117,8 +150,7 @@ async function api(path) {
117
150
  /** Same call shape as `api()` but for endpoints that return text/markdown. */
118
151
  async function apiText(path) {
119
152
  if (!API_KEY) {
120
- throw new Error(`Missing CLIPY_API_KEY. Create a free API key at ${API_URL}/settings/api-keys ` +
121
- "and set it in your MCP client config, then try again.");
153
+ throw new Error(MISSING_KEY_MESSAGE);
122
154
  }
123
155
  const controller = new AbortController();
124
156
  const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
@@ -165,7 +197,7 @@ async function apiText(path) {
165
197
  /** POST/PUT JSON to a write endpoint. Retries transient failures; throws on hard errors. */
166
198
  async function apiPostJson(path, payload, method = "POST") {
167
199
  if (!API_KEY)
168
- throw new Error(`Missing CLIPY_API_KEY. Create one at ${API_URL}/settings/api-keys.`);
200
+ throw new Error(MISSING_KEY_MESSAGE);
169
201
  for (let attempt = 1; attempt <= 4; attempt++) {
170
202
  const controller = new AbortController();
171
203
  const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
@@ -220,7 +252,7 @@ async function apiPostJson(path, payload, method = "POST") {
220
252
  /** Upload one raw-upload chunk as multipart/form-data, retrying transient 429/5xx. */
221
253
  async function apiPostChunk(recordingId, uploadToken, partNumber, bytes) {
222
254
  if (!API_KEY)
223
- throw new Error("Missing CLIPY_API_KEY.");
255
+ throw new Error(MISSING_KEY_MESSAGE);
224
256
  for (let attempt = 1; attempt <= 4; attempt++) {
225
257
  const part = bytes.slice().buffer;
226
258
  const form = new FormData();
@@ -1492,7 +1524,7 @@ server.tool("record", "Record a web app HEADLESSLY and upload it as a Clipy reco
1492
1524
  return fail(`url must be http(s), got ${target.protocol}`);
1493
1525
  }
1494
1526
  if (!API_KEY) {
1495
- return fail(`Missing CLIPY_API_KEY. Create an ingest-scoped key at ${API_URL}/settings/api-keys.`);
1527
+ return fail(MISSING_INGEST_KEY_MESSAGE);
1496
1528
  }
1497
1529
  // Validate the structured inputs before touching a browser so an agent gets
1498
1530
  // instant, precise feedback on a bad `type` / `viewports` / auth path.
@@ -1848,7 +1880,7 @@ server.tool("start_recording", "Start a RECORDING SESSION: opens the given URL i
1848
1880
  return fail(`url must be http(s), got ${target.protocol}`);
1849
1881
  }
1850
1882
  if (!API_KEY) {
1851
- return fail(`Missing CLIPY_API_KEY. Create an ingest-scoped key at ${API_URL}/settings/api-keys.`);
1883
+ return fail(MISSING_INGEST_KEY_MESSAGE);
1852
1884
  }
1853
1885
  if (activeSession) {
1854
1886
  return fail("a recording session is already active — finish it with stop_recording or discard it with abort_recording first.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clipy/mcp",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
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",