YouTube Comments MCP Server
Enables fetching and analyzing YouTube video comments and replies through the YouTube Data API. Supports sorting by relevance or time and returns structured JSON data for comment analysis, summarization, and translation tasks.
README
yt_mcp — YouTube Comments MCP Server
一個遵循 Model Context Protocol (MCP) 的本機伺服器。提供工具:
fetch_comments(videoUrl, order="relevance|time", max=300)以 YouTube Data API v3 取得並展開 頂層留言+回覆,回傳 JSON 字串。
需求
- Python 3.10+
- 已啟用 YouTube Data API v3 的 API 金鑰
安裝
uv venv
source .venv/bin/activate
uv pip install "mcp[cli]" httpx python-dotenv
設定金鑰(擇一)
A. 用 .env(推薦)
在專案根目錄建立 .env:
YOUTUBE_API_KEY=YOUR_API_KEY_HERE
B. 寫在客戶端設定的 env(見下方範例)
在 Claude Desktop 使用(本機 STDIO)
- 開啟:Settings → Developer → Local MCP servers → Edit Config
- 加入(請把絕對路徑換成你的實際路徑):
{
"mcpServers": {
"yt_comments": {
"command": "<abs path>/yt_mcp/.venv/bin/python",
"args": ["<abs path>/yt_mcp/server.py"],
"env": { "YOUTUBE_API_KEY": "YOUR_API_KEY" } // 若已用 .env,可移除此段
}
}
}
也可不填
env,改用專案根目錄的.env。
- 回到 Local MCP servers 啟動
yt_comments。 - 新開對話請 Claude 呼叫:
yt_comments.fetch_comments(
videoUrl="https://www.youtube.com/watch?v=XXXXXXXXXXX",
order="relevance",
max=300
)
接著請模型做摘要/分類/翻譯並輸出報告。
在 MCP Inspector 測試
- Transport:
STDIO - Command:
<abs path>/yt_mcp/.venv/bin/python - Arguments:
<abs path>/yt_mcp/server.py - Environment(可選):
YOUTUBE_API_KEY=YOUR_API_KEY
輸出格式(節選)
{
"video_id": "abcdEFGhijk",
"order": "relevance",
"requested": 300,
"total_returned": 278,
"items": [
{
"id": "...",
"parentId": null,
"author": "Somebody",
"publishedAt": "2025-01-01T12:34:56Z",
"likeCount": 42,
"text": "Great video!"
}
]
}
Troubleshooting
- Missing YOUTUBE_API_KEY
在
.env或設定的env補上金鑰,並確認金鑰已啟用 YouTube Data API v3。 - 找不到
server.py在設定裡把args改用絕對路徑(例如"/Users/you/yt_mcp/server.py")。 - ModuleNotFoundError
確認已在虛擬環境內安裝相依套件(
"mcp[cli]" httpx python-dotenv)。 - HTTP 403/400 可能是配額不足、影片關閉留言、或金鑰權限未開。
安全
.env已在.gitignore中,請勿提交金鑰。- 若曾不小心提交金鑰,請 旋轉金鑰 並清理 Git 歷史。
授權
MIT License。
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.