clipbait 1.6.0 → 1.8.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 +69 -27
- package/index.js +69 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
# clipbait
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Official CLI + MCP server for [Clipbait](https://clipbait.ai) — the AI video clipping tool for streamers and clippers.
|
|
4
|
+
|
|
5
|
+
Let Claude (or any MCP-capable agent) turn long videos into viral vertical clips, check your credits, auto-clip live Twitch streams, and download finished clips to disk — on your Clipbait account. Also works as a plain terminal CLI.
|
|
6
|
+
|
|
7
|
+
## Requires
|
|
8
|
+
|
|
9
|
+
- **Node.js 18 or higher.**
|
|
10
|
+
- **A paid Clipbait account.** Generate a key at [app.clipbait.ai/me](https://app.clipbait.ai/me) → **Developers / API**. Keys are prefixed `cbk_live_`.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
### Fastest — one command (auto-configures Claude Code + Claude Desktop)
|
|
4
15
|
|
|
5
|
-
## Fastest start — one command
|
|
6
16
|
```bash
|
|
7
17
|
npx clipbait@latest
|
|
8
18
|
```
|
|
9
|
-
It opens Clipbait so you can grab your key, then installs a **`/clipbait`** slash command and connects the Clipbait MCP server to Claude Code. Then just type in Claude:
|
|
10
|
-
```
|
|
11
|
-
/clipbait https://youtube.com/watch?v=...
|
|
12
|
-
```
|
|
13
19
|
|
|
14
|
-
|
|
20
|
+
Opens Clipbait so you can copy your key, then installs a `/clipbait` slash command and wires the MCP server into Claude Code and Claude Desktop for you — no JSON to hand-write. Pass the key inline to skip the prompt: `npx clipbait@latest cbk_live_yourkey`. Restart Claude, then type `/clipbait <video url>`.
|
|
21
|
+
|
|
22
|
+
### Claude Code
|
|
23
|
+
|
|
15
24
|
```bash
|
|
16
|
-
|
|
17
|
-
npx clipbait generate "https://youtube.com/watch?v=..." --aspect 9:16 --max 9
|
|
18
|
-
npx clipbait status <jobId> # get finished clip URLs
|
|
25
|
+
claude mcp add --transport http clipbait https://app.clipbait.ai/api/mcp --header "X-API-Key: cbk_live_your_key_here"
|
|
19
26
|
```
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
| `clipbait login <apiKey>` | Save your API key (`~/.clipbait.json`) |
|
|
26
|
-
| `clipbait generate <url> [--aspect 9:16] [--type talking_head] [--max 9]` | Generate clips |
|
|
27
|
-
| `clipbait status <jobId>` | Check a job + get clip URLs |
|
|
28
|
-
| `clipbait jobs` | List recent jobs |
|
|
29
|
-
| `clipbait live <twitchUrl> [--cadence 7]` | Start live auto-clipping (Pro) |
|
|
30
|
-
| `clipbait probe <url>` | Get a video's duration |
|
|
31
|
-
|
|
32
|
-
Auth via `CLIPBAIT_API_KEY` env var or `~/.clipbait.json`. Requires Node 18+.
|
|
33
|
-
|
|
34
|
-
## MCP server (Claude Desktop, Cursor, Cline, Windsurf)
|
|
35
|
-
This package is also an MCP server. `npx clipbait@latest` auto-configures **Claude Code**. For other clients, add this to their MCP config:
|
|
28
|
+
### Cursor / Cline / Windsurf / manual
|
|
29
|
+
|
|
30
|
+
Drop this into the client's MCP config file (runs the local stdio server):
|
|
31
|
+
|
|
36
32
|
```json
|
|
37
33
|
{
|
|
38
34
|
"mcpServers": {
|
|
@@ -44,6 +40,52 @@ This package is also an MCP server. `npx clipbait@latest` auto-configures **Clau
|
|
|
44
40
|
}
|
|
45
41
|
}
|
|
46
42
|
```
|
|
47
|
-
Tools: `generate_clips`, `get_job`, `list_recent_clips`, `get_credits`, `start_live_autoclip`, `probe_video`, and **`download_clip`** (saves a finished clip to your `~/Downloads`).
|
|
48
43
|
|
|
49
|
-
|
|
44
|
+
> **ChatGPT / claude.ai** take a remote URL instead of a local process — point them at `https://app.clipbait.ai/api/mcp/<your_api_key>` (nothing runs on your machine, nothing to update).
|
|
45
|
+
|
|
46
|
+
## Tools
|
|
47
|
+
|
|
48
|
+
Seven tools are available to any agent:
|
|
49
|
+
|
|
50
|
+
| Tool | What it does |
|
|
51
|
+
|---|---|
|
|
52
|
+
| `generate_clips` | Start a clipping job (`videoUrl`, optional `aspectRatio` 9:16\|16:9, `maxClips` 1–20). Returns a job id. |
|
|
53
|
+
| `get_job` | Check a job's status and get finished clip URLs (`jobId`). |
|
|
54
|
+
| `list_recent_clips` | List your recent jobs and clip counts. |
|
|
55
|
+
| `get_credits` | Show credits remaining and your plan. No inputs. |
|
|
56
|
+
| `start_live_autoclip` | Auto-clip a **live** Twitch stream continuously (`channelUrl`, optional `cadenceMin`). Pro plan. |
|
|
57
|
+
| `probe_video` | Get a video's duration before clipping (`url`). |
|
|
58
|
+
| `download_clip` | Save a finished clip to your `~/Downloads/` folder and return the path (`jobId`, `clipIndex` 1-based). Max 500 MB. |
|
|
59
|
+
|
|
60
|
+
## Terminal usage
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx clipbait login cbk_live_your_key
|
|
64
|
+
npx clipbait generate "https://youtube.com/watch?v=..." --aspect 9:16 --max 9
|
|
65
|
+
npx clipbait status <jobId> # get finished clip URLs
|
|
66
|
+
npx clipbait jobs # list recent jobs
|
|
67
|
+
npx clipbait live "https://twitch.tv/somestreamer"
|
|
68
|
+
npx clipbait mcp # run the stdio MCP server (used in configs above)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Auth via the `CLIPBAIT_API_KEY` env var or `~/.clipbait.json`.
|
|
72
|
+
|
|
73
|
+
## Security
|
|
74
|
+
|
|
75
|
+
- **Never commit your `CLIPBAIT_API_KEY`.** Your agent's config file contains a secret — add it to `.gitignore`, or use a secrets manager (1Password CLI, direnv) instead of inline env vars.
|
|
76
|
+
- If you leak your key, rotate it at [app.clipbait.ai/me](https://app.clipbait.ai/me) immediately — the old key stops working at once.
|
|
77
|
+
- `download_clip` links are presigned and expire in ~1 hour. Save clips promptly.
|
|
78
|
+
|
|
79
|
+
## Pricing
|
|
80
|
+
|
|
81
|
+
Requires a **paid Clipbait account**. Clip generation spends credits (1 credit ≈ 1 minute of source video). See [clipbait.ai](https://clipbait.ai).
|
|
82
|
+
|
|
83
|
+
## Links
|
|
84
|
+
|
|
85
|
+
- Clipbait: https://clipbait.ai
|
|
86
|
+
- API docs: https://app.clipbait.ai/docs
|
|
87
|
+
- Get an API key: https://app.clipbait.ai/me
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
MIT
|
package/index.js
CHANGED
|
@@ -13,6 +13,7 @@ const path = require("path");
|
|
|
13
13
|
const CFG = path.join(os.homedir(), ".clipbait.json");
|
|
14
14
|
const BASE = (process.env.CLIPBAIT_API_URL || "https://app.clipbait.ai/api").replace(/\/$/, "");
|
|
15
15
|
const KEY_PAGE = "https://app.clipbait.ai/me";
|
|
16
|
+
const MCP_URL = "https://app.clipbait.ai/api/mcp";
|
|
16
17
|
|
|
17
18
|
// Shown whenever there's no usable key. Written so an AI agent can relay it
|
|
18
19
|
// verbatim to the user and they'll know exactly what to do.
|
|
@@ -74,12 +75,14 @@ function prompt(question) {
|
|
|
74
75
|
// reads MCP servers from ~/.claude.json under projects[cwd].mcpServers (local
|
|
75
76
|
// scope) and, when present, a top-level mcpServers (user scope) — we write
|
|
76
77
|
// both so it shows up regardless of which directory Claude opens in.
|
|
77
|
-
function writeMcpConfig(
|
|
78
|
+
function writeMcpConfig(key) {
|
|
78
79
|
const cfgPath = path.join(os.homedir(), ".claude.json");
|
|
79
80
|
let cfg;
|
|
80
81
|
try { cfg = JSON.parse(fs.readFileSync(cfgPath, "utf8")); }
|
|
81
82
|
catch { return false; } // no/unreadable config → caller prints manual steps
|
|
82
|
-
|
|
83
|
+
// Key travels in an X-API-Key header, not the URL path — keeps it out of the
|
|
84
|
+
// URL (and request logs). It still lives in the config file, same as any MCP.
|
|
85
|
+
const entry = { type: "http", url: MCP_URL, headers: { "X-API-Key": key } };
|
|
83
86
|
cfg.mcpServers = cfg.mcpServers || {};
|
|
84
87
|
cfg.mcpServers.clipbait = entry;
|
|
85
88
|
const cwd = process.cwd();
|
|
@@ -114,55 +117,97 @@ Do this, conversationally and fast:
|
|
|
114
117
|
5. Then offer follow-ups and act on them by calling the tools again: regenerate at a different aspect ratio, pull more clips, or probe another video with \`probe_video\`.
|
|
115
118
|
`;
|
|
116
119
|
|
|
120
|
+
// Claude Desktop config path per-OS.
|
|
121
|
+
function desktopConfigPath() {
|
|
122
|
+
const home = os.homedir();
|
|
123
|
+
if (process.platform === "darwin") return path.join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json");
|
|
124
|
+
if (process.platform === "win32") return path.join(process.env.APPDATA || path.join(home, "AppData", "Roaming"), "Claude", "claude_desktop_config.json");
|
|
125
|
+
return path.join(home, ".config", "Claude", "claude_desktop_config.json");
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Configure Claude Desktop (stdio) if it's installed. Desktop can't use the
|
|
129
|
+
// remote http MCP, and the local stdio server is what enables download_clip.
|
|
130
|
+
// Returns false (silently) when Claude Desktop isn't present.
|
|
131
|
+
function writeDesktopConfig(key) {
|
|
132
|
+
const cfgPath = desktopConfigPath();
|
|
133
|
+
try {
|
|
134
|
+
if (!fs.existsSync(path.dirname(cfgPath))) return false; // Desktop not installed
|
|
135
|
+
let cfg = {};
|
|
136
|
+
try { cfg = JSON.parse(fs.readFileSync(cfgPath, "utf8")); } catch { /* new file */ }
|
|
137
|
+
cfg.mcpServers = cfg.mcpServers || {};
|
|
138
|
+
cfg.mcpServers.clipbait = { command: "npx", args: ["-y", "clipbait@latest", "mcp"], env: { CLIPBAIT_API_KEY: key } };
|
|
139
|
+
const tmp = cfgPath + ".clipbait.tmp";
|
|
140
|
+
fs.writeFileSync(tmp, JSON.stringify(cfg, null, 2));
|
|
141
|
+
fs.renameSync(tmp, cfgPath);
|
|
142
|
+
return true;
|
|
143
|
+
} catch { return false; }
|
|
144
|
+
}
|
|
145
|
+
|
|
117
146
|
// Interactive one-command setup. Grabs the key (from arg / saved / by opening
|
|
118
147
|
// the browser and prompting), installs the /clipbait command, and connects the
|
|
119
|
-
// MCP server to Claude Code.
|
|
148
|
+
// MCP server to Claude Code and Claude Desktop.
|
|
149
|
+
// Print the exact config for the user/agent to apply, WITHOUT touching any
|
|
150
|
+
// files. Used in non-interactive contexts (an agent ran this): silently
|
|
151
|
+
// rewriting global AI-tool config there reads as a supply-chain attack, so we
|
|
152
|
+
// stay transparent and let the caller apply it with full visibility.
|
|
153
|
+
function printManualConfig(key) {
|
|
154
|
+
console.log("\nTo connect Clipbait, apply one of these (nothing was written — you're not in an interactive terminal):\n");
|
|
155
|
+
console.log("Claude Code:");
|
|
156
|
+
console.log(` claude mcp add --transport http clipbait ${MCP_URL} --header "X-API-Key: ${key}"\n`);
|
|
157
|
+
console.log("Claude Desktop / Cursor / Cline / Windsurf — add to the MCP config:");
|
|
158
|
+
console.log(` ${JSON.stringify({ mcpServers: { clipbait: { command: "npx", args: ["-y", "clipbait@latest", "mcp"], env: { CLIPBAIT_API_KEY: key } } } })}\n`);
|
|
159
|
+
console.log(`Tip: run \`npx clipbait@latest\` in a real terminal to apply this automatically.\n`);
|
|
160
|
+
}
|
|
161
|
+
|
|
120
162
|
async function runSetup(providedKey) {
|
|
163
|
+
const interactive = !!process.stdin.isTTY;
|
|
121
164
|
let key = providedKey && providedKey.startsWith("cbk_") ? providedKey : loadKey();
|
|
122
165
|
|
|
123
166
|
if (!key) {
|
|
167
|
+
if (!interactive) { console.error(NEED_KEY); process.exit(1); }
|
|
124
168
|
console.log("\n⚡ Let's connect Clipbait to Claude.");
|
|
125
|
-
if (!process.stdin.isTTY) {
|
|
126
|
-
// No interactive terminal (e.g. an AI agent ran this). Print the full
|
|
127
|
-
// guidance so the agent can pass it straight to the user.
|
|
128
|
-
console.error(NEED_KEY);
|
|
129
|
-
process.exit(1);
|
|
130
|
-
}
|
|
131
169
|
console.log(`\nOpening ${KEY_PAGE} so you can copy your API key…`);
|
|
132
170
|
openBrowser(KEY_PAGE);
|
|
133
171
|
key = (await prompt("\nPaste your API key (starts with cbk_) and press Enter:\n> ")).trim();
|
|
134
172
|
}
|
|
173
|
+
if (!key || !key.startsWith("cbk_")) { console.error(NEED_KEY); process.exit(1); }
|
|
135
174
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
175
|
+
// Non-interactive (agent / pipe): don't silently modify global config. Print
|
|
176
|
+
// it and let the caller apply it with consent.
|
|
177
|
+
if (!interactive) { printManualConfig(key); return; }
|
|
178
|
+
|
|
179
|
+
// Interactive: announce exactly what will change BEFORE writing anything, so
|
|
180
|
+
// it never looks like a package quietly registering itself.
|
|
181
|
+
console.log("\n⚡ Clipbait setup will make these changes on this machine:");
|
|
182
|
+
console.log(" • save your API key to ~/.clipbait.json");
|
|
183
|
+
console.log(" • install a /clipbait slash command (~/.claude/commands/clipbait.md)");
|
|
184
|
+
console.log(" • register the Clipbait MCP server in Claude Code (~/.claude.json)");
|
|
185
|
+
console.log(" • register it in Claude Desktop, if installed\n");
|
|
140
186
|
|
|
141
187
|
fs.writeFileSync(CFG, JSON.stringify({ apiKey: key }, null, 2));
|
|
142
|
-
const mcpUrl = "https://app.clipbait.ai/api/mcp/" + key;
|
|
143
188
|
|
|
144
|
-
// 1) Install the /clipbait slash command for Claude Code.
|
|
145
189
|
const cmdDir = path.join(os.homedir(), ".claude", "commands");
|
|
146
190
|
fs.mkdirSync(cmdDir, { recursive: true });
|
|
147
191
|
fs.writeFileSync(path.join(cmdDir, "clipbait.md"), SLASH_COMMAND);
|
|
148
192
|
console.log("✓ Installed the /clipbait command for Claude Code");
|
|
149
193
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
// printing manual steps.
|
|
153
|
-
if (writeMcpConfig(mcpUrl)) {
|
|
154
|
-
console.log("✓ Connected the Clipbait MCP server to Claude Code");
|
|
194
|
+
if (writeMcpConfig(key)) {
|
|
195
|
+
console.log("✓ Registered the Clipbait MCP server in Claude Code");
|
|
155
196
|
} else {
|
|
156
197
|
const { spawnSync } = require("child_process");
|
|
157
|
-
const r = spawnSync("claude", ["mcp", "add", "--transport", "http", "clipbait",
|
|
198
|
+
const r = spawnSync("claude", ["mcp", "add", "--transport", "http", "clipbait", MCP_URL, "--header", `X-API-Key: ${key}`], { stdio: "ignore" });
|
|
158
199
|
if (!r.error && r.status === 0) {
|
|
159
|
-
console.log("✓
|
|
200
|
+
console.log("✓ Registered the Clipbait MCP server in Claude Code");
|
|
160
201
|
} else {
|
|
161
|
-
console.log("• Couldn't auto-
|
|
162
|
-
console.log(
|
|
202
|
+
console.log("• Couldn't auto-register the MCP server. Add it manually:");
|
|
203
|
+
console.log(` claude mcp add --transport http clipbait ${MCP_URL} --header "X-API-Key: ${key}"`);
|
|
163
204
|
}
|
|
164
205
|
}
|
|
165
206
|
|
|
207
|
+
if (writeDesktopConfig(key)) {
|
|
208
|
+
console.log("✓ Registered Clipbait in Claude Desktop (quit + reopen it to load)");
|
|
209
|
+
}
|
|
210
|
+
|
|
166
211
|
console.log("\n🎬 Done! Restart Claude Code, then type:\n /clipbait https://youtube.com/watch?v=…\n");
|
|
167
212
|
}
|
|
168
213
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clipbait",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Clipbait CLI + MCP server — turn any video into viral clips, and auto-clip live streams, from your terminal or any AI agent.",
|
|
5
5
|
"bin": { "clipbait": "index.js" },
|
|
6
6
|
"type": "commonjs",
|