feat(mcp): auto_hook and hook_style on process_video

The dashboard burns the AI hook line by default; API/MCP callers never
could because the field is off when absent. Exposed as an explicit opt-in
so existing integrations keep their output byte-for-byte.
This commit is contained in:
juancarlos.cavero 2026-08-27 19:35:40 +02:00
parent 3d637f51ce
commit 8251f4f02a
4 changed files with 34 additions and 3 deletions

View file

@ -314,7 +314,7 @@ claude mcp add --transport http openshorts https://mcp.openshorts.app/mcp \
claude mcp add --transport http openshorts http://localhost:8000/mcp claude mcp add --transport http openshorts http://localhost:8000/mcp
``` ```
Tools: `process_video` (URL or `upload_id`, `captions: false` when the source already has subtitles), `create_upload` (hand the agent a local file: PUT the bytes, then process), `get_job_status`, `list_clips`, `get_quota`, `add_subtitles`, `recut_clip`, `publish_clip`. A prompt like *"clip this podcast and schedule the best 3 to TikTok"* is now a one-liner in your agent of choice. Tools: `process_video` (URL or `upload_id`; `captions: false` when the source already has subtitles, `auto_hook: true` to burn the hook line like the dashboard), `create_upload` (hand the agent a local file: PUT the bytes, then process), `get_job_status`, `list_clips`, `get_quota`, `add_subtitles`, `recut_clip`, `publish_clip`. A prompt like *"clip this podcast and schedule the best 3 to TikTok"* is now a one-liner in your agent of choice.
### REST API + API keys ### REST API + API keys

View file

@ -1069,7 +1069,7 @@ snippets for Claude Desktop, Cursor, n8n and curl.</p>
<table> <table>
<thead><tr><th>Tool</th><th>What it does</th></tr></thead> <thead><tr><th>Tool</th><th>What it does</th></tr></thead>
<tbody> <tbody>
<tr><td><code>process_video</code></td><td>Starts clipping a video from a URL or an upload_id. Returns a job id immediately; processing takes minutes. Pass captions: false when the source already has subtitles burned in.</td></tr> <tr><td><code>process_video</code></td><td>Starts clipping a video from a URL or an upload_id. Returns a job id immediately; processing takes minutes. Pass captions: false when the source already has subtitles burned in, auto_hook: true to burn the hook line.</td></tr>
<tr><td><code>create_upload</code></td><td>Reserves an upload slot for a local file: the agent PUTs the bytes to the returned URL, then processes it by upload_id.</td></tr> <tr><td><code>create_upload</code></td><td>Reserves an upload slot for a local file: the agent PUTs the bytes to the returned URL, then processes it by upload_id.</td></tr>
<tr><td><code>get_job_status</code></td><td>Progress, recent log lines, and the clips once the job completes.</td></tr> <tr><td><code>get_job_status</code></td><td>Progress, recent log lines, and the clips once the job completes.</td></tr>
<tr><td><code>list_clips</code></td><td>Titles, durations, platform-ready descriptions and download URLs for a finished job.</td></tr> <tr><td><code>list_clips</code></td><td>Titles, durations, platform-ready descriptions and download URLs for a finished job.</td></tr>

View file

@ -62,7 +62,9 @@ TOOLS = [
"description": ( "description": (
"Start clipping a video from its URL. OpenShorts downloads the " "Start clipping a video from its URL. OpenShorts downloads the "
"source itself, transcribes it, finds the most viral moments with AI " "source itself, transcribes it, finds the most viral moments with AI "
"and renders vertical (9:16) clips with captions. Call this directly " "and renders vertical (9:16) clips. Captions are burned unless "
"captions=false; the AI hook line is burned only with auto_hook=true. "
"Call this directly "
"with the URL the user gave you; do not fetch, search or inspect the " "with the URL the user gave you; do not fetch, search or inspect the "
"URL yourself first (you cannot access the video, and it is not " "URL yourself first (you cannot access the video, and it is not "
"needed). Returns a job_id immediately — the work takes minutes; " "needed). Returns a job_id immediately — the work takes minutes; "
@ -86,6 +88,17 @@ TOOLS = [
"file was PUT to its upload_url. Use when the user gave you a " "file was PUT to its upload_url. Use when the user gave you a "
"video file rather than a link.", "video file rather than a link.",
}, },
"auto_hook": {
"type": "boolean",
"description": "Burn the AI-written hook line (the clip's title) over the first "
"seconds of each clip, as the dashboard does by default. Off when "
"omitted, so existing integrations keep their output.",
},
"hook_style": {
"type": "string",
"enum": ["classic", "dark", "yellow", "red", "outline", "outline_yellow"],
"description": "Look of the hook text (with auto_hook). Default classic.",
},
"captions": { "captions": {
"type": "boolean", "type": "boolean",
"description": "Default true: burn word-level captions on every clip. Set false " "description": "Default true: burn word-level captions on every clip. Set false "
@ -346,6 +359,10 @@ async def _tool_process_video(client, args):
for k in ("target_clips", "clip_min_seconds", "clip_max_seconds", "captions"): for k in ("target_clips", "clip_min_seconds", "clip_max_seconds", "captions"):
if args.get(k) is not None: if args.get(k) is not None:
body[k] = args[k] body[k] = args[k]
if args.get("auto_hook"):
body["auto_hook"] = True
if args.get("hook_style"):
body["auto_hook_style"] = args["hook_style"]
resp = await client.post("/api/process", json=body) resp = await client.post("/api/process", json=body)
if resp.status_code >= 400: if resp.status_code >= 400:
return _api_error(resp), True return _api_error(resp), True

View file

@ -141,3 +141,17 @@ def test_tmpfiles_link_is_refreshed_through_the_page():
assert file_hosts.resolve_tmpfiles("https://tmpfiles.org/wAwNGnPW0lXW/video.mp4", fetch=fetch) == fresh assert file_hosts.resolve_tmpfiles("https://tmpfiles.org/wAwNGnPW0lXW/video.mp4", fetch=fetch) == fresh
assert file_hosts.resolve_tmpfiles(stale, fetch=lambda u: "<html>no link</html>") == stale assert file_hosts.resolve_tmpfiles(stale, fetch=lambda u: "<html>no link</html>") == stale
assert not file_hosts.is_tmpfiles("https://youtube.com/watch?v=x") assert not file_hosts.is_tmpfiles("https://youtube.com/watch?v=x")
def test_auto_hook_reaches_the_job_env(dirs, monkeypatch):
slot = _tool_payload(_mcp("create_upload", {}))
async def _put():
async with _client() as c:
return await c.put(f"/api/uploads/{slot['upload_id']}", content=b"x" * 100)
assert asyncio.run(_put()).status_code == 200
async def fake_put(item): pass
monkeypatch.setattr(app_module.job_queue, "put", fake_put)
payload = _tool_payload(_mcp("process_video", {"upload_id": slot["upload_id"], "confirm_rights": True,
"auto_hook": True, "hook_style": "yellow"}))
env = app_module.jobs[payload["job_id"]]["env"]
assert env["AUTO_HOOK"] == "1" and env["AUTO_HOOK_STYLE"] == "yellow"