YouTube MCP Server
Enables interaction with YouTube's Data API through MCP, providing tools for channel info, videos, playlists, captions, subscriptions, and more.
README
YouTube MCP Server
A Python Model Context Protocol (MCP) server that exposes YouTube Data API tools. Use it from MCP Inspector, Cursor, or any MCP client.
Tool reference: Composio YouTube Toolkit
Table of contents
- Project structure
- Prerequisites
- Installation
- Getting OAuth2 credentials
- Configuration (.env)
- Running the server
- MCP Inspector
- Cursor MCP config
- Tools overview
- Troubleshooting
Project structure
youtube mcp/
├── src/youtubemcp/
│ ├── config.py # OAuth2, .env, YouTube API client
│ ├── mcp.py # FastMCP instance
│ ├── main.py # Entry point
│ └── tools/ # Tool modules (channel, captions, playlists, etc.)
├── .env # Your credentials (create from .env.example)
├── .env.example # Template for .env
├── pyproject.toml
├── requirements.txt
├── run.py # Run server: python run.py
└── README.md
Prerequisites
- Python 3.10+
- Google account (for YouTube / OAuth2)
- uv (optional, for
uv run) or pip
Installation
Option A: Using pip
cd "d:\clg files\PROJECTS\youtube mcp"
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
Option B: Using uv
cd "d:\clg files\PROJECTS\youtube mcp"
uv sync
Getting OAuth2 credentials
Follow these steps to get Client ID and Client Secret from Google Cloud.
Step 1: Open Google Cloud Console
- Go to Google Cloud Console.
- Sign in with the Google account you want to use for YouTube.
Step 2: Create or select a project
- At the top, click the project dropdown (next to “Google Cloud”).
- Click New Project.
- Enter a name (e.g. YouTube MCP) and click Create.
- Select this project from the dropdown so it’s the active project.
Step 3: Enable YouTube Data API v3
- In the left menu: APIs & Services → Library
Or go to: APIs Library. - Search for YouTube Data API v3.
- Click it, then click Enable.
Step 4: Configure OAuth consent screen
- In the left menu: APIs & Services → OAuth consent screen.
- Choose External (unless you use Google Workspace and want Internal only).
- Click Create.
- App information
- App name: e.g.
YouTube MCP - User support email: your email
- Developer contact: your email
- App name: e.g.
- Click Save and Continue.
- Scopes
- Click Add or Remove Scopes.
- Filter or search for YouTube Data API v3.
- Add at least:
- View your YouTube account (
.../auth/youtube.readonly) - See, edit, and permanently delete your YouTube videos, ratings, comments and captions (
.../auth/youtube.force-ssl) - Manage your YouTube videos (
.../auth/youtube.upload) — needed for uploads and thumbnails
- View your YouTube account (
- Click Update → Save and Continue.
- Test users (required while app is in Testing)
- Click Add Users.
- Add the Gmail address you will use to sign in (e.g.
yourname@gmail.com). - Click Save and Continue.
- Click Back to Dashboard.
Step 5: Create OAuth 2.0 Client ID
- In the left menu: APIs & Services → Credentials.
- Click + Create Credentials → OAuth client ID.
- Application type: Desktop app.
- Name: e.g.
YouTube MCP desktop. - Click Create.
- In the popup, copy:
- Client ID (looks like
123456789-xxxx.apps.googleusercontent.com) - Client secret (looks like
GOCSPX-xxxxxxxxxxxxxxxx)
- Client ID (looks like
Keep these for the next section.
Configuration (.env)
-
Copy the example env file:
copy .env.example .env(On macOS/Linux:
cp .env.example .env) -
Open
.envand set your credentials:client_id=YOUR_CLIENT_ID.apps.googleusercontent.com client_secret=YOUR_CLIENT_SECRET -
Optional variables:
Variable Description oauth_redirect_uriRedirect URI (default: http://localhost)scopesComma-separated OAuth scopes (default includes readonly; add https://www.googleapis.com/auth/youtube.force-sslandhttps://www.googleapis.com/auth/youtube.uploadfor full features)Example for full access (read, write, upload, thumbnails):
scopes=https://www.googleapis.com/auth/youtube.readonly,https://www.googleapis.com/auth/youtube.force-ssl,https://www.googleapis.com/auth/youtube.upload -
First run: When you start the server, a browser window will open. Sign in with the same Google account you added as a test user and approve the requested permissions. The app will save tokens to
token.json(created automatically; do not commit it).
Running the server
From the project root:
python run.py
Or, if you use uv:
uv run run.py
The server runs over STDIO by default (for MCP Inspector and Cursor). It will wait for input; close with Ctrl+C when done.
MCP Inspector
Connect via STDIO (recommended)
-
Start MCP Inspector:
npx -y @modelcontextprotocol/inspector -
In the Inspector:
- Transport: STDIO
- Command:
uv(orpython) - Arguments:
run run.py(orrun.pyif Command ispython) - Ensure the working directory is the project root (where
run.pyand.envare).
-
Click Connect. The server starts; on first run, a browser may open for Google sign-in.
-
Call any tool (e.g. get_channel_id_by_handle with
@YouTube) to verify.
Cursor MCP config
Add the server to Cursor so it can call YouTube tools.
-
Open Cursor Settings → MCP (or edit your MCP config file).
-
Add a server entry, for example:
{ "mcpServers": { "youtube": { "command": "C:\\path\\to\\youtube mcp\\.venv\\Scripts\\python.exe", "args": ["C:\\path\\to\\youtube mcp\\run.py"], "env": { "YOUTUBE_CLIENT_ID": "YOUR_CLIENT_ID", "YOUTUBE_CLIENT_SECRET": "YOUR_CLIENT_SECRET" } } } }Replace
C:\\path\\to\\youtube mcpwith your actual project path. You can omitenvif.envis in the project root and Cursor runs from there. -
Restart Cursor or reload MCP; the YouTube tools should appear.
Tools overview
All tools return an object with data (object), error (string, optional), and successful (boolean).
| Tool | Description |
|---|---|
| get_channel_activities | Recent activities for a channel (uploads, playlists, likes). |
| get_channel_id_by_handle | Get channel ID from handle (e.g. @Google). |
| get_channel_statistics | Channel stats (subscribers, views, video count). |
| list_channel_videos | List videos from a channel. |
| list_captions | List caption tracks for a video (your videos). |
| download_caption_track | Download caption content by track ID (your videos). |
| list_user_playlists | Playlists owned by the authenticated user. |
| list_user_subscriptions | Channels the authenticated user is subscribed to. |
| subscribe_to_channel | Subscribe the authenticated user to a channel. |
| search_youtube | Search videos, channels, or playlists. |
| update_thumbnail | Set custom thumbnail from image URL (your videos). |
| update_video | Update video metadata (title, description, tags, privacy). |
| upload_video | Upload a video from a local file path. |
| video_details | Get video details (snippet, statistics, etc.) by video ID. |
Troubleshooting
"Access blocked" or "Error 403: access_denied"
- Your app is in Testing mode. Add your Google account under OAuth consent screen → Test users and try again.
"Request had insufficient authentication scopes"
- Add the needed scope to OAuth consent screen (e.g.
youtube.force-ssl,youtube.upload). - Delete
token.json, then run the server again and sign in to get a new token with the new scopes.
"The authenticated user doesn't have permissions to upload and set custom video thumbnails"
- Add scope Manage your YouTube videos (
youtube.upload) in the OAuth consent screen. - Delete
token.jsonand sign in again. - Ensure your YouTube channel is verified (e.g. phone verification in YouTube Studio → Settings → Channel).
"YouTube Data API v3 has not been used in project ... or it is disabled"
- In APIs Library, enable YouTube Data API v3 for the same project that has your OAuth client.
Invalid scope (e.g. scopes=https://... in error)
- In
.env, thescopesvalue must be only the comma-separated URLs, e.g.
scopes=https://www.googleapis.com/auth/youtube.readonly,https://www.googleapis.com/auth/youtube.force-ssl
Do not repeat the wordscopes=inside the value.
Token refresh
- Access tokens expire in about an hour. The server refreshes them automatically using
token.json. If you change scopes or get auth errors, deletetoken.jsonand sign in again.
.env and token.json location
- Both must be in the project root (same folder as
run.py). The server loads them from there.
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.