yt-mcp
yt-mcp
Un servidor MCP (Model Context Protocol) totalmente local que proporciona a los asistentes de IA una conciencia profunda y multimodal de los vídeos de YouTube. No requiere claves API. Todo el procesamiento se ejecuta en el dispositivo mediante yt-dlp, OpenAI Whisper, FFmpeg, PySceneDetect y librosa.
Nota: Este repositorio también contiene un servidor experimental en TypeScript (
src/) que utiliza la API de Gemini. Ese servidor no está bajo desarrollo activo; el servidor local en Python (server/) es la implementación principal.
Tabla de contenidos
Related MCP server: YT-NINJA
Cómo funciona
YouTube URL
│
▼
yt-dlp ──────────────── download video.mp4
│ extract audio.wav (16 kHz mono)
▼
Whisper ─────────────── timestamped transcript (word-level)
│
▼
PySceneDetect ────────── detect scene-cut timestamps
│
▼
FFmpeg ──────────────── extract keyframe JPEGs at scene cuts
│
▼
OpenCV ──────────────── pixel-diff animation detection
│
▼
librosa ─────────────── energy · tempo · music vs speech
│
▼
timeline.py ─────────── unified JSON timeline (all signals, time-aligned)Todos los resultados se almacenan en caché en /tmp/yt-analysis-cache/<video_id>/. Volver a llamar a la misma URL es instantáneo.
Requisitos previos
# macOS
brew install ffmpeg
# Ubuntu / Debian
sudo apt install ffmpeg
# Verify
ffmpeg -version
python3 --version # must be 3.10+Instalación
git clone https://github.com/yourusername/yt-mcp.git
cd yt-mcp
# Create and activate a virtual environment (recommended)
python3 -m venv .venv
source .venv/bin/activate # macOS / Linux
# .venv\Scripts\activate # Windows
pip install -r requirements.txtLos pesos del modelo Whisper se descargan automáticamente en la primera llamada de transcripción (~75 MB para base, ~1.5 GB para large).
Integración con MCP
Los clientes MCP inician el servidor como un subproceso; no activan su shell o venv automáticamente. Debe apuntar directamente al intérprete de Python del venv utilizando su ruta absoluta.
Encuentre la ruta de su intérprete después de activar el venv:
source .venv/bin/activate
which python # e.g. /Users/you/repos/yt-mcp/.venv/bin/pythonClaude Code:
claude mcp add -s user yt-mcp -- /path/to/yt-mcp/.venv/bin/python /path/to/yt-mcp/server/main.pyClaude Desktop — añádalo a ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"yt-mcp": {
"command": "/path/to/yt-mcp/.venv/bin/python",
"args": ["/path/to/yt-mcp/server/main.py"]
}
}
}Reemplace
/path/to/yt-mcpcon la ruta absoluta a donde clonó el repositorio. En Windows, el intérprete se encuentra en.venv\Scripts\python.exe.
Herramientas
get_video_transcript
Transcribe un vídeo de YouTube utilizando OpenAI Whisper (se ejecuta completamente de forma local).
Parámetro | Tipo | Predeterminado | Descripción |
| string | — | URL completa de YouTube |
| string |
|
|
Respuesta:
{
"title": "Video Title",
"duration": 847,
"language": "en",
"full_text": "Welcome to this video...",
"segments": [
{
"t_start": 0.0,
"t_end": 4.5,
"text": "Welcome to this video.",
"words": [{ "word": "Welcome", "start": 0.0, "end": 0.6 }]
}
]
}get_video_frames
Extrae fotogramas clave como JPEGs codificados en base64. Utiliza PySceneDetect para la detección de escenas y FFmpeg para la extracción.
Parámetro | Tipo | Predeterminado | Descripción |
| string | — | URL completa de YouTube |
| string |
|
|
| integer |
| Segundos entre fotogramas (para estrategias |
Respuesta:
{
"title": "Video Title",
"duration": 847,
"duration_formatted": "14:07",
"frame_count": 12,
"strategy": "scene",
"frames": [
{
"t": 0.0,
"t_formatted": "0:00",
"keyframe": "<base64 JPEG>",
"scene_change": false,
"animation_detected": false
}
],
"summary": [ /* same list without keyframe bytes — for quick review */ ]
}get_audio_features
Analiza las características del audio utilizando librosa (se ejecuta localmente).
Parámetro | Tipo | Predeterminado | Descripción |
| string | — | URL completa de YouTube |
| integer |
| Tamaño de la ventana de análisis en segundos |
Respuesta:
{
"title": "Video Title",
"duration": 847,
"segment_duration": 30,
"segments": [
{
"t_start": 0.0,
"t_end": 30.0,
"energy": "medium",
"music": false,
"tempo_bpm": 95.0,
"rms_db": -22.1
}
]
}get_full_context
Herramienta principal. Devuelve una línea de tiempo multimodal completa y sincronizada: transcripción + límites de escena + detección de animación + características de audio, todo alineado temporalmente.
Parámetro | Tipo | Predeterminado | Descripción |
| string | — | URL completa de YouTube |
| boolean |
| Incrustar fotogramas clave en base64 por segmento |
| string |
| Tamaño del modelo Whisper |
Respuesta:
{
"title": "How Transformers Work",
"channel": "AI Explained",
"duration": 847,
"duration_formatted": "14:07",
"language": "en",
"description": "In this video...",
"segments": [
{
"t_start": 0.0,
"t_end": 12.0,
"transcript": "Welcome to this video on transformers...",
"keyframe": null,
"scene_change": false,
"animation_detected": false,
"audio": {
"energy": "low",
"speech_rate": "normal",
"music": true,
"tempo_bpm": 0.0,
"rms_db": -28.4
}
}
]
}Consejo sobre la ventana de contexto: Llame primero a
get_full_contextconinclude_frames=falsepara comprender la estructura del vídeo y, a continuación, llame aget_video_framespara obtener marcas de tiempo específicas de interés.
Formatos de URL admitidos
https://www.youtube.com/watch?v=VIDEO_ID
https://youtu.be/VIDEO_ID
https://youtube.com/shorts/VIDEO_IDVariables de entorno
Variable | Predeterminado | Descripción |
|
| Directorio de caché para vídeos y audios descargados |
Desarrollo
# Activate the venv first
source .venv/bin/activate
# Run the server directly (stdio mode — same as MCP clients use)
python server/main.py
# Quick smoke test
python -c "
from server.utils.downloader import VideoDownloader
from server.tools.transcript import get_transcript
d = VideoDownloader()
vp, ap, info = d.download('https://www.youtube.com/watch?v=jNQXAC9IVRw')
print(get_transcript(ap)['language'])
"Pruebas
El servidor de Python tiene un conjunto completo de pruebas unitarias: 164 pruebas en 6 módulos. Todas las pruebas se ejecutan sin acceso a la red ni descargas de modelos; cada dependencia externa (Whisper, librosa, FFmpeg, PySceneDetect, OpenCV, yt-dlp) está simulada (mocked).
Instalar dependencias de prueba
pip install -r requirements-dev.txtEjecutar el conjunto completo
python -m pytestSalida esperada: 164 passed in ~4s
Ejecutar pruebas para un módulo específico
python -m pytest tests/test_downloader.py # VideoDownloader + VideoInfo
python -m pytest tests/test_transcript.py # Whisper wrapper + range helpers
python -m pytest tests/test_frames.py # FFmpeg, PySceneDetect, OpenCV
python -m pytest tests/test_audio.py # librosa AudioAnalyzer
python -m pytest tests/test_timeline.py # build_timeline + speech rate
python -m pytest tests/test_main.py # all 4 MCP tool handlersEjecutar una sola prueba por nombre
python -m pytest tests/test_timeline.py::TestBuildTimeline::test_rapid_cuts_below_min_merged -vPrueba de humo en vivo con un vídeo real
El siguiente ejemplo utiliza プリマドンナ / 星街すいせい (Hoshimachi Suisei · Suisei Channel, 2:52), un vídeo musical japonés que ejercita cada capa de la canalización: transcripción multilingüe de Whisper, detección de música mediante HPSS de librosa, cortes rápidos de escena mediante PySceneDetect y detección de animación mediante diferencia de píxeles de OpenCV.
from server.utils.downloader import VideoDownloader
from server.tools.transcript import get_transcript
from server.tools.audio import AudioAnalyzer
from server.tools.frames import detect_scene_timestamps
URL = "https://www.youtube.com/watch?v=M1GYqy0tHV0"
d = VideoDownloader()
video_path, audio_path, info = d.download(URL)
print(f"Title: {info.title}") # プリマドンナ / 星街すいせい(official)
print(f"Duration: {info.duration:.0f}s") # 172
transcript = get_transcript(audio_path, model_size="base")
print(f"Language: {transcript['language']}") # ja
cuts = detect_scene_timestamps(video_path)
print(f"Scene cuts detected: {len(cuts)}") # typically 30–60 for a music video
analyzer = AudioAnalyzer(audio_path)
seg = analyzer.analyze_segment(0, 30)
print(f"First 30s — energy: {seg['energy']}, music: {seg['music']}")
# energy: 'medium' or 'high', music: TruePara obtener la guía completa de pruebas (fixtures, patrones de mock, escritura de pruebas para nuevas herramientas), consulte docs/testing.md.
Arquitectura
Para obtener una explicación detallada del diseño del sistema, los flujos de datos y cómo añadir nuevas herramientas:
docs/architecture.md — diagramas de canalización y decisiones clave de diseño
docs/python-server.md — referencia de componentes para todos los módulos
docs/extending.md — cómo añadir nuevas herramientas
docs/testing.md — estructura del conjunto de pruebas, fixtures y escritura de nuevas pruebas
Servidor TypeScript (archivado)
El directorio src/ contiene un servidor experimental en TypeScript que delega el análisis de vídeo a la API de Gemini. No está bajo desarrollo activo y se mantiene solo como referencia.
Si busca preguntas y respuestas de vídeo rápidas basadas en la nube, el enfoque del servidor TypeScript (pasar la URL de YouTube directamente a Gemini) funciona bien para un prototipo rápido, pero el servidor de Python es la única implementación que recibirá mantenimiento continuo.
Consulte docs/typescript-server.md para ver su referencia de API.
Licencia
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseCqualityDmaintenanceBridges YouTube API and AI assistants, enabling video analysis by downloading and processing closed captions to create summaries of YouTube videos.120MIT
- FlicenseBqualityDmaintenanceEnables AI-powered YouTube video analysis including transcript management, video summaries, chapter generation, keyword extraction, and playback control. Supports searching videos, retrieving channel/playlist information, and translating transcripts using Google Gemini AI.14
- FlicenseAqualityCmaintenanceEnables analysis of YouTube videos using the Gemini API to generate summaries and answer specific questions via direct URLs. It supports standard videos and shorts, allowing users to interact with video content without requiring manual downloads.54
- AlicenseBqualityDmaintenanceEnables conversational analysis of YouTube videos using Gemini 2.5 Pro, supporting multi-turn sessions, direct URL processing, and local video uploads.101MIT
Related MCP Connectors
AI-powered YouTube to flashcards with spaced repetition and Anki export
Provide token-optimized, structured YouTube data to enhance your LLM applications. Access efficien…
Multimodal video analysis MCP — transcription, vision, and OCR for any video URL.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/PakmanGames/yt-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server