Architecture & verification guide
How can an AI coding agent (Claude Code, Codex, or MCP client) download and extract audio from videos reliably via MCP?
Direct answer
Connect your agent to a stateless Streamable HTTP MCP server (POST https://videodownloadmcp.com/mcp, JSON-RPC 2.0, Bearer vd_ key) that exposes six narrow tools: resolve_video, list_formats, download_video, get_download, cancel_download, and extract_audio. The agent inspects metadata free first, queues one asynchronous MP4, 192 kbps MP3, or short GIF job, polls get_download until a terminal status, and downloads a signed capability URL that expires in 15 minutes. No local yt-dlp or ffmpeg is required, and failed or canceled active jobs automatically refund their credit.
Reviewed by the Videodownload engineering team · · Protocol 2025-06-18 · First-party codebase & test evidence only (no fabricated benchmarks or third-party reviews).
Copy-paste setup by client
Use remote Streamable HTTP /mcp with VIDEODOWNLOAD_API_KEY in your process environment. For stdio-only environments in an authorized repository checkout, packages/mcp-server/index.mjs proxies the same six tools over /v1 REST.
{
"mcpServers": {
"videodownload": {
"type": "http",
"url": "https://videodownloadmcp.com/mcp",
"headers": { "Authorization": "Bearer ${VIDEODOWNLOAD_API_KEY}" }
}
}
}Merge into .mcp.json. Supply VIDEODOWNLOAD_API_KEY in the process environment; never hardcode the key in git or chat.
- Resolve free first: call
resolve_videoto confirm the link is public, check duration (≤30 min), and inspect real MP4/MP3/GIF formats without spending a credit. - Create one job: call
download_video(MP4 or GIF) orextract_audio(192 kbps MP3). Save the returnedjob_id— a second create call starts a separate job. - Poll until terminal: call
get_downloadevery ~2s whilequeued / resolving / downloading / processing; stop onready / failed / canceled / expired. - Save within 15 minutes or branch on error.code: fetch
file.urlbeforefile.expires_at, or inspectisError+error.code(failed/canceled active jobs refund automatically).
The 6 implemented MCP tools
Defined once in src/config/mcp-tools.ts and served by src/server/mcp/handler.ts. Every tool mirrors a /v1 REST route and returns both structuredContent and JSON text.
| MCP tool | Purpose | REST equivalent | Billing & limit |
|---|---|---|---|
| resolve_video | Resolve a public video URL into title, duration, thumbnail, platform, uploader, and available formats. Use this before download_video when the user wants to choose a quality. | POST /v1/resolve | Free (20/min/key) |
| list_formats | Return the MP4, MP3, and GIF formats available for a public URL, with dimensions, file size estimates, and whether a video format already includes audio. | GET /v1/formats?url= | Free (20/min/key) |
| download_video | Create an asynchronous download job for a public video URL. Returns a job_id and status. Poll get_download for progress and a signed download URL. Costs 1 credit. | POST /v1/downloads | 1 credit · auto-refunds on fail/cancel (8/min/key) |
| get_download | Get the status, progress, metadata, and signed file URL for a download job. The file URL expires 15 minutes after the job becomes ready. | GET /v1/downloads/:id | Free |
| cancel_download | Cancel a queued or running download job and refund its credit when one was charged. | DELETE /v1/downloads/:id | Free · refunds active job |
| extract_audio | Create an asynchronous MP3 extraction job for a public video URL. Costs 1 credit. Same job lifecycle as download_video. | POST /v1/audio | 1 credit · 192 kbps MP3 · auto-refunds on fail/cancel |
Resolve rate limit
20/min per key
Job create limit
8/min per key
Max duration / size
30 min · 500 MB
Signed file lifetime
15 min after ready
Security, SSRF, expiry & refund architecture
Every guardrail below is enforced server-side in code, not just requested in a prompt or SKILL.md instruction.
| Control | Implemented behavior | Codebase reference |
|---|---|---|
| Gateway boundary | App gateway authenticates Bearer vd_ keys (missing/invalid keys return HTTP 401 before JSON-RPC runs) and calls the isolated Node worker with internal DOWNLOADER_SECRET. The worker is never exposed directly to browsers or agents. | src/server/mcp/handler.ts |
| URL & host allowlist | Only http: and https: URLs on ports 80 or 443 up to 2,048 characters are accepted. Embedded user:pass credentials, IP literals, localhost, single-label hosts, and internal suffixes (.localhost, .local, .internal, .home.arpa, .lan, .intranet, .corp) are rejected with INVALID_URL. Unlisted hosts fail with UNSUPPORTED_PLATFORM (HTTP 422). | services/downloader/src/urls.mjs · config.mjs |
| DNS private-IP SSRF blocking | Before yt-dlp runs, the worker resolves DNS (lookup(..., { all: true, verbatim: true })) and rejects any IPv4 private/CGNAT/link-local/cloud-metadata range (127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10, 169.254.0.0/16, multicast/reserved) or IPv6 loopback/ULA/link-local/IPv4-mapped/NAT64 address. | services/downloader/src/urls.mjs |
| Signed 15-minute file URLs | Ready files are served via signed capability URLs (/v1/files/:id?token=...) validated by both the app and worker. FILE_TTL_SEC is 900 seconds (15 minutes) from ready; polling never extends expiry, and no permanent media URL exists. | services/downloader/src/config.mjs · persistence.mjs |
| Resource caps & no cookies | Hard caps enforce 30-minute maximum duration (10 minutes and 480px max height for GIF; MP3 shares the 30-minute source cap) and 500 MB max file size. The worker never accepts user cookies or passwords, so DRM, private, and login-walled posts fail cleanly with explicit error codes. | src/config/downloads.ts · services/downloader/src/config.mjs |
| Atomic billing & auto-refund | resolve_video and list_formats cost 0 credits. download_video and extract_audio reserve 1 credit atomically; failed jobs or active jobs canceled with cancel_download automatically refund once via atomic claim guards. Ready or expired jobs are not refunded. | src/modules/downloads/service.ts · tests/download-lifecycle.test.ts |
Verifiable first-party test evidence
Recorded observations from owner-authorized public samples. First-party SDK, stdio, and worker checks are listed separately from native third-party desktop GUI approvals (which remain client-controlled).
| Date | Environment | Authorized sample | Observed outcome |
|---|---|---|---|
| 2026-11-24 | Isolated app + deployed Railway worker (first-party SDK) | Public TikTok video (@scout2015, 10s, owner-authorized test sample) | Official MCP SDK over HTTP and repository stdio proxy both listed 6 tools, moved queued → ready, charged 1 credit, and fetched signed MP4 (HTTP 200, video/mp4, 1,202,896 bytes, valid ftyp header). Bad token returned HTTP 401; file:// URL returned INVALID_URL. |
| 2026-11-24 | Production worker network (first-party resolve check) | Public YouTube sample ("Me at the zoo", owner-authorized) | Returned LOGIN_REQUIRED on the worker network because the service refuses to inject account cookies. Recorded as an honest refusal rather than substituting older November 14 success. |
| 2026-11-25 | Production Cloudflare Worker + Railway downloader | Signed file persistence & 900-second expiry verification | Signed file URL returned HTTP 200 with identical bytes across a Railway worker restart without extending expiry; after 900 seconds the same URL returned HTTP 401 and physical temp directory + manifest were confirmed deleted. |
| 2026-11-25 | Production HTTP MCP + repository stdio (API-only QA account) | Public Pinterest video Pin (15s, owner-authorized) | HTTP MCP completed queued → ready (1 credit) and delivered an 847,653-byte H.264/AAC MP4; repository stdio read the same ready job. Duplicate get_download and cancel-after-ready neither double-charged nor refunded; 0-balance create returned INSUFFICIENT_CREDITS. |
Honest scope note: first-party tests verify the hosted HTTP MCP endpoint, official MCP client SDK, repository stdio adapter, worker SSRF/expiry/cleanup logic, and atomic credit refunds. Platform access can change at any time, and third-party desktop client UIs (Claude Desktop, Cursor UI, Codex app) enforce their own tool-approval prompts. See dated platform tests and the shared Web, MCP & Skill walkthrough.
Who this is for — and who should not use it
Use these decision rules before integrating Videodownload MCP into a coding agent or production workflow.
Choose Videodownload MCP when
- You want Claude Code, Codex, Cursor, Antigravity, or a custom MCP client to download public MP4 video, extract 192 kbps MP3 audio, or create short 480p GIFs without installing Python,
yt-dlp, orffmpegon every machine. - You need server-enforced guardrails for autonomous agent loops: platform host allowlist, DNS private-IP SSRF blocking, 30-minute / 500 MB caps, per-key rate limits, and automatic 15-minute file expiry.
- You want free pre-flight format checks (
resolve_video) and pay-as-you-go metering where failed or canceled jobs refund automatically.
Do not use Videodownload MCP when
- You need private, follower-only, age-gated, members-only, paywalled, or DRM-protected videos (including Instagram Stories or YouTube login-walled streams) — the worker never accepts cookies or passwords and refuses them with
PRIVATE_CONTENT,LOGIN_REQUIRED, orDRM_PROTECTED. - You need live stream recording (
LIVE_NOT_SUPPORTED), channel or playlist scraping, photo/carousel album exports, media longer than 30 minutes (10 minutes for GIF), files over 500 MB, or permanent CDN URLs. - You are a single developer working locally who needs zero external network calls, unlimited local disk storage, or your own authenticated cookies — run local
yt-dlpinstead (see Hosted MCP vs local yt-dlp MCP).
Downloading a public URL does not grant copyright or redistribution rights. Use this service only on media you own or have permission to process, and follow each platform's terms and the Terms of Service.
Technical FAQ
Short answers grounded in the current MCP handler and downloader worker.
Does the AI coding agent need yt-dlp, Python, or ffmpeg installed locally?+
No. When connected to the hosted streamable HTTP endpoint at https://videodownloadmcp.com/mcp, yt-dlp and ffmpeg run inside the isolated download worker. The agent only exchanges JSON-RPC 2.0 tool calls and receives a temporary 15-minute signed file URL.
How does audio extraction work through MCP?+
Call resolve_video first (free) to confirm the post is public and within the 30-minute limit, then call extract_audio with the URL (or download_video with format "audio"). The worker extracts a 192 kbps MP3 with ffmpeg and returns a signed URL via get_download. MP3 extraction uses the same 30-minute source cap and 15-minute file expiry.
What happens if a download fails, hits a login wall, or is canceled?+
Failed jobs and active jobs canceled with cancel_download automatically refund the reserved credit once. Tool refusals return result.isError: true with a stable machine-readable code such as LOGIN_REQUIRED, PRIVATE_CONTENT, DRM_PROTECTED, or DURATION_LIMIT_EXCEEDED so the agent can stop instead of looping.
Why does the worker block custom domains and private IP addresses?+
Because an autonomous agent can be prompted with untrusted URLs. Restricting requests to an allowlist of supported video platforms and resolving DNS to reject private, loopback, CGNAT, link-local, and cloud-metadata IPs prevents the downloader from acting as an SSRF proxy.
Can this download private videos, DRM streams, or live broadcasts?+
No. The worker never accepts account cookies or passwords and explicitly refuses private, follower-only, age-gated, paywalled, DRM-protected, and live streams.
Create a dedicated vd_ API key, connect /mcp, and run a free resolve_video call before starting a download job.