@clipy/mcp 0.11.0 → 0.13.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/README.md +25 -23
- package/dist/index.js +50 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,39 +26,25 @@ delete anything.
|
|
|
26
26
|
|
|
27
27
|
## Setup
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
`CLIPY_API_KEY` env var (it looks like `clipy_sk_live_…`). The easiest way to get one is
|
|
31
|
-
the Clipy CLI's browser login:
|
|
29
|
+
Log in once with the Clipy CLI:
|
|
32
30
|
|
|
33
31
|
```bash
|
|
34
32
|
npx @clipy/cli@latest login
|
|
35
33
|
```
|
|
36
34
|
|
|
37
35
|
It opens your browser; click **Approve** once. The key is saved to
|
|
38
|
-
`~/.config/clipy/config.json
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
**Prefer to mint one by hand?** Create a key at
|
|
42
|
-
**https://clipy.online/settings/api-keys** instead (it's shown only once — copy it
|
|
43
|
-
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.
|
|
44
38
|
|
|
45
39
|
Then add the server to your MCP client.
|
|
46
40
|
|
|
47
|
-
> **Never inline your key into the server's launch command** — e.g.
|
|
48
|
-
> `"command": "sh", "args": ["-c", "CLIPY_API_KEY=… npx -y @clipy/mcp"]`. Command-line
|
|
49
|
-
> arguments are visible to **every local process** via the process table (`ps`, `/proc`),
|
|
50
|
-
> so a key placed there is effectively world-readable on the machine. Always put it in the
|
|
51
|
-
> `env` block, exactly as every example below does. (The one-time `claude mcp add --env …` /
|
|
52
|
-
> `codex mcp add --env …` helpers below write that `env` block for you — they expose the key
|
|
53
|
-
> only in the argv of that single setup command, never in the long-running server's.)
|
|
54
|
-
|
|
55
41
|
### Claude Code
|
|
56
42
|
|
|
57
43
|
The `--scope user` flag installs Clipy **globally** for every project. Without it,
|
|
58
44
|
`claude mcp add` defaults to `local` scope (the current folder only):
|
|
59
45
|
|
|
60
46
|
```bash
|
|
61
|
-
claude mcp add --scope user clipy --
|
|
47
|
+
claude mcp add --scope user clipy -- npx -y @clipy/mcp
|
|
62
48
|
```
|
|
63
49
|
|
|
64
50
|
### Codex
|
|
@@ -67,7 +53,7 @@ This writes the server to your global `~/.codex/config.toml`, so it's available
|
|
|
67
53
|
Codex session:
|
|
68
54
|
|
|
69
55
|
```bash
|
|
70
|
-
codex mcp add clipy --
|
|
56
|
+
codex mcp add clipy -- npx -y @clipy/mcp
|
|
71
57
|
```
|
|
72
58
|
|
|
73
59
|
Or add it to `~/.codex/config.toml` by hand:
|
|
@@ -76,7 +62,6 @@ Or add it to `~/.codex/config.toml` by hand:
|
|
|
76
62
|
[mcp_servers.clipy]
|
|
77
63
|
command = "npx"
|
|
78
64
|
args = ["-y", "@clipy/mcp"]
|
|
79
|
-
env = { CLIPY_API_KEY = "clipy_sk_live_xxx" }
|
|
80
65
|
```
|
|
81
66
|
|
|
82
67
|
### Claude Desktop / Cursor / Windsurf
|
|
@@ -89,13 +74,30 @@ or the Windsurf MCP config) directly:
|
|
|
89
74
|
"mcpServers": {
|
|
90
75
|
"clipy": {
|
|
91
76
|
"command": "npx",
|
|
92
|
-
"args": ["-y", "@clipy/mcp"]
|
|
93
|
-
"env": { "CLIPY_API_KEY": "clipy_sk_live_xxx" }
|
|
77
|
+
"args": ["-y", "@clipy/mcp"]
|
|
94
78
|
}
|
|
95
79
|
}
|
|
96
80
|
}
|
|
97
81
|
```
|
|
98
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
|
+
|
|
99
101
|
## Tools
|
|
100
102
|
|
|
101
103
|
| Tool | What it does |
|
|
@@ -264,7 +266,7 @@ await page.evaluate(() => window.__clipyChapter("AFTER — fix applied"));
|
|
|
264
266
|
|
|
265
267
|
| Env var | Required | Default | Notes |
|
|
266
268
|
| --- | --- | --- | --- |
|
|
267
|
-
| `CLIPY_API_KEY` |
|
|
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. |
|
|
268
270
|
| `CLIPY_API_URL` | no | `https://clipy.online` | Override for self-hosted/staging. |
|
|
269
271
|
|
|
270
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
|
|
21
|
-
* CLIPY_API_KEY
|
|
22
|
-
*
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
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.13.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]
|
|
43
|
-
`
|
|
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 —
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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.
|
|
3
|
+
"version": "0.13.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",
|