MediaVault MCP
# ๐๏ธ MediaVault MCP
**[English](README.md)** ๏ฝ **[็ฎไฝไธญๆ](README.zh-CN.md)**
[](https://github.com/Majiturbo/mediavault-mcp/actions/workflows/ci.yml)
[](https://github.com/Majiturbo/mediavault-mcp)
[](https://www.python.org/)
[](https://modelcontextprotocol.io/)
[](LICENSE)
[](CONTRIBUTING.md)
> **Paste a link, get the original.** A local, key-free stdio MCP server that
> pulls native no-watermark media from 1800+ platforms and hands your AI agent
> real video evidence โ transcript plus keyframe images โ without ever calling
> a second LLM.
Your agent already has a model. Why should a media MCP demand another API key?
MediaVault collects deterministic evidence on your machine
(yt-dlp / f2 / gallery-dl โ ffmpeg โ local Whisper) and returns it as MCP
content blocks, so **the agent you already run does the reasoning**. An
optional server-side summary fusion is there if you want it, but it is never
required.
## โจ Why MediaVault?
- ๐ **Zero required API keys.** `parse_url`, `download` and `analyze` work with no key and never call a third-party model. Speech is transcribed on-device with faster-whisper; frames come back as image blocks for the agent's own vision.
- ๐ก๏ธ **Honest no-watermark claims.** We fetch the platform's own source stream and report `native` / `unknown` / `none` per item. No cropping, no inpainting, no pretending a watermark was removed.
- ๐ **Scored adapter fallback chain.** f2 (CN-first) โ gallery-dl (image sets) โ yt-dlp (1800+ sites). A stale extractor degrades transparently instead of failing the request.
- ๐ง **Agent-native video understanding.** One `analyze` call returns a JSON evidence block (caption, timestamped transcript, pipeline status) **plus one image content block per keyframe** โ exactly what a vision-capable agent needs.
- ๐ **Persistent media library.** Every result is atomically cached per video; repeat calls skip re-downloading and re-transcribing, with `refresh=true` to force a fresh run.
- ๐ **Local-first and private.** Cookies and proxies stay on your machine, are validated before use, and never appear in logs or cached evidence.
## ๐งฉ How it works
```mermaid
flowchart LR
A[AI Agent / MCP Client] -->|stdio JSON-RPC| B[MediaVault MCP Server]
B --> C[Scored Adapter Registry]
C --> D1["f2 ยท score 200<br/>Douyin / XHS / Kuaishou / TikTok"]
C --> D2["gallery-dl ยท 150<br/>image sets"]
C --> D3["yt-dlp ยท 100<br/>1800+ sites"]
D1 -. AdapterStale .-> D2 -. AdapterStale .-> D3
B --> E[Key-free Evidence Pipeline]
E --> Gf[ffmpeg keyframes]
E --> Gw[faster-whisper on-device ASR]
B --> H[("Media Library<br/>evidence.json cache")]
B -. optional .-> I[OpenAI-compatible endpoint<br/>summarize fusion only]
```
The MCP surface never changes when a platform shifts: only the adapter behind
the registry does, and `AdapterStale` automatically walks the chain.
## ๐ Quick start
Requires Python 3.11+, [uv](https://docs.astral.sh/uv/), and ffmpeg
(`brew install ffmpeg` on macOS, or your distro's package).
```bash
git clone https://github.com/Majiturbo/mediavault-mcp.git
cd mediavault-mcp
uv venv --python 3.11
uv pip install -e ".[dev]"
uv pip install -e ".[local-asr]" # optional: fully offline speech-to-text
cp .env.example .env # optional: proxy/cookies/LLM settings
```
Run the stdio server:
```bash
uv run python -m mediavault
# or the installed console script: mediavault
```
Point any MCP client at it (stdio):
```json
{
"mcpServers": {
"mediavault": {
"command": "uv",
"args": ["--directory", "/abs/path/to/mediavault-mcp",
"run", "python", "-m", "mediavault"]
}
}
}
```
Optional backends are auto-detected on PATH โ install neither, one, or both:
```bash
pipx install f2 # first-class Douyin/Xiaohongshu/Kuaishou/TikTok/Weibo/Bilibili
pipx install gallery-dl # image-set posts (Xiaohongshu, Instagram, Pinterest, Weibo)
```
## ๐ ๏ธ The seven tools
| Tool | Input | What it does |
|---|---|---|
| `parse_url` | share text or URL | Normalized metadata, no bytes downloaded |
| `download` | share text or URL, `quality=compat/quality/speed` | Native media under `MEDIAVAULT_HOME` |
| `analyze` | share text or URL, `with_media=true`, `refresh=false` | **No key**: JSON evidence + keyframe image blocks, cached per video |
| `summarize` | share text or URL, `with_media=true` | Optional server-side fused summary job (needs an OpenAI-compatible endpoint); poll with `get_job` |
| `get_job` | job id | Job polling (queued/running/succeeded/failed) |
| `list_jobs` | โ | Recent background jobs, newest first |
| `list_library` | โ | Index cached evidence/summary artifacts |
Collection responses use an explicit envelope `{"count": n, "results": [...]}`,
so a pasted blob with several links never silently loses one. `analyze` is
single-resource (its images belong to one clip) and reports `urls_detected` /
`additional_urls` so the agent knows which links still need a call.
## ๐ Platform coverage
| Platform | Video | Image sets | Primary adapter |
|---|:---:|:---:|---|
| Douyin (ๆ้ณ), Kuaishou (ๅฟซๆ) | โ
| โ | f2 โ yt-dlp fallback |
| Xiaohongshu (ๅฐ็บขไนฆ) | โ
| โ
| f2 โ gallery-dl โ yt-dlp |
| TikTok, Weibo (ๅพฎๅ), Bilibili (B็ซ) | โ
| partial | f2 โ yt-dlp |
| YouTube, X/Twitter, Vimeo, Reddit | โ
| โ | yt-dlp (native clean streams) |
| Instagram, Pinterest | โ
| โ
| gallery-dl โ yt-dlp |
| 1800+ other yt-dlp sites | โ
| partial | yt-dlp |
External CLIs are optional: when f2 or gallery-dl is absent, its adapter raises
`AdapterStale` and the registry falls through automatically โ the same MCP
call keeps working.
## ๐ง Two ways to understand a video
**1. `analyze` โ agent-native, no key (recommended).** Deterministic evidence:
title/author/caption, a timestamped transcript (local faster-whisper or your ASR
endpoint), and up to `MEDIAVAULT_KEYFRAME_MAX` downscaled JPEG keyframes
returned as MCP image blocks. Every stage reports itself honestly in `pipeline`
(`ok` / `off` / `not-configured` / `extracted` / `skipped-*` / `empty` /
`error`); one failed stage never kills the run. Your agent reads the transcript
and looks at the frames with its own model.
**2. `summarize` โ optional server-side fusion.** Runs the same evidence
collection, then makes one OpenAI-compatible chat call that fuses caption,
transcript and visual observations into a stable schema (`tldr`, `chapters`,
`entities`, `hooks`, ...). Fails fast with an actionable message when no
endpoint is configured โ in which case `analyze` is the answer.
### Fully local, no commercial key
Point everything at a local stack and keep audio on-device:
```bash
OPENAI_BASE_URL=http://localhost:11434/v1 # Ollama / LM Studio / vLLM
OPENAI_API_KEY=ollama # placeholder, local servers ignore it
MEDIAVAULT_LLM_MODEL=qwen2.5
MEDIAVAULT_VLM_MODEL=llava
MEDIAVAULT_ASR_BACKEND=local # faster-whisper, audio never leaves the machine
MEDIAVAULT_WHISPER_MODEL=base
MEDIAVAULT_WHISPER_DEVICE=mps # cpu on CI/Linux ยท mps on Apple Silicon ยท cuda on NVIDIA
```
## โ๏ธ Configuration
All settings come from environment variables or `.env` (see
[.env.example](.env.example) for the full list).
| Variable | Default | Purpose |
|---|---|---|
| `MEDIAVAULT_HOME` | `~/MediaVault` | Download + cache root (`<platform>/<id>/`) |
| `MEDIAVAULT_PROXY` | โ | `http(s)/socks4/socks5/socks5h`; bare `host:port` assumed HTTP; invalid values fail fast |
| `MEDIAVAULT_COOKIES_FILE` | โ | Netscape cookies.txt, validated before use; bad paths skipped with a warning |
| `MEDIAVAULT_COOKIES_BROWSER` | โ | Reuse a logged-in browser (chrome/firefox/...) |
| `MEDIAVAULT_F2_BIN` / `MEDIAVAULT_GALLERYDL_BIN` | `f2` / `gallery-dl` | Override optional CLI paths |
| `MEDIAVAULT_ASR_BACKEND` | `openai` | `openai` (hosted) / `local` (faster-whisper) / `off` |
| `MEDIAVAULT_WHISPER_MODEL` / `_DEVICE` | `base` / `cpu` | Local ASR size and device (cpu/mps/cuda) |
| `MEDIAVAULT_KEYFRAME_MAX` / `_WIDTH` | `8` / `768` | Frame budget and downscale width |
| `OPENAI_BASE_URL` / `OPENAI_API_KEY` | OpenAI / โ | Only needed for `summarize`, hosted ASR and server VLM |
Downloads land in `~/MediaVault/<platform>/<canonical_id>/` alongside
`resource.json`, `evidence.json` (the analyze cache) and optional
`summary.json`; media runs also write `audio.wav` and a `keyframes/` folder.
## ๐งญ Design principles
1. **The host agent is the brain.** MCP servers should gather evidence, not rent a second LLM behind the caller's back. Model calls are opt-in.
2. **Degrade honestly, per stage.** Every adapter failure, skipped media stage and ignored cookie file is surfaced as a marker or note โ never hidden.
3. **No-watermark means source-native, not "removed".** We never crop or blur; unverifiable streams stay `unknown`.
4. **Credentials stay local.** No third-party parser keys, no telemetry, no credentials in URLs, logs or caches.
5. **Test the seams, mock the world.** 228 offline tests at 100% statement and branch coverage; real ffmpeg smoke tests run when ffmpeg is present and skip themselves otherwise.
## ๐บ๏ธ Roadmap
- **Next:** self-built SSR adapters for CN platforms (calibrated against live page shapes), richer local models โ speaker diarization and denser scene detection.
- **Always:** keeping the adapter chain and evidence schema stable while platforms drift.
## ๐งช Development
```bash
.venv/bin/ruff check src tests # lint
.venv/bin/python -m pytest -q --cov-fail-under=100 # offline suite, 100% gate
uv build # wheel + sdist
```
CI runs the same three checks on Ubuntu/macOS ร Python 3.11/3.12. See
[CONTRIBUTING.md](CONTRIBUTING.md) for the adapter contract and coverage
policy, [CHANGELOG.md](CHANGELOG.md) for release history, and
[SECURITY.md](SECURITY.md) for vulnerability reporting.
## โ๏ธ License
[MIT](LICENSE). Only process publicly available content, respect each
platform's terms of service and applicable copyright, and keep downloads for
personal study. This project performs no DRM circumvention.
TDQS
Scored across 7 tools
Most tools are clearly separated by resource and action: parse_url only extracts metadata, download only fetches bytes, and get_job/list_jobs/list_library are distinct. The only fuzzy pair is analyze vs summarize, which both process a video but differ in who produces the summary; the descriptions call this out explicitly, so an agent can distinguish them.
The set mostly uses a verb_noun pattern (parse_url, list_library, get_job, list_jobs) but mixes in bare verbs (download, analyze, summarize). It is still readable and intuitive, just not a single uniform convention.
Seven tools is well-scoped for a media ingest/analyze/summarize server: metadata parsing, downloading, local evidence collection, server-side summarization, job polling/listing, and library listing. Each tool has a clear role without filler.
The core lifecycle is covered: parse, download, analyze, summarize, track jobs, and list cached artifacts. Minor gaps remain, such as no job cancellation, no deletion/cleanup of library entries, and no single-item library lookup, but these are workable omissions.