Skip to content

Open-source AI podcast clipper. Generate vertical clips with face tracking and burned-in captions. CLI, MCP server, web app.

Expose reel iteration as an MCP tool (manage_reel)

Nika Siradze8b43f0818ef7
diff --git a/src/models/index.ts b/src/models/index.ts
index ebc424f..c6704e4 100644
--- a/src/models/index.ts
+++ b/src/models/index.ts
@@ -2,7 +2,7 @@
export interface TaskRequest {
task_id: string;
- task_type: "transcribe" | "parse_transcript" | "create_clip" | "batch_clips" | "analyze_energy" | "pack_transcript" | "detect_encoder" | "presets" | "ping" | "suggest_clips" | "find_moment" | "generate_content" | "generate_custom" | "corrections" | "manage_integrations" | "run_integration_tool" | "manage_config" | "manage_env" | "ai_cli_status";
+ task_type: "transcribe" | "parse_transcript" | "create_clip" | "batch_clips" | "analyze_energy" | "detect_highlights" | "manage_reel" | "pack_transcript" | "detect_encoder" | "presets" | "ping" | "suggest_clips" | "find_moment" | "generate_content" | "generate_custom" | "corrections" | "manage_integrations" | "run_integration_tool" | "manage_config" | "manage_env" | "ai_cli_status";
params: Record<string, unknown>;
}
diff --git a/src/server.ts b/src/server.ts
index e6b11d3..b335162 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -2072,6 +2072,82 @@ export function createServer(): McpServer {
},
);
+ // =============================================
+ // Tool: manage_reel
+ // =============================================
+ server.tool(
+ "manage_reel",
+ "Create and iterate on a highlights reel. Detection runs once with action 'new'; after that, edit individual moments fast (longer/shorter/earlier/later/shift/drop/toggle) and rebuild without re-detecting. Actions: 'new' (video_path, profile, top_n), 'show' (session_id), 'edit' (session_id, index, op, seconds), 'build' (session_id).",
+ {
+ action: z
+ .enum(["new", "show", "edit", "build"])
+ .describe("What to do with the reel"),
+ video_path: z
+ .string()
+ .optional()
+ .describe("For 'new': path to the source video"),
+ session_id: z
+ .string()
+ .optional()
+ .describe("For show/edit/build: the reel session id returned by 'new'"),
+ profile: z
+ .enum(["party", "action"])
+ .optional()
+ .describe("For 'new': detection profile (default party)"),
+ top_n: z.number().optional().describe("For 'new': number of moments"),
+ index: z
+ .number()
+ .optional()
+ .describe("For 'edit': 1-based moment number to adjust"),
+ op: z
+ .enum(["longer", "shorter", "earlier", "later", "shift", "drop", "toggle"])
+ .optional()
+ .describe("For 'edit': how to change the moment"),
+ seconds: z
+ .number()
+ .optional()
+ .describe("For 'edit': seconds for longer/shorter/earlier/later/shift"),
+ },
+ async (params) => {
+ try {
+ const res = await fetch("http://localhost:3847/api/reel", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(params),
+ });
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
+ const data = (await res.json()) as ApiError & Record<string, unknown>;
+ if (data.error) {
+ return {
+ content: [{ type: "text" as const, text: `Error: ${data.error}` }],
+ isError: true,
+ };
+ }
+ return {
+ content: [
+ { type: "text" as const, text: JSON.stringify(data, null, 2) },
+ ],
+ };
+ } catch (err: unknown) {
+ const msg = err instanceof Error ? err.message : String(err);
+ if (msg.includes("ECONNREFUSED") || msg.includes("fetch failed")) {
+ return {
+ content: [
+ {
+ type: "text" as const,
+ text: "Web UI is not running. Start with: npm run ui",
+ },
+ ],
+ };
+ }
+ return {
+ content: [{ type: "text" as const, text: `Error: ${msg}` }],
+ isError: true,
+ };
+ }
+ },
+ );
+
// =============================================
// Tool: set_video
// =============================================
diff --git a/src/ui/web-server.ts b/src/ui/web-server.ts
index 6f90c11..3196909 100644
--- a/src/ui/web-server.ts
+++ b/src/ui/web-server.ts
@@ -1561,6 +1561,16 @@ app.post("/api/analyze-energy", async (req, res) => {
}
});
+// --- Highlight reel: detect once, then iterate on moments ---
+app.post("/api/reel", async (req, res) => {
+ try {
+ const result = await executor.execute("manage_reel", req.body || {});
+ res.json(result.data || {});
+ } catch (err: any) {
+ res.status(500).json({ error: err.message });
+ }
+});
+
// --- Encoder info ---
app.get("/api/encoder-info", async (_req, res) => {
try {