YouTube MCP

by tsubouchi

Integrations

  • Extracts screenshots from YouTube videos at specified intervals or timestamps, with special handling for regular videos and Shorts format.

  • Takes screenshots at 1-10 second intervals from YouTube Shorts, capturing up to 60 screenshots per video with precise cropping of the video area.

YouTube MCP

A tool to automatically take screenshots from YouTube videos. Supports YouTube Shorts and YouTube videos.

function

YouTube Shorts

  • Take a screenshot every n seconds
  • Up to 60 shots (if the video is 60 seconds or longer)
  • Accurately cut out only the video area and save it to tmp/
  • View screenshots in real time
  • Download all or selected images locally as a ZIP file (opens on both Mac and Windows)

YouTube videos

  • Take a screenshot every n seconds
  • Up to 60 shots (if the video is 60 seconds or longer)
  • Accurately cut out only the video area and save it to tmp/
  • View screenshots in real time
  • Download all or selected images locally as a ZIP file (opens on both Mac and Windows)

TikTok

  • Currently in preparation
  • Please use a YouTube or YouTube Shorts URL

Technology stack

  • Node.js 18
  • Express
  • Playwright
  • Firebase Functions (Gen 2)
  • Firebase Hosting
  • Firebase Storage
  • TypeScript
  • Bootstrap CSS

Project Configuration

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セキュリティルール

API List

Take screenshot

  • Endpoint : /screenshot
  • Method : POST
  • Parameters :
    { "url": "YouTube URL", "interval": 1 // 間隔(秒) }
  • response :
    { "success": true, "screenshots": [ { "imageUrl": "署名付きURL", "time": "タイムスタンプ", "filename": "ファイル名" } ], "interval": 1 }

Get screenshot list

  • Endpoint : /screenshots
  • Method : GET
  • response :
    [ { "filename": "ファイル名", "imageUrl": "署名付きURL", "time": "タイムスタンプ" } ]

ZIP Download

  • Endpoint : /download-zip
  • Method : POST
  • Parameters :
    { "filenames": ["ファイル名1", "ファイル名2"] }
  • Response : ZIP file

GCP Architecture

Services Used

  1. Firebase Functions (Gen 2)
  2. Firebase Storage
    • Bucket: mcp-5e4b5.firebasestorage.app
    • Security rules: Access only to authenticated users
  3. Firebase Hosting

IAM permission settings

User permissions
  • t@bonginkan.ai
    • roles/owner (project owner)
    • roles/run.admin (Cloud Run administrator)
Service Account Permissions
  1. Cloud Functions
    • 33501462786-compute@developer.gserviceaccount.com
      • roles/run.admin
      • roles/run.developer
      • roles/run.invoker
      • roles/cloudfunctions.developer
      • roles/storage.admin
  2. Firebase Admin
    • firebase-adminsdk-fbsvc@mcp-5e4b5.iam.gserviceaccount.com
      • roles/firebase.sdkAdminServiceAgent
      • roles/firebaseauth.admin
      • roles/iam.serviceAccountTokenCreator
      • roles/storage.admin
  3. Cloud Build
    • 33501462786@cloudbuild.gserviceaccount.com
      • roles/run.admin
      • roles/cloudfunctions.developer
      • roles/storage.admin
      • roles/artifactregistry.admin
      • roles/eventarc.admin

Implementation details

Screenshot feature

  • Controlling headless browsers with Playwright
  • Viewport size: 1280x720
  • Use a temporary directory to store screenshots
  • After uploading to Firebase Storage, delete the temporary file.
  • Signed URLs are valid for 15 minutes

Error Handling

  • Catch errors at each API endpoint
  • Returns an error message in JSON format.
  • Handling 404 Endpoints
  • Appropriate error response for 500 errors

CORS Settings

Safety features

  • Firebase Storage Security Rules
  • Set expiration time for signed URLs (15 minutes)
  • Properly delete temporary files

Latest revisions (2024-03-28)

Bug fixes

  1. Improved CORS configuration
    • Explicitly specifying allowed origins
    • Enabling Credentials
  2. Improved error handling
    • JSON response for 404 errors
    • Detailed error message for 500 errors
  3. Firebase Storage Support
    • Specifying a bucket name explicitly
    • Set the expiration time for signed URLs to 15 minutes
  4. Cloud Functions Gen 2 Optimizations
    • Optimize memory settings (1GiB)
    • Adjust the timeout setting (540 seconds)
    • Setting the number of concurrent executions (80)

Improved functions

  1. Screenshot feature
    • Optimizing Playwright settings
    • Headless browser viewport settings
    • Improved temporary file management
    • Improved support for YouTube Shorts
    • Real-time display function implementation
  2. Improved API response
    • Error messages in Japanese
    • Standardized response format
    • Standardization of timestamp formats
    • Implementing a streaming response
  3. Enhanced security
    • Firebase Storage security rules update
    • Ensure temporary files are deleted
    • Appropriate restriction of error information
  4. Front-end improvements
    • Optimizing real-time display
    • Image URL correction
    • Improved error handling
    • User interface improvements

set up

  1. Clone the repository
git clone https://github.com/tsubouchi/youtube_mcp.git cd youtube_mcp
  1. Installing Dependencies
# プロジェクトルート npm install # Cloud Functions cd functions npm install
  1. Install Firebase CLI
npm install -g firebase-tools
  1. Logging in to Firebase
firebase login
  1. Initializing the project
firebase init
  1. Deploy
# Cloud Functions cd functions npm run deploy # Firebase Hosting cd .. firebase deploy --only hosting

Setting up a local development environment

  1. Installing Dependencies
# プロジェクトルート npm install # Cloud Functions cd functions npm install
  1. Setting the service account key
  • Download your service account key from the Firebase Console
  • Save as functions/service-account.json
  1. Setting environment variables
# functions/.env GOOGLE_APPLICATION_CREDENTIALS=./service-account.json
  1. Starting the emulator
cd functions npm run serve

Emulator port settings

The emulator uses the following ports:

API Testing

  1. Health Check
curl http://localhost:5001/mcp-5e4b5/us-central1/api
  1. Take screenshot
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}'
  1. Get screenshot list
curl http://localhost:5001/mcp-5e4b5/us-central1/api/screenshots
  1. ZIP Download
curl -X POST http://localhost:5001/mcp-5e4b5/us-central1/api/download-zip \ -H "Content-Type: application/json" \ -d '{"filenames": ["ファイル名1", "ファイル名2"]}'

Notes

  • When using the emulator, you will access the actual Firebase Storage.
  • The service account key is included in .gitignore and is not committed to the repository
  • You can check the execution status and logs of functions in the emulator UI.

Notes

  • Node.js 18 will be deprecated on April 30, 2025
  • The screenshots are saved to a temporary directory and deleted after processing.
  • If the video is longer than 60 seconds, only the first 60 images will be saved.
  • The security rules for Firebase Storage are set to allow access only to authenticated users.
  • Signed URLs are only valid for 15 minutes

IMPORTANT

Specifications for saving screenshots and zipping

  1. Saving a screenshot
    • All screenshots are temporarily saved in /tmp/screenshots/ directory.
    • The file name is in the format screenshot_[タイムスタンプ]_[連番].png
    • The temporary file will be kept after processing is complete and will be overwritten when you take a new screenshot.
  2. Creating a ZIP file
    • The selected screenshot will be loaded directly from /tmp/screenshots/
    • A temporary ZIP file will be created in /tmp/screenshots/ and then deleted after download.
    • The ZIP file name is in the format screenshots_[タイムスタンプ].zip
  3. Managing temporary files
    • Temporary files should be cleaned up regularly
    • We recommend deleting old screenshots before taking new ones.

license

MIT License

-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Automatically captures and processes screenshots from YouTube videos and Shorts at specified intervals, supporting customizable screenshot timing and providing API endpoints for image management.

  1. function
    1. YouTube Shorts
    2. YouTube videos
    3. TikTok
  2. Technology stack
    1. Project Configuration
      1. API List
        1. Take screenshot
        2. Get screenshot list
        3. ZIP Download
      2. GCP Architecture
        1. Services Used
        2. IAM permission settings
      3. Implementation details
        1. Screenshot feature
        2. Error Handling
        3. CORS Settings
        4. Safety features
      4. Latest revisions (2024-03-28)
        1. Bug fixes
        2. Improved functions
      5. set up
        1. Setting up a local development environment
          1. Emulator port settings
          2. API Testing
          3. Notes
        2. Notes
          1. IMPORTANT
            1. Specifications for saving screenshots and zipping
          2. license

            Related MCP Servers

            • -
              security
              A
              license
              -
              quality
              Provides functionality to search YouTube videos and automatically save the results to Google Sheets.
              Last updated -
              1
              9
              JavaScript
              MIT License
            • A
              security
              A
              license
              A
              quality
              Enables capturing high-quality native macOS screenshots using Safari through a Node.js server, supporting various sizes, zoom levels, and load wait times.
              Last updated -
              1
              7
              TypeScript
              MIT License
            • -
              security
              F
              license
              -
              quality
              Enables extraction of transcript text from YouTube videos by providing the video URL, supporting standard, shortened, and embed URL formats.
              Last updated -
              1
              JavaScript
            • A
              security
              A
              license
              A
              quality
              An official MCP server implementation that allows AI assistants to capture website screenshots through the ScreenshotOne API, enabling visual context from web pages during conversations.
              Last updated -
              1
              6
              TypeScript
              MIT License
              • Apple

            View all related MCP servers

            ID: u2f5xij3z5