youtube mcp
Automatically captures and processes screenshots from YouTube videos and Shorts at specified intervals, supporting customizable screenshot timing and providing API endpoints for image management.
Automatically captures and processes screenshots from YouTube videos and Shorts at specified intervals, supporting customizable screenshot timing and providing API endpoints for image management.
YouTubeの動画から自動的にスクリーンショットを取得するツールです。YouTube ShortsとYouTube動画に対応しています。
tmp/
に保存tmp/
に保存Playwrigh-MCP-Server/
├── functions/ # Cloud Functions
│ ├── src/ # ソースコード
│ │ ├── index.ts # メインエントリーポイント
│ │ ├── screenshot.ts # スクリーンショット機能
│ │ ├── screenshots.ts # スクリーンショット一覧取得
│ │ ├── download-zip.ts # ZIPダウンロード機能
│ │ └── types.ts # 型定義
│ ├── package.json # 依存関係
│ └── tsconfig.json # TypeScript設定
├── public/ # 静的ファイル
│ └── index.html # メインページ
├── firebase.json # Firebase設定
└── storage.rules # Storageセキュリティルール
/screenshot
{
"url": "YouTube URL",
"interval": 1 // 間隔(秒)
}
{
"success": true,
"screenshots": [
{
"imageUrl": "署名付きURL",
"time": "タイムスタンプ",
"filename": "ファイル名"
}
],
"interval": 1
}
/screenshots
[
{
"filename": "ファイル名",
"imageUrl": "署名付きURL",
"time": "タイムスタンプ"
}
]
/download-zip
{
"filenames": ["ファイル名1", "ファイル名2"]
}
エンドポイント: https://api-ub7zp5pjra-uc.a.run.app
Firebase Storage
セキュリティルール: 認証済みユーザーのみアクセス可能
Firebase Hosting
[email protected]
roles/owner
(プロジェクト所有者)roles/run.admin
(Cloud Run管理者)roles/run.admin
roles/run.developer
roles/run.invoker
roles/cloudfunctions.developer
roles/storage.admin
Firebase Admin
roles/firebase.sdkAdminServiceAgent
roles/firebaseauth.admin
roles/iam.serviceAccountTokenCreator
roles/storage.admin
Cloud Build
[email protected]
roles/run.admin
roles/cloudfunctions.developer
roles/storage.admin
roles/artifactregistry.admin
roles/eventarc.admin
クレデンシャルの有効化
エラーハンドリングの強化
500エラー時の詳細なエラーメッセージ
Firebase Storage対応
署名付きURLの有効期限を15分に設定
Cloud Functions Gen 2の最適化
リアルタイム表示機能の実装
API応答の改善
ストリーミングレスポンスの実装
セキュリティ強化
エラー情報の適切な制限
フロントエンド改善
リポジトリのクローン
git clone https://github.com/tsubouchi/youtube_mcp.git
cd youtube_mcp
依存パッケージのインストール
# プロジェクトルート
npm install
# Cloud Functions
cd functions
npm install
Firebase CLIのインストール
npm install -g firebase-tools
Firebaseへのログイン
firebase login
プロジェクトの初期化
firebase init
デプロイ
# Cloud Functions
cd functions
npm run deploy
# Firebase Hosting
cd ..
firebase deploy --only hosting
依存パッケージのインストール
# プロジェクトルート
npm install
# Cloud Functions
cd functions
npm install
サービスアカウントキーの設定
functions/service-account.json
として保存
環境変数の設定
# functions/.env
GOOGLE_APPLICATION_CREDENTIALS=./service-account.json
エミュレータの起動
cd functions
npm run serve
エミュレータは以下のポートを使用します: - Functions: http://127.0.0.1:5001 - Emulator UI: http://127.0.0.1:4001
ヘルスチェック
curl http://localhost:5001/mcp-5e4b5/us-central1/api
スクリーンショット取得
curl -X POST http://localhost:5001/mcp-5e4b5/us-central1/api/screenshot
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{"url": "YouTube URL", "interval": 5}'
スクリーンショット一覧取得
curl http://localhost:5001/mcp-5e4b5/us-central1/api/screenshots
ZIPダウンロード
curl -X POST http://localhost:5001/mcp-5e4b5/us-central1/api/download-zip
-H "Content-Type: application/json"
-d '{"filenames": ["ファイル名1", "ファイル名2"]}'
.gitignore
に含まれており、リポジトリにコミットされません/tmp/screenshots/
ディレクトリに一時保存されますscreenshot_[タイムスタンプ]_[連番].png
の形式です一時ファイルは処理完了後も保持され、新しいスクリーンショットを撮影する際に上書きされます
ZIPファイルの作成
/tmp/screenshots/
から直接読み込まれます/tmp/screenshots/
に作成され、ダウンロード後に削除されますZIPファイル名はscreenshots_[タイムスタンプ].zip
の形式です
一時ファイルの管理
MIT License