Fetches YouTube video comments and replies through the YouTube Data API, allowing retrieval of top-level comments with configurable ordering and limits for analysis and reporting.
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 金鑰
安裝
設定金鑰(擇一)
A. 用
在專案根目錄建立 .env:
B. 寫在客戶端設定的
在 Claude Desktop 使用(本機 STDIO)
開啟:Settings → Developer → Local MCP servers → Edit Config
加入(請把絕對路徑換成你的實際路徑):
也可不填
env,改用專案根目錄的.env。
回到 Local MCP servers 啟動
yt_comments。新開對話請 Claude 呼叫:
接著請模型做摘要/分類/翻譯並輸出報告。
在 MCP Inspector 測試
Transport:
STDIOCommand:
<abs path>/yt_mcp/.venv/bin/pythonArguments:
<abs path>/yt_mcp/server.pyEnvironment(可選):
YOUTUBE_API_KEY=YOUR_API_KEY
輸出格式(節選)
Troubleshooting
Missing YOUTUBE_API_KEY 在
.env或設定的env補上金鑰,並確認金鑰已啟用 YouTube Data API v3。找不到 在設定裡把
args(例如"/Users/you/yt_mcp/server.py")。ModuleNotFoundError 確認已在虛擬環境內安裝相依套件(
"mcp[cli]" httpx python-dotenv)。HTTP 403/400 可能是配額不足、影片關閉留言、或金鑰權限未開。
安全
.env已在.gitignore中,請勿提交金鑰。若曾不小心提交金鑰,請 旋轉金鑰 並清理 Git 歷史。
授權
MIT License。
This server cannot be installed