Skip to main content

Convert any YouTube video into an AI-queryable MCP server

Project description

๐ŸŽฌ mcptube

Convert any YouTube video into an AI-queryable MCP server.

YouTube URL in โ†’ searchable library โ†’ ask your AI anything about any video.

mcptube extracts transcripts, metadata, and frames from YouTube videos, indexes them into a local vector database, and exposes everything as MCP tools โ€” queryable by Claude, ChatGPT, VS Code Copilot, Cursor, Gemini, and any MCP-compatible client.


โœจ Features

  • Semantic search across video transcripts (single video or entire library)
  • Frame extraction at any timestamp or by natural language query
  • Auto-classification with LLM-generated tags
  • Illustrated reports โ€” single-video or cross-video, markdown or HTML
  • Video discovery โ€” search YouTube by topic, filter and cluster results
  • Cross-video synthesis โ€” themes, agreements, and contradictions across videos
  • Dual interface โ€” full CLI + MCP server
  • Passthrough LLM โ€” MCP tools require zero API keys; the client LLM does the reasoning
  • BYOK โ€” CLI mode supports 100+ LLM providers via LiteLLM
  • Smart video resolver โ€” reference videos by ID, index, or title substring

๐Ÿ“‹ Prerequisites

  • Python 3.12+
  • ffmpeg โ€” required for frame extraction
    # macOS
    brew install ffmpeg
    
    # Ubuntu/Debian
    sudo apt install ffmpeg
    
    # Windows
    winget install ffmpeg
    

๐Ÿš€ Installation

pip install mcptube

From source (development)

git clone https://github.com/0xchamin/mcptube.git
cd mcptube
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

โšก Quick Start

CLI

# Add a video
mcptube add "https://www.youtube.com/watch?v=dQw4w9WgXcQ"

# List your library
mcptube list

# Search across all videos
mcptube search "machine learning basics"

# Extract a frame
mcptube frame 1 120.5

# Start the MCP server
mcptube serve

MCP Server

# Streamable HTTP (default) โ€” works with Claude Code, ChatGPT
mcptube serve

# stdio โ€” works with VS Code, Claude Desktop, Cursor
mcptube serve --stdio

๐Ÿ”ง CLI Commands

Command Description
mcptube add <url> Ingest a YouTube video
mcptube list List all videos in the library
mcptube info <query> Show video details (ID, index, or text)
mcptube remove <query> Remove a video from the library
mcptube search <query> Semantic search across transcripts
mcptube frame <video> <timestamp> Extract a frame at a timestamp
mcptube frame-query <video> <text> Search transcript + extract frame
mcptube classify <video> Auto-classify with LLM tags (BYOK)
mcptube report <video> Generate an illustrated report (BYOK)
mcptube report-query <query> Cross-video report from search (BYOK)
mcptube discover <topic> Search YouTube + cluster results (BYOK)
mcptube synthesize-cmd <topic> -v <id> Cross-video synthesis (BYOK)
mcptube serve Start MCP server (Streamable HTTP)
mcptube serve --stdio Start MCP server (stdio)

Smart Video Resolver

Commands that take a <video> or <query> argument accept:

Input Resolution
BpibZSMGtdY Exact YouTube video ID
1 Index number from mcptube list
"prompting" Substring match on title or channel

Search Options

# Search all videos
mcptube search "attention mechanism"

# Search within a specific video
mcptube search "attention" --video "prompting"

# Limit results
mcptube search "attention" --limit 5

Report Options

# Full report for a video
mcptube report "prompting" --format html --output report.html

# Focused report
mcptube report "prompting" --focus "reasoning strategies" --output focused.html

# Cross-video report from search
mcptube report-query "prompt engineering" --format html --output multi.html

# Cross-video synthesis
mcptube synthesize-cmd "prompting" -v BpibZSMGtdY -v UPGB-hsAoVY --output synthesis.html

๐Ÿค– MCP Tools (13 tools)

All MCP tools use the passthrough pattern โ€” no API key required on the server. The connected AI client (Claude, ChatGPT, Copilot) provides the LLM reasoning.

Tool Description
add_video(url) Ingest a YouTube video
remove_video(video_id) Remove from library
list_videos() List all videos with metadata
get_info(video_id) Full video details with transcript
search(query, video_id?, limit) Semantic search (single or all videos)
search_library(query, tags?, limit) Cross-library search with tag filter
get_frame(video_id, timestamp) Extract frame at timestamp
get_frame_by_query(video_id, query) Search + extract frame
classify_video(video_id) Return metadata for client classification
generate_report(video_id, query?) Return data for client report generation
generate_report_from_query(query, tags?) Cross-video report data
discover_videos(topic) YouTube search results
synthesize(video_ids, topic) Cross-video synthesis data

๐Ÿ”Œ MCP Client Configuration

Claude Code

# Streamable HTTP (recommended)
claude mcp add --transport http --scope global mcptube http://127.0.0.1:9093/mcp

Note: Use --scope global to make mcptube available in all projects. Without it, the server is scoped to the directory where you ran the command.

Then start the server in a separate terminal:

mcptube serve

VS Code / Copilot Chat

Add to .vscode/mcp.json in your workspace:

{
  "servers": {
    "mcptube": {
      "command": "mcptube",
      "args": ["serve", "--stdio"]
    }
  }
}

Note: If VS Code can't find mcptube, use the full path to the executable:

"command": "/path/to/your/.venv/bin/mcptube"

Or if installed globally via pip, the command should work as-is.

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "mcptube": {
      "command": "mcptube",
      "args": ["serve", "--stdio"]
    }
  }
}

Cursor

Add to .cursor/mcp.json:

{
  "mcpServers": {
    "mcptube": {
      "command": "mcptube",
      "args": ["serve", "--stdio"]
    }
  }
}

ChatGPT

Settings โ†’ Connectors โ†’ Add โ†’ http://localhost:9093/mcp

Gemini CLI

Add to settings.json:

{
  "mcpServers": {
    "mcptube": {
      "command": "mcptube",
      "args": ["serve", "--stdio"]
    }
  }
}

๐Ÿ”‘ BYOK โ€” Bring Your Own Key (CLI Mode)

CLI commands that use LLM features (classify, report, discover, synthesize) require an API key via environment variables:

# Anthropic (Claude)
export ANTHROPIC_API_KEY="sk-ant-..."

# OpenAI
export OPENAI_API_KEY="sk-..."

# Google (Gemini)
export GOOGLE_API_KEY="AI..."

mcptube auto-detects which key is available. Set a default model:

export MCPTUBE_DEFAULT_MODEL="anthropic/claude-sonnet-4-20250514"

Security: Never pass API keys as CLI flags. Always use environment variables.

MCP mode does not need any API key โ€” the connected AI client provides the LLM.


โš™๏ธ Configuration

All settings can be overridden via MCPTUBE_-prefixed environment variables:

Variable Default Description
MCPTUBE_DATA_DIR ~/.mcptube Root directory for all data
MCPTUBE_HOST 127.0.0.1 Server bind host
MCPTUBE_PORT 9093 Server bind port
MCPTUBE_DEFAULT_MODEL gpt-4o Default LLM model for CLI

Server Options

mcptube serve                              # Streamable HTTP on 127.0.0.1:9093
mcptube serve --stdio                      # stdio transport
mcptube serve --host 0.0.0.0 --port 8080   # Custom host/port
mcptube serve --reload                     # Dev mode with hot-reload

๐Ÿ—๏ธ Architecture

CLI (Typer)  โ†โ”€โ”€โ”€โ”€โ”€โ”€โ”
                     โ”œโ”€โ”€ Service Layer (McpTubeService)
MCP Server (FastMCP) โ†โ”€โ”˜        โ”‚
                           โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”
                     Repository    VectorStore
                     (SQLite)      (ChromaDB)
                           โ”‚
                     Ingestion Layer
                     โ”œโ”€โ”€ YouTubeExtractor (yt-dlp)
                     โ”œโ”€โ”€ FrameExtractor (yt-dlp + ffmpeg)
                     โ”œโ”€โ”€ LLMClient (LiteLLM โ€” CLI only)
                     โ”œโ”€โ”€ ReportBuilder (CLI only)
                     โ””โ”€โ”€ VideoDiscovery (CLI only)

LLM Strategy

Mode LLM Cost
CLI LiteLLM (BYOK) User's API key
MCP Client LLM (passthrough) Free โ€” client provides reasoning

Storage

Component Per video (~40 min) 100 videos
SQLite (metadata + transcript) ~200-500 KB ~50 MB
ChromaDB (384-dim vectors) ~1.5-2 MB ~200 MB
Total ~250 MB

ChromaDB downloads the all-MiniLM-L6-v2 embedding model (~80 MB) on first use. This is a one-time download cached at ~/.cache/chroma/.


๐Ÿ› ๏ธ Tech Stack

  • FastMCP 3.0 โ€” MCP server framework (Streamable HTTP + stdio)
  • yt-dlp โ€” YouTube extraction (transcripts, metadata, search)
  • ffmpeg โ€” On-demand frame extraction
  • ChromaDB โ€” Local vector database with built-in embeddings
  • LiteLLM โ€” Unified LLM interface (100+ providers)
  • Typer โ€” CLI framework
  • Pydantic โ€” Data models and settings
  • SQLite โ€” Library metadata storage

๐Ÿงช Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run with coverage
pytest --cov=mcptube --cov-report=html

# Lint
ruff check src/

# Format
ruff format src/

๐Ÿ“ฆ Project Structure

mcptube/
โ”œโ”€โ”€ src/mcptube/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ cli.py              # Typer CLI
โ”‚   โ”œโ”€โ”€ server.py           # FastMCP MCP server
โ”‚   โ”œโ”€โ”€ service.py          # Core business logic
โ”‚   โ”œโ”€โ”€ models.py           # Pydantic domain models
โ”‚   โ”œโ”€โ”€ config.py           # Settings (pydantic-settings)
โ”‚   โ”œโ”€โ”€ llm.py              # LiteLLM wrapper (BYOK)
โ”‚   โ”œโ”€โ”€ report.py           # ReportBuilder
โ”‚   โ”œโ”€โ”€ discovery.py        # VideoDiscovery
โ”‚   โ”œโ”€โ”€ ingestion/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ youtube.py      # YouTubeExtractor
โ”‚   โ”‚   โ””โ”€โ”€ frames.py       # FrameExtractor
โ”‚   โ””โ”€โ”€ storage/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ repository.py   # Abstract VideoRepository
โ”‚       โ”œโ”€โ”€ sqlite.py       # SQLiteVideoRepository
โ”‚       โ””โ”€โ”€ vectorstore.py  # VectorStore + ChromaVectorStore
โ”œโ”€โ”€ tests/
โ”œโ”€โ”€ pyproject.toml
โ””โ”€โ”€ README.md

๐Ÿ—บ๏ธ Roadmap

  • MVP โ€” 13 MCP tools, CLI, semantic search, frames, reports
  • MCP Apps โ€” Interactive HTML UIs inline in chat
  • Playlist / channel import
  • Speaker diarization
  • OCR on frames
  • Auto-chaptering
  • Multi-language transcripts
  • SaaS tier (OAuth, pgvector, team libraries)

๐Ÿ“„ License

MIT


Built with FastMCP โšก

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcptube-0.1.1.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcptube-0.1.1-py3-none-any.whl (33.6 kB view details)

Uploaded Python 3

File details

Details for the file mcptube-0.1.1.tar.gz.

File metadata

  • Download URL: mcptube-0.1.1.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for mcptube-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7e159b21de164faa753fb2dff9cedc0ae96ab4b627a7f5b02fa131bf1445bb9a
MD5 888bb69c14246b847d79bdc167ef28cf
BLAKE2b-256 ad083295ce9895a72b8e4f1d7be9e3d3694325077a0a1d38037a6277eba54850

See more details on using hashes here.

File details

Details for the file mcptube-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mcptube-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 33.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for mcptube-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0b3eca26d6f11d629ad4a0992f9a356ab7fd41655cb2eb6a5c49bac3bab5b136
MD5 88b41a5f4422bc81cfe578ee04ca12ec
BLAKE2b-256 1dcdd136c962c0760fdba12ebf2a601728176cf60c502e7ea88698a3dae4d4fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page