YouTube Channel MCP Server

YouTube Channel MCP Server

Retrieves YouTube Channel statistics, metadata, and uploaded videos using the YouTube Data API v3.

Category
访问服务器

README

YouTube Channel MCP Server (Python FastAPI)

A Model Context Protocol (MCP) server that retrieves YouTube Channel statistics, metadata, and uploaded videos using the YouTube Data API v3.

This version is implemented in Python using FastAPI and the FastMCP SDK. It runs as an HTTP service over Server-Sent Events (SSE), making it ready for local development and cloud hosting on platforms like Vercel.

Features

  • Server-Sent Events (SSE) Transport: Host your MCP server as a remote service.
  • Auto-generated Docs: Swagger/OpenAPI interactive documentation automatically available at /docs.
  • Flexible Queries: Search channel statistics and uploads using either a channel ID or handle (automatically handles @ prefix normalization).
  • Vercel Ready: Contains a pre-configured vercel.json routing configuration.

Local Setup

  1. Install dependencies:

    pip install -r requirements.txt
    
  2. Add Environment Variables: Create a .env file in the project root:

    YOUTUBE_API_KEY=your_google_youtube_api_key_here
    
  3. Run the Server: Start the FastAPI development server using Uvicorn:

    uvicorn api.index:app --reload
    

    The server will start at http://127.0.0.1:8000.


Interactive API Documentation

Once the server is running, you can access the interactive Swagger UI in your browser:

You can test endpoints and check request/response schemas directly from the Swagger UI.


Connecting to Claude Desktop (SSE Mode)

To connect Claude Desktop to your locally running FastAPI server, edit your configuration file:

  • Windows Path: %APPDATA%\Claude\claude_desktop_config.json
  • macOS Path: ~/Library/Application Support/Claude/claude_desktop_config.json

Add the server to mcpServers using the url property:

{
  "mcpServers": {
    "youtube-channel-info-sse": {
      "url": "http://127.0.0.1:8000/sse"
    }
  }
}

Ensure your FastAPI server is running (uvicorn api.index:app) before restarting Claude Desktop.


Deploying to Vercel

Because this server uses the SSE transport over standard HTTP endpoints, you can deploy it directly to Vercel:

  1. Push your repository to GitHub.
  2. Go to Vercel and import your project.
  3. In Settings -> Environment Variables, add your:
    • YOUTUBE_API_KEY = <your_api_key>
  4. Deploy!

Vercel will build the serverless functions. Your live remote MCP URL will be: https://your-project.vercel.app/sse You can then share this URL or use it in any remote-compatible MCP client configuration!


Available Tools

1. get_channel_details

Retrieves YouTube channel metadata and statistics.

  • Arguments:
    • channel_id (string, optional): Unique ID of the channel (e.g. UC_x5XG1OV2P6uZZ5FSM9Ttw).
    • handle (string, optional): Custom handle of the channel (e.g. @GoogleDevelopers or GoogleDevelopers).

2. get_channel_videos

Retrieves recently uploaded videos for a channel.

  • Arguments:
    • channel_id (string, optional)
    • handle (string, optional)
    • limit (number, optional, default: 10, max: 50): Number of videos to retrieve.

3. get_video_analytics

Retrieves public statistics (views, likes, comments) and metadata (duration, definition). When OAuth2 is configured, it also fetches private Analytics API metrics (impressions, CTR, watch time, retention/average percentage, subscriber gains/losses, shares).

  • Arguments:
    • video_ids (string, required): Comma-separated list of video IDs (e.g. bfvS1UeAkN0,qnl8-PBJNu4).

4. get_channel_video_analytics

Retrieves recent uploads for a channel fully enriched with public statistics and private Analytics API metrics (if OAuth2 is configured).

  • Arguments:
    • channel_id (string, optional)
    • handle (string, optional)
    • limit (number, optional, default: 10, max: 50)

Private YouTube Analytics Setup (OAuth2)

To retrieve private video-level performance metrics (such as CTR, impressions, average watch duration, and subscriber changes), you must obtain Google OAuth2 Client credentials and a refresh token.

1. Google Cloud Console Setup

  1. Go to the Google Cloud Console.
  2. Create a new project (or select an existing one).
  3. Enable both the YouTube Analytics API and the YouTube Data API v3.
  4. Configure the OAuth Consent Screen:
    • Choose External user type.
    • Enter standard details (AppName, Support Email).
    • Add your own email as a Test User (required while in testing status).
  5. Create Credentials:
    • Go to Credentials -> Create Credentials -> OAuth Client ID.
    • Select Web application as application type.
    • Add http://localhost:8080/ under Authorized redirect URIs.
    • Copy the generated Client ID and Client Secret.

2. Generate the Refresh Token

You can easily generate your refresh token using the helper script included in the repository:

  1. Run the helper script:
    python get_refresh_token.py
    
  2. Enter your Client ID and Client Secret when prompted.
  3. The script will automatically open your web browser to sign in to your Google Account.
  4. Sign in with the account owning the YouTube channel and grant the permissions.
  5. Return to your terminal to copy the generated Refresh Token.

3. Environment Variables

Add the generated credentials to your .env (or Vercel Environment Variables):

YOUTUBE_CLIENT_ID=your_client_id
YOUTUBE_CLIENT_SECRET=your_client_secret
YOUTUBE_REFRESH_TOKEN=your_refresh_token

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选