YouTube MCP Server

by nattyraz

5 stars
258 downloads
Not rated
GitHub

About

A Model Context Protocol (MCP) server for YouTube videos with caption extraction and markdown conversion capabilities

Details

Author
nattyraz
GitHub stars
5
Downloads
258
Categories
Web Scraping, Other, Media

- Fetch comprehensive video metadata (title, description, etc.)
- Extract auto‑generated and manual captions
- Support for English and French captions
- Three built‑in markdown templates: basic, detailed, and search
- Search functionality within video captions
- Flexible authentication: API key or OAuth2

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name YouTube MCP Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install Node.js v16+, clone the repository, install dependencies (npm install), build the project (npm run build), and configure a .env file with your YouTube Data API key and optionally OAuth2 credentials. Then add the server to your MCP settings file (e.g., ~/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json) with the command node path/to/build/index.js and the required environment variables. Use tools like get_video_info, get_captions, convert_to_markdown, and list_templates via MCP tool calls.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "youtube mcp server": {
            "youtube-mcp-nattyraz": {
                "command": "node",
                "args": [
                    "src/get-api-key.js"
                ]
            }
        }
    }
}

McpServers

{
    "youtube-mcp-nattyraz": {
        "command": "node",
        "args": [
            "src/get-api-key.js"
        ]
    }
}

YouTube MCP Server

A Model Context Protocol (MCP) server for interacting with YouTube videos. This server provides tools for extracting video metadata, captions, and converting them to markdown format with various templates.

Features

- Video Metadata: Fetch comprehensive video information
- Caption Extraction: Support for auto-generated and manual captions
- Multiple Languages: Built-in support for English and French
- Template System: Three built-in markdown templates:
- Basic: Simple transcript format
- Detailed: Full metadata with timestamps
- Search: Results highlighting with context
- Search Functionality: Search within video captions
- Flexible Authentication: Supports both API key and OAuth2 authentication

Prerequisites

- Node.js (v16 or higher)
- npm or yarn
- A YouTube Data API key and/or OAuth2 credentials

Installation

1. Clone the repository:

git clone [repository-url]
cd youtube-mcp

2. Install dependencies:

npm install

3. Build the project:

npm run build

Configuration

Create a .env file in the root directory with your YouTube credentials:

YOUTUBE_API_KEY=your_api_key
YOUTUBE_CLIENT_ID=your_client_id
YOUTUBE_CLIENT_SECRET=your_client_secret
YOUTUBE_REFRESH_TOKEN=your_refresh_token  # Optional, for OAuth2

MCP Configuration

Add the server to your MCP settings file (usually at ~/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json):

{
  "mcpServers": {
    "youtube": {
      "command": "node",
      "args": ["path/to/youtube-mcp/build/index.js"],
      "env": {
        "YOUTUBE_API_KEY": "your_api_key",
        "YOUTUBE_CLIENT_ID": "your_client_id",
        "YOUTUBE_CLIENT_SECRET": "your_client_secret"
      },
      "disabled": false,
      "alwaysAllow": []
    }
  }
}

Usage

The server provides the following tools:

1. Get Video Info

use_mcp_tool youtube get_video_info {
  "url": "https://www.youtube.com/watch?v=VIDEO_ID"
}

2. Get Captions

use_mcp_tool youtube get_captions {
  "url": "https://www.youtube.com/watch?v=VIDEO_ID",
  "language": "en"  // Optional, defaults to "en"
}

3. Convert to Markdown

use_mcp_tool youtube convert_to_markdown {
  "url": "https://www.youtube.com/watch?v=VIDEO_ID",
  "template_name": "detailed",  // Optional, "basic", "detailed", or "search"
  "language": "en",            // Optional
  "options": {                 // Optional
    "include_chapters": true,
    "search_term": "keyword"   // Only for search template
  }
}

4. List Templates

use_mcp_tool youtube list_templates

Dependencies

{
  "dependencies": {
    "@modelcontextprotocol/sdk": "latest",
    "googleapis": "^146.0.0",
    "google-auth-library": "^9.0.0",
    "youtube-captions-scraper": "^2.0.0",
    "express": "^4.18.2",
    "open": "^9.1.0"
  },
  "devDependencies": {
    "@types/node": "^20.0.0",
    "typescript": "^5.0.0",
    "tsx": "^4.0.0"
  }
}

OAuth2 Setup

For OAuth2 authentication (required for private video access):

1. Create a project in the Google Cloud Console
2. Enable the YouTube Data API v3
3. Create OAuth2 credentials (Web application type)
4. Run the authentication script:

node src/get-api-key.js

5. Follow the browser prompts to authorize the application
6. Copy the refresh token to your configuration

Customizing Templates

You can add custom templates by modifying the DEFAULT_TEMPLATES array in src/index.ts. Templates follow this structure:

interface MarkdownTemplate {
  name: string;
  description: string;
  format: {
    header?: string;
    chapter_format?: string;
    caption_block: string;
    timestamp_format?: string;
    search_result_format?: string;
  }
}

License

MIT

Contributing

1. Fork the repository
2. Create your feature branch (git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add some amazing feature')
4. Push to the branch (git push origin feature/amazing-feature)
5. Open a Pull Request

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.