Skip to main content
Glama
mcp-youtube-intelligence

mcp-youtube-intelligence

by Dmitriusan
README.md
# mcp-youtube-intelligence

MCP server for extracting structured intelligence from YouTube channels and videos.

## What it does

Analyzes YouTube channels to produce structured intelligence reports:
- Transcript extraction across recent videos (up to 50 videos)
- Semantic topic extraction per video via Gemini (theme, named entities, tags)
- Keyword frequency analysis across all transcripts (fallback when Gemini is unavailable)

## Prerequisites

You need API keys for three services:

| Variable | Where to get it |
|----------|----------------|
| `YOUTUBE_API_KEY` | [Google Cloud Console](https://console.cloud.google.com/) → YouTube Data API v3 |
| `APIFY_TOKEN` | [Apify Console](https://console.apify.com/) → Account → Integrations → API token |
| `GEMINI_API_KEY` | [Google AI Studio](https://aistudio.google.com/) → Get API key |

`YOUTUBE_API_KEY` and `APIFY_TOKEN` are required: without them `analyze_channel` fails before sending any request, and the error names every key that is missing.

`GEMINI_API_KEY` is optional — if omitted, the tool falls back to word-frequency topic extraction instead of semantic analysis. The same fallback applies when a configured Gemini call fails (invalid key, exhausted quota, blocked content); the result's `note` says why.

**Optional**

| Variable | Default | Description |
|----------|---------|-------------|
| `ANALYZE_CHANNEL_OUTPUT_DIR` | `./output/` | Directory where per-channel JSON analysis artifacts are written. The default is relative to the server's working directory, which your MCP client chooses (some start servers in `/`, where the write is denied). Set an absolute path to be sure: when the write fails the analysis still succeeds, but the result has no `output_path` and the reason goes only to stderr |

## Installation

```bash
npm install -g mcp-youtube-intelligence
```

## CLI flags

```bash
mcp-youtube-intelligence --version   # or -v — print the installed version and exit
mcp-youtube-intelligence --help      # or -h — print usage and exit
```

Running the command with no flags starts the MCP server itself (stdio transport) — this is what
an MCP client config invokes; it's not meant to be run bare in a terminal for interactive use.

## Usage

Add to your Claude Desktop / MCP client config:
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Linux**: `~/.config/Claude/claude_desktop_config.json`
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`

```json
{
  "mcpServers": {
    "youtube-intelligence": {
      "command": "mcp-youtube-intelligence",
      "env": {
        "YOUTUBE_API_KEY": "your-youtube-api-key",
        "APIFY_TOKEN": "your-apify-token",
        "GEMINI_API_KEY": "your-gemini-api-key"
      }
    }
  }
}
```

### Tools

**`analyze_channel`** — Extract intelligence from a YouTube channel

```
channel_url: YouTube channel URL or @handle. Accepts:
               - @handle (e.g. @fireship; handles in any script work, e.g. @фокусхплаза)
               - full URL with handle (e.g. youtube.com/@fireship; a percent-encoded
                 non-ASCII handle copied from a browser address bar is decoded)
               - /channel/UC... URL
               - bare 24-character UC... channel ID
               - legacy /user/name URL (looked up exactly by its username)
               - legacy /c/name URL (found by YouTube search, which takes the
                 first matching channel; prefer @handle when you know it)
max_videos:  Number of recent videos to analyze (default: 5, max: 50)
```

Each run spends 2 units of the YouTube Data API's daily quota (10,000 by default) on the channel and its
video list. A /c/ URL adds 100 for the search; a /user/ name the username lookup does not know falls back to
that search too.

Returns a JSON object:

| Field | Meaning |
|-------|---------|
| `channel_id`, `channel_title` | The resolved channel |
| `channel_url` | Your `channel_url` input, echoed back |
| `sample_video_ids` | The most recent uploads that were analyzed |
| `videos_analyzed` | How many videos were fetched from the channel's uploads playlist |
| `transcripts_available` | How many of those came back with caption content |
| `topics` | Up to 20 top keywords by frequency across all transcripts. Always computed. Counts plain English words only: a word with an accented or non-Latin letter is skipped, so a transcript in another language gives few or no keywords here (`topics_structured` still works for it when Gemini is configured) |
| `topics_structured` | Per video: `theme`, `entities[]`, `tags[]` from Gemini. Empty when Gemini is not configured or fails. Only the first 1,000 words of each transcript are sent, and a video Gemini blocks or returns nothing usable for is left out. After 3 videos in a row that Gemini never answers or keeps refusing (timeout, connection failure, 429 or 5xx after one retry) the remaining videos are not sent, so a rate-limited key or an unreachable Gemini costs seconds, not minutes. A 429 for the key's daily quota (the free tier allows `gemini-2.5-flash` 20 requests a day; it resets at midnight Pacific time) is not retried and stops the run at once, and `note` names the limit and when to retry |
| `note` | Which analysis mode ran. When Gemini was configured but failed, or when none of the videos returned a transcript (so there was nothing to analyze), it also says why. When Gemini answered for some transcripts but not others, it says how many are missing from `topics_structured` and the most recent cause |
| `output_path` | Where the JSON artifact was written. Absent if the write failed |

**Example prompt:** "Analyze the @fireship YouTube channel and tell me what topics they cover most."

## Development

```bash
npm install
npm run build
npm test
```

## License

MIT

TDQS

A4.1/5.0

Scored across 1 tool

Disambiguation5/5

Only one tool exists, so there is no possibility of confusion with other tools.

Naming Consistency5/5

The single tool name 'analyze_channel' follows a clear verb_noun pattern, making it predictable and unambiguous.

Tool Count2/5

With only one tool for a domain like YouTube intelligence, the surface is too narrow; typical well-scoped servers have 3-15 tools.

Completeness2/5

The server only offers channel analysis, missing obvious operations like video search, video details, playlist management, and subscription handling, leaving significant gaps.

Maintenance

ActivityActive
ResponsivenessNo recent community issues