Skip to main content
Glama
README.md
# Local Video MCP

[![CI](https://github.com/op7en/local-video-mcp/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/op7en/local-video-mcp/actions/workflows/tests.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

Local Video MCP is a Python MCP server that lets a desktop client inspect local video and audio over stdio. It returns metadata and frames, samples scenes and audio activity, and runs longer indexing or transcription jobs in background processes. Source media stays on the machine. A client can still send returned text or images to its configured model provider.

## Architecture

```mermaid
flowchart LR
    Client[MCP client] <-->|JSON-RPC over stdio| Server[Python MCP server]
    Server --> Guard[Source path validation]
    Server --> Media[Media analyzer]
    Server --> Manager[Job manager]
    Manager --> DB[(SQLite job state)]
    Manager --> Worker[Python worker]
    Media --> FF[FFmpeg and ffprobe]
    Worker --> FF
    Worker --> Whisper[Local Whisper backend]
    Server --> Cache[(File cache)]
    Worker --> Cache
    Worker --> DB
```

The server handles bounded requests and leaves long operations to workers. SQLite tracks job state. The file cache stores frames, indexes, transcript chunks and other generated artifacts.

## Tools

| Tool | Purpose |
| --- | --- |
| `list_videos` | List supported video files under an allowed folder. |
| `get_video_info` | Read container and stream metadata. |
| `get_video_frame` | Extract one frame at a timestamp. |
| `get_video_contact_sheet` | Sample frames across a time range. |
| `start_video_index` | Queue a background indexing job. |
| `transcribe_video` | Queue local Whisper transcription. |
| `get_job_status` | Read job state, progress and available results. |
| `list_jobs` | List recent jobs. |
| `cancel_job` | Request cancellation of an active job. |
| `get_scene_index` | Retrieve sampled scene information. |
| `get_audio_activity` | Retrieve approximate audio activity and silence. |
| `get_transcript` | Read transcript segments for a time range. |
| `search_transcript` | Search locally cached transcript segments. |
| `get_video_mcp_status` | Inspect server and dependency status. |
| `start_audio_qa` | Queue an acoustic analysis job. |
| `get_audio_qa` | Read acoustic measurements. |
| `compare_voice_takes` | Compare acoustic measurements for voice takes. |
| `get_video_quality_report` | Summarize available video and audio quality findings. |
| `start_voice_enhance` | Queue voice processing and artifact generation. |
| `get_voice_enhancement` | Inspect a voice processing result. |
| `compare_audio_versions` | Compare audio versions with level matching. |

## Requirements and installation

Use Windows 11, 64-bit Python 3.13, and a local FFmpeg distribution with both `ffmpeg.exe` and `ffprobe.exe` on PATH. The test fixtures also require the `libx264` encoder. Allow disk space for dependencies, models and generated artifacts. The project uses the Python MCP SDK, SQLite, FFmpeg, Pillow, psutil, NumPy and local Whisper. Other operating systems have no verified support in this release.

Download a Windows build from the [FFmpeg builds page](https://www.gyan.dev/ffmpeg/builds/). Extract it, add its `bin` directory to your user PATH, and open a new PowerShell window. Verify that the binaries and test encoder are available.

```powershell
ffmpeg -version
ffprobe -version
ffmpeg -hide_banner -encoders | Select-String libx264
```

From PowerShell, in the repository root:

```powershell
py -3.13 -m venv .venv
.\.venv\Scripts\python.exe -X utf8 -m pip install -r requirements.txt
ffmpeg -version
ffprobe -version
$env:VIDEO_MCP_ALLOWED_ROOTS = 'C:\path\to\media'
.\.venv\Scripts\python.exe -B -X utf8 server.py
```

The process waits for an MCP client on stdio. Its stdout carries JSON-RPC messages. To use the optional faster-whisper backend, install `requirements-faster-whisper.txt` into the same environment and select that backend in the client configuration.

Example MCP client configuration:

```json
{
  "mcpServers": {
    "local-video": {
      "command": "C:/path/to/local-video-mcp/.venv/Scripts/python.exe",
      "args": ["-B", "-X", "utf8", "C:/path/to/local-video-mcp/server.py"],
      "env": {
        "VIDEO_MCP_ALLOWED_ROOTS": "C:/path/to/media;D:/path/to/other-media"
      }
    }
  }
}
```

## Configuration and file access

| Variable | Purpose |
| --- | --- |
| `VIDEO_MCP_ALLOWED_ROOTS` | Required for media operations. Use semicolon-separated existing local directories on Windows. |
| `WHISPER_BACKEND`, `WHISPER_MODEL` | Select the local backend and model. |
| `VIDEO_MCP_OFFLINE` | Require locally available model data where supported. |
| `VIDEO_MCP_CACHE_DIR` | Server-generated data directory within the repository, defaulting to `.analysis-cache`. |
| `VIDEO_MCP_FFMPEG_BIN`, `VIDEO_MCP_FFPROBE_BIN` | Optional executable overrides. |
| `VIDEO_MCP_FFMPEG_MAX_ALLOC_BYTES` | FFmpeg allocation limit for analysis paths that use the configurable limit. |
| `VIDEO_MCP_POWER_POLICY`, `VIDEO_MCP_CPU_THREADS` | Processing and CPU thread controls. |
| `VIDEO_MCP_DEEPFILTER_BIN` | Optional path to the external DeepFilterNet executable. |

See `video_mcp/config.py` for the complete environment list and defaults. Prefer a dedicated input directory with permissions that prevent other users or processes from replacing files during analysis. Path checks reject UNC, Windows device paths, alternate data streams, symlinks and junctions. FFmpeg inputs are restricted to the file protocol and listed container formats. Native decoders run with the server account's OS permissions. Use OS isolation for untrusted media or directories writable by an adversary.

See [SECURITY.md](SECURITY.md) for the trust model and vulnerability reporting.

The cache can contain sensitive generated images and transcripts. Keep it private. Whisper model acquisition may require a network connection the first time a model is used. FFmpeg executables and model weights are installed separately.

## Tests

```powershell
.\.venv\Scripts\python.exe -X utf8 -m pip install -r requirements-dev.txt
$env:VIDEO_MCP_CACHE_DIR = '.tmp/test-runtime-cache'
.\.venv\Scripts\python.exe -m pytest
```

Media fixtures are generated locally with FFmpeg. Tests use temporary directories and mock transcription backends where real model inference is unnecessary.

## Limitations

Scene changes are sampled. Audio activity is approximate and does not identify speakers. Transcription and quality analysis depend on source quality, the local model and the available compute. Long jobs may consume significant CPU and disk. The server is designed for a local stdio client.

## Licensing and acknowledgments

The original project code is licensed under the [MIT License](LICENSE). FFmpeg, the Python MCP SDK, OpenAI Whisper, faster-whisper, PyTorch, Pillow, NumPy, psutil and optional DeepFilterNet are separate projects governed by their respective licenses.