YouTube MCP
Enables YouTube video upload, metadata updates, thumbnail management, stats retrieval, and analytics via the YouTube Data API v3 and Analytics API using OAuth 2.0.
README
YouTube MCP
This project provides a Python MCP server for a practical YouTube upload and management workflow that uses the real YouTube Data API v3 and YouTube Analytics API with Google OAuth 2.0.
Architecture
The code is intentionally split into separate layers:
youtube_mcp/server.pyexposes MCP tools to Claude or any MCP client.youtube_mcp/services/youtube_service.pycontains the actual YouTube API logic and validation.youtube_mcp/config.pyreads environment variables and keeps secret values out of source control.
This separation keeps the tool layer focused on MCP contracts while the service layer handles YouTube API requests, validation, and error handling.
Required OAuth and API approach
This project is designed for authenticated workflow operations, not API-key-only use.
For upload, channel management, thumbnail update, and other private/channel-based actions, use Google OAuth 2.0 with the following scopes:
https://www.googleapis.com/auth/youtube.uploadhttps://www.googleapis.com/auth/youtube.readonlyhttps://www.googleapis.com/auth/youtubepartnerhttps://www.googleapis.com/auth/yt-analytics.readonly
The server expects these values in environment variables or a local .env file:
export GOOGLE_CLIENT_ID="your-google-client-id"
export GOOGLE_CLIENT_SECRET="your-google-client-secret"
export YOUTUBE_REFRESH_TOKEN="your-google-refresh-token"
export YOUTUBE_ACCESS_TOKEN="optional-current-access-token"
export YOUTUBE_CHANNEL_ID="optional-channel-id"
Never put client secrets, refresh tokens, or access tokens in source code or Git.
Tool set
hello_youtube
Simple validation tool that returns:
YouTube MCP is working
upload_video
Uploads a video file to YouTube.
Inputs:
title(required)description(required)file_path(required local/publicly accessible path)tags(optional list of YouTube tag strings)hashtags(optional list of hashtags; these are added to the description text)privacy_status(optional:public,private, orunlisted)scheduled_publish_at(optional ISO 8601 future datetime; requiresprivacy_status="private"for YouTube scheduling)category_id(optional)made_for_kids(optional boolean)
Behavior:
- Does not fake a success result.
- Returns the uploaded video ID only when the YouTube API confirms it.
- Validates
scheduled_publish_atand rejects non-future or invalid timestamps. - Treats hashtags separately from YouTube tags; hashtags are represented in the title/description text, while tags go into the video
tagsfield.
update_video
Updates video metadata.
Inputs:
video_id(required)title(optional)description(optional)tags(optional)hashtags(optional)privacy_status(optional)scheduled_publish_at(optional)category_id(optional)made_for_kids(optional)
Rules:
- Requires a valid update payload.
- For scheduled publishing, YouTube requires private + publishAt workflow.
- Returns the API result only when the update request succeeds.
set_thumbnail
Sets a thumbnail image for an existing YouTube video.
Inputs:
video_id(required)thumbnail_path(required local file path)
get_video_stats
Gets public YouTube video metadata and statistics for a given video ID.
get_channel_info
Fetches channel metadata for a channel ID, username, or mine=True when authenticated.
get_latest_videos
Lists recent videos for a channel.
get_video_analytics
Uses the YouTube Analytics API with authorized metrics for available reporting dimensions and filters.
Validation and error handling
The service layer validates:
privacy_statusscheduled_publish_at- missing required parameters
- file existence for uploads and thumbnails
- OAuth environment configuration before channel or upload actions run
If the YouTube API responds with an error, the code raises a clear RuntimeError or ValueError with the API response details instead of masking the failure.
Local development / stdio mode
Run the local MCP server over stdio:
cd /workspaces/youtube-mcp
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m youtube_mcp.server
This uses the local stdio transport for testing and debugging.
Remote HTTP MCP mode for Claude Custom Connector
The repository also supports a remote HTTP transport using the installed official MCP Python SDK.
Set the host/port and transport mode before starting the server:
cd /workspaces/youtube-mcp
source .venv/bin/activate
export YOUTUBE_MCP_TRANSPORT="http"
export YOUTUBE_MCP_HOST="127.0.0.1"
export YOUTUBE_MCP_PORT="8000"
export YOUTUBE_MCP_HTTP_PATH="/mcp"
python -m youtube_mcp.server
This exposes the MCP protocol at:
http://127.0.0.1:8000/mcp
The health endpoint is available at:
http://127.0.0.1:8000/health
You can verify the health endpoint with:
curl http://127.0.0.1:8000/health
Expected response:
{"status":"ok","service":"youtube-mcp","transport":"http"}
Notes
.envis included in.gitignore.- OAuth tokens and credentials are intentionally kept in environment variables.
- No fake API responses are used.
- No deployment or public publishing is configured in this repository.
- The Google OAuth redirect URI is not changed here.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。