Skip to main content

YouTube MCP

中文文档

YouTube MCP is a Model Context Protocol server for extracting video-platform metadata and context from YouTube and BiliBili. It is designed for Claude, Cursor, VS Code, and other MCP-compatible agents that need searchable video context, subtitles, comments, playlists, streams, danmaku, and live-room metadata.

The server runs locally over stdio and does not require a browser extension or a hosted backend.

Features

  • Search videos, channels, playlists, anime/PGC entries, and BiliBili media results.
  • Resolve arbitrary supported URLs or IDs with detect_url and resolve_url.
  • Extract video metadata, thumbnails, playability status, related items, tags, and available stream URLs or manifests.
  • Fetch subtitles and convert them to raw, json, text, srt, or vtt.
  • Fetch YouTube comments and BiliBili comments.
  • Fetch BiliBili danmaku for regular videos and PGC episodes.
  • Fetch YouTube playlists, BiliBili favorites, BiliBili collections, and BiliBili PGC season lists.
  • Fetch YouTube channel and BiliBili uploader metadata with recent videos.
  • Fetch YouTube live-video metadata and BiliBili live-room stream information.
  • Fetch YouTube SponsorBlock skip segments.
  • Expose MCP tools, resources, and prompt templates.

Supported Inputs

Platform Supported IDs and URLs
YouTube watch URLs, youtu.be URLs, shorts URLs, live URLs, video IDs, playlist IDs/URLs, channel IDs, handles, channel URLs
BiliBili BV IDs, AV IDs, video URLs, ep IDs/URLs, ss IDs/URLs, favorite ml IDs/URLs, space collection URLs, live room IDs/URLs

Limitations

  • The project does not bypass paid content, DRM, private videos, region restrictions, age gates, or account permissions.
  • If you provide cookies through environment variables, the server can parse content that the underlying platform API returns for that account.
  • YouTube danmaku-style comments are not supported.
  • BiliBili subtitle translation is not supported.
  • Network-facing platform behavior changes frequently; live integration tests are available but disabled by default.

Installation

Install dependencies with uv:

uv sync

Run the MCP server locally:

uv run youtube-bilibili-mcp

The command starts a stdio MCP server. It is normally launched by an MCP client rather than run directly in a long-lived terminal.

Claude Code Setup

Register the server globally for Claude Code:

claude mcp add-json --scope user youtube-bilibili-mcp \
  '{"type":"stdio","command":"uvx","args":["youtube-bilibili-mcp"],"env":{"YOUTUBE_MCP_REQUEST_TIMEOUT":"30"}}'

Check the connection:

claude mcp get youtube-bilibili-mcp

Claude Desktop Setup

Add this to claude_desktop_config.json:

{
  "mcpServers": {
    "youtube-bilibili-mcp": {
      "command": "uvx",
      "args": [
        "youtube-bilibili-mcp"
      ],
      "env": {
        "YOUTUBE_MCP_REQUEST_TIMEOUT": "30"
      }
    }
  }
}

An editable example is available at examples/mcp-config.json.

Configuration

Environment variable Description
YOUTUBE_MCP_USER_AGENT Optional custom user agent
YOUTUBE_MCP_REQUEST_TIMEOUT Request timeout in seconds, default 30
YOUTUBE_MCP_HTTP_PROXY Optional HTTP proxy URL
YOUTUBE_MCP_YOUTUBE_COOKIES Optional YouTube cookie header for account-enabled content
YOUTUBE_MCP_BILIBILI_COOKIES Optional BiliBili cookie header for account-enabled content

Do not commit cookie values, API credentials, or proxy credentials.

MCP Tools

Tool Purpose
list_services List supported platforms and feature flags
detect_url Detect platform and resource type for a URL or ID
resolve_url Auto-detect and call the matching extractor
search_videos Search videos or media entries
get_suggestions Return search suggestions
get_trending Return trending, popular, or ranking entries
get_video_info Extract metadata, streams, subtitles, and related context
get_channel_info Extract channel/uploader metadata and recent videos
get_playlist_info Extract playlist, favorite, collection, or PGC season entries
get_subtitles List or fetch subtitles in multiple output formats
get_comments Fetch comments
get_danmaku Fetch BiliBili danmaku
get_live_info Extract live-room or live-video information
get_skip_segments Fetch YouTube SponsorBlock skip segments

MCP Resources

Resource Purpose
video://services Supported service capability matrix
video://service/{platform} Detailed platform capability notes
video://url/{url} URL detection result as resource context

MCP Prompts

Prompt Purpose
summarize_video Guide an agent through metadata, subtitles, comments, and skip segments
research_channel Guide an agent through channel/uploader research

Examples

Ask your MCP client:

Use youtube-bilibili-mcp to resolve https://www.bilibili.com/bangumi/play/ep693247
Use youtube-bilibili-mcp to search YouTube for "lofi study music" and return 5 results.
Use youtube-bilibili-mcp to fetch subtitles for dQw4w9WgXcQ as text.

Development

Run local checks:

uv run ruff check src tests
uv run pytest

Run live extractor tests:

YOUTUBE_MCP_LIVE_TESTS=1 uv run pytest tests/test_live_extractors.py

Build the package:

uv build

Publishing

Publishing notes and an MCP Registry template are available in:

License

MIT License. See LICENSE.

Metadata

Release files for youtube-bilibili-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for youtube-bilibili-mcp 0.1.0
File Size Uploaded Provenance Actions
youtube_bilibili_mcp-0.1.0.tar.gz 36.4 kB Without provenance Details for youtube_bilibili_mcp-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for youtube-bilibili-mcp 0.1.0
File Interpreter ABI Platform Actions
youtube_bilibili_mcp-0.1.0-py3-none-any.whl Python 3 none any Details for youtube_bilibili_mcp-0.1.0-py3-none-any.whl

Total release size: 73.6 kB

Release files / youtube_bilibili_mcp-0.1.0.tar.gz

Download URL youtube_bilibili_mcp-0.1.0.tar.gz
Size 36.4 kB
Tags Source
SHA-256 checksum
How to use checksums
cd6f65e681999d7c3952250af250e03f0d9d9886690d06272c670428bad56ae2
BLAKE2b-256 checksum
How to use checksums
9f5053612e1e7277a311b99dd15f8be677f5731aa8dc1c2bd98231f049aa1ec4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / youtube_bilibili_mcp-0.1.0-py3-none-any.whl

Download URL youtube_bilibili_mcp-0.1.0-py3-none-any.whl
Size 37.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ff302723e081e2ac33a115226c3a3a584aa6966a1827271ac8d0b04c126b833
BLAKE2b-256 checksum
How to use checksums
ef7980510b5aed9fc4011eb7944eb4350955a00ee84828a64e8564d15cac9bab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for youtube-bilibili-mcp 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page