clipbait 1.5.0 โ 1.6.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 +16 -1
- package/index.js +69 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -31,4 +31,19 @@ npx clipbait status <jobId> # get finished clip URLs
|
|
|
31
31
|
|
|
32
32
|
Auth via `CLIPBAIT_API_KEY` env var or `~/.clipbait.json`. Requires Node 18+.
|
|
33
33
|
|
|
34
|
-
|
|
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:
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"mcpServers": {
|
|
39
|
+
"clipbait": {
|
|
40
|
+
"command": "npx",
|
|
41
|
+
"args": ["-y", "clipbait@latest", "mcp"],
|
|
42
|
+
"env": { "CLIPBAIT_API_KEY": "cbk_live_your_key_here" }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
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
|
+
|
|
49
|
+
Using **ChatGPT / claude.ai** (URL connectors, no local process)? Point them at the hosted MCP instead: `https://app.clipbait.ai/api/mcp/<your_api_key>`.
|
package/index.js
CHANGED
|
@@ -166,9 +166,77 @@ async function runSetup(providedKey) {
|
|
|
166
166
|
console.log("\n๐ฌ Done! Restart Claude Code, then type:\n /clipbait https://youtube.com/watch?v=โฆ\n");
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
// Download a clip URL to ~/Downloads and return the saved path. Presigned
|
|
170
|
+
// storage URLs need no auth; our own proxy URLs need the key โ only send the
|
|
171
|
+
// key to clipbait.ai hosts so we never leak it to third-party storage.
|
|
172
|
+
async function downloadToFile(url, filename) {
|
|
173
|
+
const dir = path.join(os.homedir(), "Downloads");
|
|
174
|
+
try { fs.mkdirSync(dir, { recursive: true }); } catch { /* ignore */ }
|
|
175
|
+
const dest = path.join(dir, filename);
|
|
176
|
+
const headers = /(^|\.)clipbait\.ai/i.test(new URL(url).host) ? { "X-API-Key": loadKey() } : {};
|
|
177
|
+
const res = await fetch(url, { headers });
|
|
178
|
+
if (!res.ok) throw new Error(`download failed: HTTP ${res.status}`);
|
|
179
|
+
const len = Number(res.headers.get("content-length") || 0);
|
|
180
|
+
if (len > 500 * 1024 * 1024) throw new Error("clip is larger than 500 MB");
|
|
181
|
+
fs.writeFileSync(dest, Buffer.from(await res.arrayBuffer()));
|
|
182
|
+
return dest;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Local stdio MCP server. Lets Claude Desktop, Cursor, Cline, Windsurf, etc.
|
|
186
|
+
// drive Clipbait via `npx clipbait mcp`. Tools proxy the REST API; download_clip
|
|
187
|
+
// runs locally so it can save to disk (a remote MCP can't). NEVER write to
|
|
188
|
+
// stdout here โ it's the MCP transport; diagnostics go to stderr only.
|
|
189
|
+
async function runMcpServer() {
|
|
190
|
+
if (!loadKey()) { console.error("No API key. Set CLIPBAIT_API_KEY or run: npx clipbait <cbk_live_...>"); process.exit(1); }
|
|
191
|
+
const { McpServer } = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
192
|
+
const { StdioServerTransport } = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
193
|
+
const { z } = require("zod");
|
|
194
|
+
const server = new McpServer({ name: "clipbait", version: require("./package.json").version });
|
|
195
|
+
const ok = (t) => ({ content: [{ type: "text", text: t }] });
|
|
196
|
+
const fail = (e) => ({ content: [{ type: "text", text: "Error: " + (e.message || String(e)) }], isError: true });
|
|
197
|
+
|
|
198
|
+
server.tool("generate_clips", "Generate short vertical viral clips from a long video (YouTube, Twitch VOD, Rumble, Ganjing). Returns a job id; poll get_job.",
|
|
199
|
+
{ videoUrl: z.string(), aspectRatio: z.enum(["9:16", "16:9"]).optional(), maxClips: z.number().int().min(1).max(20).optional() },
|
|
200
|
+
async (a) => { try { const d = await api("POST", "/clips/generate", { videoUrl: a.videoUrl, aspectRatio: a.aspectRatio || "9:16", maxClips: a.maxClips || 9 }); return ok(`Clip job started: ${d.jobId}${d.duplicate ? " (duplicate of a recent job โ no extra credits)" : ""}. Poll get_job("${d.jobId}").`); } catch (e) { return fail(e); } });
|
|
201
|
+
|
|
202
|
+
server.tool("get_job", "Check a clip job's status and get finished clip URLs.", { jobId: z.string() },
|
|
203
|
+
async (a) => { try { const d = await api("GET", "/clips/status/" + a.jobId); const clips = (d.clips || []).map((x, i) => `#${i + 1} ${x.hook || ""} โ ${x.url || "(rendering)"}`).join("\n"); return ok(`Status: ${d.status} (${d.progress ?? 0}%)\n${clips || "No clips yet."}`); } catch (e) { return fail(e); } });
|
|
204
|
+
|
|
205
|
+
server.tool("list_recent_clips", "List your recent clip jobs and how many clips each produced.", {},
|
|
206
|
+
async () => { try { const d = await api("GET", "/clips/jobs"); const jobs = (d.jobs || d || []).slice(0, 10).map((j) => `${j._id} ยท ${j.status} ยท ${(j.clips || []).length} clips ยท ${j.videoTitle || j.streamerName || ""}`).join("\n"); return ok(jobs || "No jobs yet."); } catch (e) { return fail(e); } });
|
|
207
|
+
|
|
208
|
+
server.tool("get_credits", "Check remaining Clipbait credits and plan before starting a job (1 credit โ 1 minute of source video).", {},
|
|
209
|
+
async () => { try { const d = await api("GET", "/clips/credits"); return ok(`Plan: ${d.plan}. Credits remaining: ${d.credits_remaining}${d.credits_total ? ` of ${d.credits_total}` : ""}.`); } catch (e) { return fail(e); } });
|
|
210
|
+
|
|
211
|
+
server.tool("start_live_autoclip", "Start continuous auto-clipping of a LIVE Twitch stream (Pro). Clips are generated automatically as viral moments happen.",
|
|
212
|
+
{ channelUrl: z.string(), cadenceMin: z.number().int().optional() },
|
|
213
|
+
async (a) => { try { const d = await api("POST", "/live/start", { videoUrl: a.channelUrl, cadenceMin: a.cadenceMin || 7 }); return ok(`Live auto-clipping started (${d.liveSessionId || d.session?._id || "?"}).`); } catch (e) { return fail(e); } });
|
|
214
|
+
|
|
215
|
+
server.tool("probe_video", "Get a video's duration before clipping.", { url: z.string() },
|
|
216
|
+
async (a) => { try { const d = await api("POST", "/clips/probe-url", { url: a.url }); return ok(d.durationSeconds != null ? `Duration: ${d.durationSeconds}s (~${Math.round(d.durationSeconds / 60)} min)` : "Duration unknown for this platform."); } catch (e) { return fail(e); } });
|
|
217
|
+
|
|
218
|
+
server.tool("download_clip", "Save a finished clip to the user's ~/Downloads folder and return the file path. Call after get_job shows the job is complete.",
|
|
219
|
+
{ jobId: z.string(), clipIndex: z.number().int().min(1).optional().describe("1-based, default 1") },
|
|
220
|
+
async (a) => {
|
|
221
|
+
try {
|
|
222
|
+
const d = await api("GET", "/clips/status/" + a.jobId);
|
|
223
|
+
const clips = d.clips || [];
|
|
224
|
+
if (!clips.length) return fail(new Error("No clips are ready for this job yet."));
|
|
225
|
+
const idx = (a.clipIndex || 1) - 1;
|
|
226
|
+
const clip = clips[idx];
|
|
227
|
+
if (!clip || !clip.url) return fail(new Error(`Clip #${a.clipIndex || 1} isn't available.`));
|
|
228
|
+
const p = await downloadToFile(clip.url, `clipbait-${a.jobId}-${idx + 1}.mp4`);
|
|
229
|
+
return ok(`Saved to ${p}`);
|
|
230
|
+
} catch (e) { return fail(e); }
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
await server.connect(new StdioServerTransport());
|
|
234
|
+
}
|
|
235
|
+
|
|
169
236
|
const HELP = `clipbait โ AI clip generation
|
|
170
237
|
|
|
171
238
|
npx clipbait@latest set up Claude Code (recommended)
|
|
239
|
+
clipbait mcp run the stdio MCP server (for Claude Desktop/Cursor/Cline)
|
|
172
240
|
clipbait login <apiKey> just save your API key
|
|
173
241
|
clipbait generate <url> [--aspect 9:16] [--type talking_head] [--max 9]
|
|
174
242
|
clipbait status <jobId> check a job + get clip URLs
|
|
@@ -193,6 +261,7 @@ Auth: CLIPBAIT_API_KEY env var or ~/.clipbait.json (via 'clipbait login').`;
|
|
|
193
261
|
console.log("โ Saved API key to " + CFG);
|
|
194
262
|
return;
|
|
195
263
|
}
|
|
264
|
+
if (cmd === "mcp") { await runMcpServer(); return; } // stdio MCP server for local clients
|
|
196
265
|
if (cmd === "help" || cmd === "--help" || cmd === "-h") { console.log(HELP); return; }
|
|
197
266
|
|
|
198
267
|
if (!loadKey()) {
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clipbait",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Clipbait CLI โ turn any video into viral clips, and auto-clip live streams, from your terminal or AI agent.",
|
|
3
|
+
"version": "1.6.0",
|
|
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",
|
|
7
7
|
"engines": { "node": ">=18" },
|
|
8
|
-
"keywords": ["clipbait", "clips", "video", "ai", "agent", "cli", "twitch", "shorts"],
|
|
8
|
+
"keywords": ["clipbait", "clips", "video", "ai", "agent", "mcp", "cli", "twitch", "shorts"],
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
11
|
+
"zod": "^3.25.0"
|
|
12
|
+
},
|
|
9
13
|
"license": "MIT"
|
|
10
14
|
}
|