Skip to main content
Glama

YouTube MCP (youtube_mcp)

PyPI version Python 3.13+ License: MIT

A Model Context Protocol (MCP) server that provides production-grade YouTube inventory tools (channel resolution, channel videos, channel playlists, playlist videos) designed to be safe-by-default, quota-aware, and AI-friendly.

Repository: https://github.com/glonorce/youtube_mcp PyPI: https://pypi.org/project/glonorce-youtube-mcp/

Naming note:

  • Repo name: youtube_mcp

  • Python package / import name: youtube_mcp

  • MCP entry module: python -m youtube_mcp.server


Prerequisites (PATH)

Make sure these commands work in your terminal (they must be on PATH):

  • python --version

  • python -m pip --version

  • pipx --version (only if you use the pipx-based MCP config)

PATH is the list of folders that your OS searches when you run a command like python or pipx.

  • If a command is not on PATH, you'll see errors like:

    • Windows: executable file not found in %PATH%

    • PowerShell: ... is not recognized as the name of a cmdlet

Quick checks (Windows):

where python
where pipx
$env:Path

On Windows:

Install pipx (only if you use the pipx-based MCP config):

python -m pip install --user pipx
python -m pipx ensurepath

Notes:

  • After pipx ensurepath, restart your terminal/IDE so pipx is available on PATH.

  • Verify with: pipx --version


Related MCP server: YouTube MCP Server

✨ Available on PyPI

pip install glonorce-youtube-mcp

# run
youtube_mcp

Screenshots


Features

  • 7 MCP tools (1 text-output tool + 6 structured-output tools)

  • Safe defaults (public data only; shorts/live excluded unless enabled)

  • Quota-aware design (budgeting + expensive strategies as explicit opt-in)

  • Tool discovery works in MCP hosts (tools registered with rich docstrings)

  • Resilient YouTube Data API client (endpoint allowlist, retries, gzip handling)


Tools

This server exposes 7 tools:

  1. get_yt_video_info(video_id_or_url) -> str

    • Accepts a raw video id or a full YouTube URL.

    • Returns video metadata + transcript (when available).

  2. resolve_youtube_channel(channel_ref, ...) -> dict

  3. list_youtube_channel_videos(channel_ref, ...) -> dict

    • Paginated.

    • Returns nextPageToken and next_page_token (alias).

  4. list_youtube_channel_playlists(channel_ref, ...) -> dict

    • Paginated.

    • Returns nextPageToken and next_page_token (alias).

  5. list_youtube_playlist_videos(playlist_id, ...) -> dict

    • Paginated.

    • Returns nextPageToken and next_page_token (alias).

  6. search_youtube_channel_videos(channel_ref, query, ...) -> dict

    • Keyword search within a channel (quota-expensive, uses Search API).

    • Paginated.

  7. list_youtube_video_comments(video_id, ...) -> dict

    • Public comment threads for a video (comments may be disabled).

    • Paginated.

All tools except get_yt_video_info return structured JSON and are documented with AI-friendly docstrings.


Installation & MCP configuration

PyPI distribution name: glonorce-youtube-mcp

Repo name: youtube_mcp · import name: youtube_mcp

API key

All inventory/search/comment tools require a YouTube Data API v3 key:

  • YOUTUBE_API_KEY

Use this when you want a "zero local project" setup (no clone, no venv management).

{
  "mcpServers": {
    "youtube_mcp": {
      "command": "pipx",
      "args": ["run", "--spec", "glonorce-youtube-mcp", "youtube_mcp"],
      "env": {
        "YOUTUBE_API_KEY": "YOUR_KEY"
      }
    }
  }
}

Option 2: pip into a dedicated venv (no repo clone)

python -m venv .venv_youtube_mcp
# Windows: .venv_youtube_mcp\Scripts\activate
# macOS/Linux: source .venv_youtube_mcp/bin/activate

python -m pip install -U pip
python -m pip install glonorce-youtube-mcp

MCP host JSON example (simple):

{
  "mcpServers": {
    "youtube_mcp": {
      "command": "youtube_mcp",
      "env": {
        "YOUTUBE_API_KEY": "YOUR_KEY"
      }
    }
  }
}

If your MCP host can't find youtube_mcp on PATH (Windows error like: executable file not found in %PATH%), use an absolute path.

MCP host JSON example (absolute path to venv Python + module):

{
  "mcpServers": {
    "youtube_mcp": {
      "command": "C:\\PATH\\.venv_youtube_mcp\\Scripts\\python.exe",
      "args": ["-m", "youtube_mcp.server"],
      "env": {
        "YOUTUBE_API_KEY": "YOUR_KEY"
      }
    }
  }
}

Option 3: local clone (development)

git clone https://github.com/glonorce/youtube_mcp.git
cd youtube_mcp

python -m venv .venv
# Windows: .venv\Scripts\activate
# macOS/Linux: source .venv/bin/activate

python -m pip install -e .

MCP host JSON example (local clone):

{
  "mcpServers": {
    "youtube_mcp": {
      "command": "C:\\PATH\\youtube_mcp\\.venv\\Scripts\\python.exe",
      "args": ["-m", "youtube_mcp.server"],
      "env": {
        "YOUTUBE_API_KEY": "YOUR_KEY"
      }
    }
  }
}

Getting Your YouTube API Key

While not required, you can optionally set up a YouTube Data API key for enhanced functionality. Here's how to get one:

Step 1: Create a Google Cloud Project

  1. Go to the Google Cloud Console

  2. Click "Select a project" at the top of the page

  3. Click "New Project" and give it a name (e.g., "MCP YouTube Extract")

  4. Click "Create"

Step 2: Enable the YouTube Data API

  1. In your new project, go to the API Library

  2. Search for "YouTube Data API v3"

  3. Click on it and then click "Enable"

Step 3: Create API Credentials

  1. Go to the Credentials page

  2. Click "Create Credentials" and select "API Key"

  3. Your new API key will be displayed - copy it immediately

  4. Click "Restrict Key" to secure it (recommended)

  1. In the API key settings, click "Restrict Key"

  2. Under "API restrictions", select "Restrict key"

  3. Choose "YouTube Data API v3" from the dropdown

  4. Click "Save"

Step 5: Set Up Billing (May be required)

  1. Go to the Billing page

  2. Link a billing account to your project

  3. Note: YouTube Data API has a free tier of ~10,000 units per day, which is typically sufficient for most use cases

API Key Usage Limits

  • Free Tier: ~10,000 units per day (commonly)

  • Cost: depends on your Google Cloud / billing configuration

Security Best Practices

  • Never commit your API key to version control

  • Use environment variables as shown in the MCP configuration section

  • Restrict your API key to only the YouTube Data API

  • Monitor usage in the Google Cloud Console


Example MCP calls (JSON payloads)

Exact envelope depends on your MCP client; these show tool + arguments.

Resolve a channel

{
  "tool": "resolve_youtube_channel",
  "arguments": {
    "channel_ref": "@GoogleDevelopers",
    "resolution_mode": "strict",
    "include_uploads_playlist": true
  }
}

List channel videos (safe default)

{
  "tool": "list_youtube_channel_videos",
  "arguments": {
    "channel_ref": "@GoogleDevelopers",
    "max_videos": 50,
    "page_token": null,
    "include_shorts": false,
    "include_live": false,
    "parts_level": "basic",
    "order_strategy": "uploads_playlist",
    "order_by": "date"
  }
}

Quota reference (best-effort)

This section is a best-effort summary and may change over time. Always verify with official documentation.

Last verified: 2026-02-18

Official references:

Approximate quota usage by tool

Note: get_yt_video_info returns text (not structured JSON) and is not included in the quota table because its behavior depends on optional extractors.

Tool

Primary endpoints

Typical cost (rough)

Notes

resolve_youtube_channel

channels.list

~1

strict mode mostly channels.list; best_effort may use search.list

list_youtube_channel_videos (default)

channels.list + playlistItems.list + videos.list

~ (1 + 1 + 1) per page

uploads-playlist strategy

list_youtube_channel_videos (order_strategy=search_api)

search.list + videos.list

~ (100 + 1) per page

expensive; capped behavior

list_youtube_channel_playlists

playlists.list

~1 per page

public playlists only

list_youtube_playlist_videos

playlistItems.list + videos.list

~ (1 + 1) per page

public playlist

search_youtube_channel_videos

search.list + videos.list

~ (100 + 1) per page

keyword search within a channel

list_youtube_video_comments

commentThreads.list

~1 per page

comments may be disabled (403)

Daily quota:

  • Common free quota: 10,000 units/day

  • Reset: daily (Google-defined; see official docs/console)


Testing

Use the venv interpreter to avoid accidentally running global pytest.

# recommended
python -m pytest -q

# if you use a venv
.venv\Scripts\python.exe -m pytest -q

Troubleshooting

Only get_yt_video_info is visible (other tools missing)

Your MCP host is running an old installed copy from site-packages. Fix:

python -m pip install -e .

Then restart the MCP host.

YOUTUBE_API_KEY placeholder is not expanded in some MCP hosts

Some MCP hosts do not interpolate placeholders like ${YOUTUBE_API_KEY} inside mcp.json.

❌ Not recommended (may be taken literally):

{
  "env": { "YOUTUBE_API_KEY": "${YOUTUBE_API_KEY}" }
}

✅ Recommended (explicit value in config):

{
  "env": { "YOUTUBE_API_KEY": "YOUR_REAL_KEY_HERE" }
}

✅ Also works (set it in the host process environment, then reference nothing in JSON):

  • set YOUTUBE_API_KEY in the MCP host environment (OS/IDE)

  • then keep mcp.json without placeholders


License

MIT — see LICENSE


Acknowledgements

This project was originally derived from / inspired by https://github.com/sinjab/mcp_youtube_extract. The codebase has since been heavily rewritten and extended.

Available Tools

7 tools
get_yt_video_infoA

Fetch YouTube video information and transcript.

Tip: You can pass either a raw video id (11 chars) or a full YouTube URL.

Inputs: video_id (required). Returns: result

list_youtube_channel_playlistsA

List public playlists for a channel.

Parameters: channel_ref: Same formats as resolve_youtube_channel. page_token: Token for pagination.

Returns: - items: playlist[] (YouTube API playlist resources) - nextPageToken: string | null - quotaEstimate: {estimatedUnits,strategy,notes[]}

Notes: - Public playlists only. - This tool does not list "private" playlists.

Inputs: channel_ref (required), page_token, next_page_token. Returns: object

list_youtube_channel_videosA

List videos for a channel (public data), with safe defaults.

Default behavior (safe + complete): - Uses the channel's uploads playlist (uploadsPlaylistId) to paginate through all uploaded videos.

Parameters: channel_ref: Same formats as resolve_youtube_channel. max_videos: Hard limit per tool call. The tool may return fewer items and set truncated=true. page_token: Token for pagination (from previous response nextPageToken). Alias: you may also pass next_page_token (some agents prefer it). include_shorts: Default false. If true, includes Shorts (best-effort classification). include_live: Default false. If true, includes live/upcoming videos (best-effort). parts_level: - basic (default): snippet + statistics + contentDetails - full: also requests status/liveStreamingDetails (heavier payload) order_strategy: - uploads_playlist (default): low quota, paginated. - local_sort: fetches a bounded subset then sorts locally. (Not paginated; page_token must be null.) - search_api: uses YouTube Search API ordering (expensive, capped). Explicit opt-in only. order_by: - date (default) - viewCount, likeCount, commentCount, duration Note: search_api supports only date and viewCount.

Returns (structured JSON): - items: video[] (YouTube API video resources) - nextPageToken: string | null - next_page_token: string | null (alias of nextPageToken for agent friendliness) - quotaEstimate: {estimatedUnits,strategy,notes[]} - truncated: bool - appliedMaxVideos: int - appliedOrder: {strategy, by}

Quota/performance notes: - Search API calls are expensive (quota ~100/unit per call) and may be capped for channels. - local_sort is bounded by max_videos and max_pages.

Safety notes: - Public data only; no private playlists/videos. - No file/network access except YouTube Data API endpoints.

Inputs: channel_ref (required), order_by, max_videos, page_token, +5 more. Returns: object

list_youtube_playlist_videosA

List videos in a playlist (public data).

Parameters: playlist_id: YouTube playlist ID (e.g. PL...). page_token: Token for pagination. max_items: Max number of items to include from this page. include_shorts/include_live: Default false; best-effort classification. parts_level: basic/full (same meaning as channel videos).

Returns: - items: video[] - nextPageToken: string | null - quotaEstimate: {estimatedUnits,strategy,notes[]}

Notes: - Playlist ordering is YouTube's playlist ordering.

Inputs: playlist_id (required), max_items, page_token, parts_level, +3 more. Returns: object

list_youtube_video_commentsA

List comment threads for a YouTube video (public comments).

Notes: - Uses commentThreads.list (quota cost ~1 per page). - max_threads is capped to 100 by the API.

Pagination: - Response returns nextPageToken and next_page_token. - Pass it back as page_token (or next_page_token) to fetch the next page.

Returns: - items: commentThread[] (includes top-level comment; replies optional) - nextPageToken / next_page_token - quotaEstimate

Common failure: - If comments are disabled, YouTube may return 403 (commentsDisabled).

Inputs: video_id (required), order, page_token, max_threads, +3 more. Returns: object

resolve_youtube_channelA

Resolve a YouTube channel reference into a concrete channelId.

What this tool does: - Converts a user-facing channel identifier into a YouTube channelId. - Optionally returns the channel's uploadsPlaylistId, which enables listing all uploaded videos via playlistItems.list.

Supported input formats (examples): - Handle: @GoogleDevelopers - Handle URL: https://www.youtube.com/@GoogleDevelopers - Channel ID URL: https://www.youtube.com/channel/UC... - Legacy username URL: https://www.youtube.com/user/SomeUsername

Parameters: channel_ref: Channel identifier in one of the supported formats. resolution_mode: - strict (default): ambiguous inputs are rejected with an explainable error. This prevents "silent wrong channel" bugs. - best_effort: ambiguous inputs return a short list of candidate channels. (This mode may use the Search API and can be expensive.) include_uploads_playlist: If true, attempts to include uploadsPlaylistId in the output.

Returns (structured JSON): - channelId: string | null - title: string | null - handle: string | null - uploadsPlaylistId: string | null - warnings: string[] - candidates: {channelId,title,handle}[]

Failure modes: - Missing API key: raises error "YOUTUBE_API_KEY not configured". - Ambiguous/unsupported input (strict): raises ValueError with guidance.

Safety notes: - Does not perform destructive actions. - Does not access private channel data.

Inputs: channel_ref (required), resolution_mode, include_uploads_playlist. Returns: object

search_youtube_channel_videosA

Search for videos within a channel by keyword (public data).

When to use: Use this tool when you want to find videos by keyword without enumerating the full uploads playlist.

Important: - This tool uses the YouTube Search API (search.list). - Search is quota-expensive (about 100 units per page). - Results may be capped by YouTube API behavior for channel searches.

Pagination: - Read nextPageToken (or next_page_token) from the response. - Pass it back as page_token (or next_page_token) to fetch the next page.

Returns: - items: hydrated video resources (videos.list) - nextPageToken / next_page_token - quotaEstimate

Inputs: query (required), channel_ref (required), order, max_videos, +5 more. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool targets a distinct resource or operation: video info, channel playlists, channel videos, playlist videos, video comments, channel resolution, and keyword search. While list_youtube_channel_videos and search_youtube_channel_videos both deal with channel videos, one is for listing all uploads and the other for keyword search, making them clearly separable.

    Naming Consistency4/5

    Most tools follow a 'verb_youtube_noun' pattern (e.g., list_youtube_channel_playlists, list_youtube_video_comments). However, 'get_yt_video_info' uses the abbreviation 'yt' instead of 'youtube', breaking the pattern. This is a minor inconsistency.

    Tool Count5/5

    With 7 tools covering core read operations for YouTube data, the count feels well-scoped. Each tool earns its place, providing a focused but sufficient interface for common tasks like fetching video info, listing playlists/videos, retrieving comments, resolving channels, and searching.

    Completeness4/5

    The tool set covers the main read operations: video info, channel playlists, channel videos, playlist videos, video comments, channel resolution, and keyword search. Missing are direct playlist metadata retrieval and detailed channel statistics, but for a read-only interface these are minor gaps.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Transforms YouTube into a queryable knowledge source with search, video details, transcript analysis, and AI-powered tools for summaries, learning paths, and knowledge graphs. Features quota-aware API access with caching and optional OpenAI/Anthropic integration for advanced content analysis.
      10
      41 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to search videos, read channels, browse playlists, fetch comments, and get transcripts from YouTube using the YouTube Data API v3 and InnerTube API for captions.
      2
      GPL 3.0

    Appeared in Searches