Skip to main content
Glama
YouTube Playlist MCP

YouTube Playlist MCP

by haktanonur

YouTube Playlist MCP

🇹🇷 Türkçe README

An MCP server that lets AI agents (Claude, ChatGPT, Cursor, …) research a topic on YouTube, rank the most valuable videos and save them as a playlist in your account.

Ask "I want to learn German, where should I start?" and get back a ready-to-watch playlist instead of 40 open tabs.

  • 🔎 Searches 50–100 candidates, with filters for language, country, upload date and duration

  • 📊 Scores every video 0–100 on popularity, like rate, comment rate and (optionally) recency, so an 8-year-old viral video doesn't win by age alone

  • 🧹 Drops Shorts, live streams, low-view videos, and caps how many videos one channel can place in the list

  • 🧠 Lets the agent judge relevance by reading titles and descriptions to remove off-topic, clickbait or wrong-language results

  • 👀 Previews a numbered list (title, channel, duration, views, score) that you can tweak: "remove #3", "favour newer videos", "sort by like rate"

  • ✅ Creates the playlist only after you approve it. Playlists are unlisted by default

  • 🗂️ Manages your existing playlists: list them, add videos, remove videos

  • 📉 Tracks the daily API quota and refuses up front if an action wouldn't fit

What it doesn't do: it doesn't watch or summarize videos, upload, comment, like, subscribe, or delete playlists, and it never scrapes. It only uses the official YouTube Data API v3.


Setup (about 10 minutes, one time)

Every user creates their own free Google Cloud project and OAuth client. You never share keys with the author or anyone else, your data and quota stay yours, and nothing passes through a third-party server.

0. Get the code

Requires Node.js 22 or newer and git.

git clone https://github.com/haktanonur/youtube-playlist-mcp.git
cd youtube-playlist-mcp
npm install
npm run build

To update later, run git pull && npm install && npm run build.

1. Create a Google Cloud project and enable the API

  1. Go to https://console.cloud.google.com/ and create a project (e.g. youtube-playlist-mcp).

  2. Open APIs & Services → Library, search for YouTube Data API v3 and click Enable.

  1. Go to APIs & Services → OAuth consent screen (shown as Google Auth Platform in newer consoles).

  2. Choose External and fill in an app name and your email. ("Internal" is only offered to Google Workspace organizations. For a personal Gmail account, External is the only option. It doesn't make your app public: while it's in Testing mode, only the test users you add can sign in.)

  3. Under Audience → Test users, add your own Google account (the one that owns the YouTube channel).

  4. Under Data access, you can add the scope https://www.googleapis.com/auth/youtube (optional; the app asks for it anyway).

While the app's publishing status is Testing, Google expires the authorization after 7 days and you'll need to run auth again. To avoid that, click Publish app. Google will warn that the app is unverified, which is expected for a personal app only you use. You can click Advanced → Go to (app name).

3. Create an OAuth client

  1. Go to APIs & Services → Credentials → Create credentials → OAuth client ID.

  2. Application type: Desktop app.

  3. Click Download JSON. You'll get a file like client_secret_XXXX.json.

4. Authorize (in a terminal, inside the project folder)

npm run auth -- --client-file ~/Downloads/client_secret_XXXX.json

A browser window opens. Sign in with your YouTube account and allow access. The client and token are saved to ~/.config/youtube-playlist-mcp/ (on Windows, %APPDATA%\youtube-playlist-mcp\) with permissions only you can read. After that you can delete the downloaded JSON.

5. Add it to your MCP client

You need two absolute paths: one to node (run which node, or where node on Windows) and one to dist/index.js in the folder you cloned.

Claude Desktop: edit claude_desktop_config.json (Settings → Developer → Edit Config):

{
  "mcpServers": {
    "youtube-playlist": {
      "command": "/usr/local/bin/node",
      "args": ["/Users/you/youtube-playlist-mcp/dist/index.js"]
    }
  }
}

Use the full path to node: Claude Desktop doesn't always see your shell's PATH.

Claude Code:

claude mcp add youtube-playlist -- node /Users/you/youtube-playlist-mcp/dist/index.js

Cursor / VS Code / others: use the same command + args in the client's MCP config.

Restart the client and ask: "Build me a playlist of the best beginner Python tutorials in English, longer than 20 minutes."

Optional: search-only mode with an API key

If you only want search and scoring, without creating playlists, you can skip OAuth and use an API key (Credentials → Create credentials → API key, then restrict it to YouTube Data API v3):

"env": { "YOUTUBE_API_KEY": "your-key" }

Related MCP server: YouTube MCP Server

Tools

Tool

What it does

Writes to your account?

Quota

search_videos

Search, filter and score candidates

No

~101 per 50 candidates

preview_playlist

Numbered preview; exclusions, sorting, recency, custom order

No

0

create_playlist

Create the approved draft (unlisted by default)

Yes (needs confirm: true)

50 + 50/video

list_my_playlists

Your playlists

No

1

get_playlist_items

Videos in a playlist

No

1 per 50

add_videos_to_playlist

Add videos, skipping ones already present

Yes (needs confirm: true)

50/video

remove_videos_from_playlist

Remove videos

Yes (needs confirm: true)

50/video

get_status

Auth state and today's quota usage

No

0

There is also a prompt, research_playlist, that walks the agent through the whole workflow.

Quota

Google gives each project 10,000 units per day for free (resets at midnight Pacific Time). A typical run looks like this: search 100 candidates (~202) + create a 20-video playlist (1,050) ≈ 1,250 units, so about 8 playlists a day. Writes are the expensive part: each video added costs 50 units. If your project has a higher quota, set YOUTUBE_DAILY_QUOTA.

The counter is kept locally, so it can't see usage from other apps that share the same Cloud project. YouTube's own "quota exceeded" error is still handled cleanly.

How scoring works

Each signal is converted to a percentile within the candidate pool, then combined with weights you can adjust:

Signal

Default weight

Notes

Popularity

0.45

Half total views (log scale), half views per day, so old videos don't win by age alone

Like rate

0.35

likes/views with Bayesian smoothing, so 50 views with 10 likes doesn't beat 2M views with 100K likes

Comment rate

0.20

comments/views, smoothed the same way

Recency

0 (off)

One-year half-life; turn it on with recency_weight (e.g. 0.3)

Hidden likes or disabled comments count as neutral. Filters remove videos ≤60 s (or ≤3 min tagged #shorts), live/upcoming streams, videos under 1,000 views (min_views), and limit each channel to 2 videos (max_per_channel).


Configuration

Env var

Purpose

GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET

Alternative to auth --client-file

YOUTUBE_API_KEY

Search-only mode without OAuth

YOUTUBE_DAILY_QUOTA

Your project's daily quota (default 10000)

YOUTUBE_PLAYLIST_MCP_HOME

Config directory (default ~/.config/youtube-playlist-mcp)

CLI (from the project folder):

npm run status    # what is configured
npm run logout    # revoke access at Google and delete the token

Security & privacy

  • Uses only the official YouTube Data API over HTTPS. There's no telemetry and no third-party server.

  • OAuth uses the installed-app loopback flow with PKCE (S256) and a random state. The callback listens on 127.0.0.1 only and shuts down after one use or 5 minutes.

  • Requests a single scope, youtube, which is the narrowest one that can manage playlists. The server has no tool that deletes playlists.

  • Tokens and the OAuth client are stored in files with mode 0600, in a 0700 directory. Credentials are sent in headers, never in URLs.

  • Every write tool requires confirm: true and is marked with MCP tool annotations. Each draft can only be created once, so a retry can't create duplicate playlists.

  • Video titles and descriptions are treated as untrusted. Control and bidi characters are stripped, text is truncated, and the agent is told to treat it as data, not instructions.

  • Revoke access at any time with logout or at https://myaccount.google.com/permissions.

See SECURITY.md for how to report vulnerabilities.

Development

npm test          # builds and runs unit + end-to-end tests (YouTube API is mocked)

Try it with the MCP Inspector:

npx @modelcontextprotocol/inspector node dist/index.js

License

MIT

Available Tools

8 tools
add_videos_to_playlistAdd videos to a playlistA
Idempotent

Add videos to an existing playlist owned by the user; videos already in it are skipped. WRITES TO THE USER'S ACCOUNT: only after explicit approval. Costs 50 units per added video.

Inputs: confirm (required), video_ids (required), playlist_id (required).

create_playlistCreate playlist on YouTubeA

Create the previewed playlist in the user's YouTube account and add its videos. WRITES TO THE USER'S ACCOUNT: call only after the user explicitly approved the preview for this draft_id. Each draft can be created once. Costs 50 + 50 per video quota units.

Inputs: confirm (required), draft_id (required).

get_playlist_itemsGet playlist itemsA
Read-only

List the videos in one of the user's playlists (1 quota unit per 50 videos). Read-only.

Inputs: playlist_id (required).

get_statusAuth & quota statusA
Read-only

Show whether YouTube access is configured and how much of today's API quota this server has used. Costs no quota.

Inputs: no named parameters.

list_my_playlistsList my playlistsB
Read-only

List playlists in the authorized YouTube account (50 per page, 1 quota unit). Read-only.

Inputs: page_token.

preview_playlistPreview playlistA
Read-only

Build (or rebuild) a numbered playlist preview from a search. Exclusions are remembered across calls for the same search_id. Show the returned markdown to the user and ask for approval or changes before create_playlist. Read-only, costs no quota.

Inputs: title (required), search_id (required), privacy, sort_by, +10 more.

remove_videos_from_playlistRemove videos from a playlistA
DestructiveIdempotent

Remove videos from one of the user's playlists (all occurrences). DESTRUCTIVE, WRITES TO THE USER'S ACCOUNT: only after explicit approval. Costs 50 units per removed item.

Inputs: confirm (required), video_ids (required), playlist_id (required).

search_videosSearch & score YouTube videosA
Read-only

Search YouTube for a topic, collect 10–100 candidate videos, drop Shorts/live/low-view videos and score each 0–100 (popularity incl. views-per-day, like rate, comment rate, optional recency). Read-only. Costs 100 quota units per 50 candidates (+1 per 50 for statistics). Afterwards, review titles/descriptions for relevance and call preview_playlist.

Inputs: query (required), order, language, min_views, +14 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool maps to a distinct stage or resource: search, preview, create, list, inspect items, add, remove, and status. The overlapping-looking pair (create_playlist vs add_videos_to_playlist) is clearly separated by descriptions—one builds a new playlist from an approved draft, the other appends to an existing one—and read-only vs write operations are explicitly flagged.

    Naming Consistency5/5

    All eight tools use snake_case verb_noun form (search_videos, create_playlist, add_videos_to_playlist, remove_videos_from_playlist, get_status). The only minor quirk is the possessive in list_my_playlists, which still fits the pattern and is readable.

    Tool Count5/5

    Eight tools is well-scoped for a playlist workflow: search, preview, create, list, inspect, mutate membership, and check quota/auth status. No tool feels redundant or gratuitous.

    Completeness3/5

    The core discover→preview→create→manage pipeline is covered, including add/remove of videos. However, there is no way to delete a playlist, rename/update an existing playlist, or reorder items, which are notable lifecycle gaps that leave agents at a dead end for cleanup or editing.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers