Skip to main content
Glama

yt-mcp

AI 어시스턴트에게 YouTube 동영상에 대한 깊이 있는 멀티모달 인식 기능을 제공하는 완전 로컬 MCP(Model Context Protocol) 서버입니다. API 키가 필요하지 않습니다. 모든 처리는 yt-dlp, OpenAI Whisper, FFmpeg, PySceneDetect 및 librosa를 통해 기기 내에서 실행됩니다.

참고: 이 저장소에는 Gemini API를 사용하는 실험적인 TypeScript 서버(src/)도 포함되어 있습니다. 해당 서버는 현재 활발히 개발 중이 아니며, Python 로컬 서버(server/)가 주요 구현체입니다.


목차


Related MCP server: YT-NINJA

작동 원리

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)

모든 결과는 /tmp/yt-analysis-cache/<video_id>/에 캐시됩니다. 동일한 URL을 다시 호출하면 즉시 결과가 반환됩니다.


사전 요구 사항

# macOS
brew install ffmpeg

# Ubuntu / Debian
sudo apt install ffmpeg

# Verify
ffmpeg -version
python3 --version   # must be 3.10+

설치

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.txt

Whisper 모델 가중치는 첫 번째 전사 호출 시 자동으로 다운로드됩니다(base의 경우 약 75MB, large의 경우 약 1.5GB).


MCP 통합

MCP 클라이언트는 서버를 하위 프로세스로 생성하며, 셸이나 venv를 자동으로 활성화하지 않습니다. venv의 Python 인터프리터를 절대 경로를 사용하여 직접 지정해야 합니다.

venv를 활성화한 후 인터프리터 경로를 찾으세요:

source .venv/bin/activate
which python   # e.g. /Users/you/repos/yt-mcp/.venv/bin/python

Claude Code:

claude mcp add -s user yt-mcp -- /path/to/yt-mcp/.venv/bin/python /path/to/yt-mcp/server/main.py

Claude Desktop~/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"]
    }
  }
}

/path/to/yt-mcp를 저장소를 복제한 절대 경로로 바꾸세요. Windows의 경우 인터프리터는 .venv\Scripts\python.exe에 있습니다.


도구

get_video_transcript

OpenAI Whisper를 사용하여 YouTube 동영상을 전사합니다(완전히 로컬에서 실행).

매개변수

유형

기본값

설명

youtube_url

string

전체 YouTube URL

model_size

string

base

tiny · base · small · medium · large

응답:

{
  "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

키프레임을 base64로 인코딩된 JPEG로 추출합니다. 장면 감지를 위해 PySceneDetect를, 추출을 위해 FFmpeg를 사용합니다.

매개변수

유형

기본값

설명

youtube_url

string

전체 YouTube URL

strategy

string

scene

scene · interval · both

interval

integer

30

프레임 간 간격(초) (interval 또는 both 전략의 경우)

응답:

{
  "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

librosa를 사용하여 오디오 특성을 분석합니다(로컬에서 실행).

매개변수

유형

기본값

설명

youtube_url

string

전체 YouTube URL

segment_duration

integer

30

분석 창 크기(초)

응답:

{
  "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

주요 도구. 전사 + 장면 경계 + 애니메이션 감지 + 오디오 특성이 모두 시간 동기화된 완전한 멀티모달 타임라인을 반환합니다.

매개변수

유형

기본값

설명

youtube_url

string

전체 YouTube URL

include_frames

boolean

false

세그먼트별 base64 키프레임 포함 여부

model_size

string

base

Whisper 모델 크기

응답:

{
  "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
      }
    }
  ]
}

컨텍스트 윈도우 팁: 먼저 include_frames=falseget_full_context를 호출하여 동영상 구조를 파악한 다음, 관심 있는 특정 타임스탬프에 대해 get_video_frames를 호출하세요.


지원되는 URL 형식

https://www.youtube.com/watch?v=VIDEO_ID
https://youtu.be/VIDEO_ID
https://youtube.com/shorts/VIDEO_ID

환경 변수

변수

기본값

설명

YT_CACHE_DIR

/tmp/yt-analysis-cache

다운로드된 동영상 및 오디오를 위한 캐시 디렉터리


개발

# 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'])
"

테스트

Python 서버에는 6개 모듈에 걸쳐 164개의 테스트로 구성된 전체 단위 테스트 제품군이 있습니다. 모든 테스트는 네트워크 액세스나 모델 다운로드 없이 실행되며, 모든 외부 종속성(Whisper, librosa, FFmpeg, PySceneDetect, OpenCV, yt-dlp)은 모의 객체(mock)로 처리됩니다.

테스트 종속성 설치

pip install -r requirements-dev.txt

전체 제품군 실행

python -m pytest

예상 출력: 164 passed in ~4s

특정 모듈에 대한 테스트 실행

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 handlers

이름으로 단일 테스트 실행

python -m pytest tests/test_timeline.py::TestBuildTimeline::test_rapid_cuts_below_min_merged -v

실제 동영상을 사용한 라이브 스모크 테스트

아래 예시는 プリマドンナ / 星街すいせい(호시마치 스이세이 · Suisei Channel, 2:52)를 사용합니다. 이는 다국어 Whisper 전사, librosa HPSS를 통한 음악 감지, PySceneDetect를 통한 빠른 장면 전환, 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: True

전체 테스트 가이드(픽스처, 모의 패턴, 새 도구 테스트 작성 방법)는 docs/testing.md를 참조하세요.


아키텍처

시스템 설계, 데이터 흐름 및 새 도구 추가 방법에 대한 자세한 설명은 다음을 참조하세요:


TypeScript 서버 (보관됨)

src/ 디렉터리에는 동영상 분석을 Gemini API에 위임하는 실험적인 TypeScript 서버가 포함되어 있습니다. 이 서버는 현재 활발히 개발 중이 아니며 참조용으로만 유지됩니다.

빠른 클라우드 기반 동영상 Q&A를 찾고 있다면, TypeScript 서버의 접근 방식(YouTube URL을 Gemini에 직접 전달)이 빠른 프로토타입에는 효과적이지만, 지속적인 유지 관리가 이루어지는 구현체는 Python 서버뿐입니다.

API 참조는 docs/typescript-server.md를 참조하세요.


라이선스

MIT

Install Server
A
license - permissive license
A
quality
B
maintenance

Maintenance

Maintainers
41dResponse time
Release cycle
Releases (12mo)
Commit activity

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

  • F
    license
    B
    quality
    D
    maintenance
    Enables 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
  • F
    license
    A
    quality
    C
    maintenance
    Enables 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.
    5
    4

View all related MCP servers

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.

View all MCP Connectors

Latest Blog Posts

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