feat(mcp): burn the hook line by default, auto_hook=false opts out

Matches the dashboard: an agent user expects the same clips they get in
the app. The REST endpoint keeps absent=off for older integrations.
This commit is contained in:
juancarlos.cavero 2026-08-27 20:26:57 +02:00
parent 8251f4f02a
commit 3e74fe47f7
4 changed files with 25 additions and 8 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, `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. Tools: `process_video` (URL or `upload_id`; `captions: false` when the source already has subtitles, `auto_hook: false` to skip the hook line, burned by default 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, auto_hook: true to burn the hook line.</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: false to skip the hook line (on by default).</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,8 +62,8 @@ 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. Captions are burned unless " "and renders vertical (9:16) clips. Captions and the AI hook line are "
"captions=false; the AI hook line is burned only with auto_hook=true. " "burned by default; pass captions=false or auto_hook=false to skip either. "
"Call this directly " "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 "
@ -91,8 +91,8 @@ TOOLS = [
"auto_hook": { "auto_hook": {
"type": "boolean", "type": "boolean",
"description": "Burn the AI-written hook line (the clip's title) over the first " "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 " "seconds of each clip, as the dashboard does. Default true; set "
"omitted, so existing integrations keep their output.", "false for clean clips.",
}, },
"hook_style": { "hook_style": {
"type": "string", "type": "string",
@ -359,7 +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"): # Same default as the dashboard: hook on unless the caller opts out. The
# REST endpoint keeps "absent = off" for older integrations; the MCP
# tool is newer than the hook and its users expect the dashboard output.
if args.get("auto_hook", True):
body["auto_hook"] = True body["auto_hook"] = True
if args.get("hook_style"): if args.get("hook_style"):
body["auto_hook_style"] = args["hook_style"] body["auto_hook_style"] = args["hook_style"]

View file

@ -97,7 +97,9 @@ def test_captions_default_leaves_env_alone(dirs, monkeypatch):
async def fake_put(item): pass async def fake_put(item): pass
monkeypatch.setattr(app_module.job_queue, "put", fake_put) monkeypatch.setattr(app_module.job_queue, "put", fake_put)
payload = _tool_payload(_mcp("process_video", {"upload_id": slot["upload_id"], "confirm_rights": True})) payload = _tool_payload(_mcp("process_video", {"upload_id": slot["upload_id"], "confirm_rights": True}))
assert "AUTO_CAPTIONS" not in app_module.jobs[payload["job_id"]]["env"] env = app_module.jobs[payload["job_id"]]["env"]
assert "AUTO_CAPTIONS" not in env
assert env["AUTO_HOOK"] == "1" # MCP default matches the dashboard
def test_unknown_or_unfinished_upload_id(dirs): def test_unknown_or_unfinished_upload_id(dirs):
@ -155,3 +157,15 @@ def test_auto_hook_reaches_the_job_env(dirs, monkeypatch):
"auto_hook": True, "hook_style": "yellow"})) "auto_hook": True, "hook_style": "yellow"}))
env = app_module.jobs[payload["job_id"]]["env"] env = app_module.jobs[payload["job_id"]]["env"]
assert env["AUTO_HOOK"] == "1" and env["AUTO_HOOK_STYLE"] == "yellow" assert env["AUTO_HOOK"] == "1" and env["AUTO_HOOK_STYLE"] == "yellow"
def test_auto_hook_false_opts_out(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": False}))
assert "AUTO_HOOK" not in app_module.jobs[payload["job_id"]]["env"]