youtube-stats-mcp
Provides read-only access to YouTube channel statistics, recent uploads, upload schedule, and individual video stats via the YouTube Data API v3.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@youtube-stats-mcpShow me my channel's stats and recent uploads."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
youtube-stats-mcp
A small, self-hosted MCP server that gives any MCP-compatible AI assistant (Claude, Claude Desktop / Cowork, or any other MCP client) read access to your own YouTube channel's stats and upload schedule.
It runs entirely on your own machine via Docker. Your Google OAuth refresh token stays in a local file that's never committed to git and never leaves your container. Anyone can clone this repo, connect it to their own Google account, and start querying their own channel — no shared credentials, no central server, no data collected by anyone but you.
Features
Five tools, all backed by the YouTube Data API v3:
Tool | Description |
| Profile + stats (subs/views/video count) for the authenticated channel |
| Public stats for any channel, or the authenticated one if omitted |
| Most recent published videos, each with view/like/comment counts and duration |
| Upcoming scheduled/private uploads and premieres/live streams not yet public |
| Views/likes/comments and metadata for a specific video |
The server uses the youtube.readonly scope only — it can read your
channel's data but cannot upload, edit, delete, or change anything.
Related MCP server: youtube-mcp
Prerequisites
Docker and Docker Compose (to run the server)
Node.js 18+ (only needed for the one-time OAuth setup script — the server itself runs in Docker)
A Google account that owns or manages the YouTube channel you want to track
Quick start
git clone https://github.com/YOUR_GITHUB_USERNAME/youtube-stats-mcp.git
cd youtube-stats-mcp
npm installCreate a Google Cloud OAuth client — one-time setup, see the walkthrough below. You'll end up with a Client ID and Client Secret.
Configure your credentials:
cp .env.example .envOpen
.envand fill inYOUTUBE_CLIENT_ID/YOUTUBE_CLIENT_SECRETfrom step 1.Authorize your Google account:
npm run setupThis prints a Google consent URL. Open it in the browser signed into the YouTube account you want to track, approve access, and the script saves
secrets/youtube_token.jsonfor you. That folder is gitignored — it never gets committed.Build and run the server:
docker compose up -d --buildConfirm it's up:
curl http://localhost:8787/ # {"ok":true,"name":"youtube-stats-mcp"}Connect it to your MCP client — see "Connecting it to Claude / Cowork / any MCP client" below.
Create a Google Cloud OAuth client
You need your own OAuth client because this scope (youtube.readonly) is
tied to a specific Google Cloud project and can't be shared across users.
This takes about five minutes and is free.
Go to the Google Cloud Console and create a new project (or pick an existing one).
APIs & Services > Library — search for YouTube Data API v3 and click Enable.
APIs & Services > OAuth consent screen:
User type: External (unless you have a Google Workspace org and want Internal)
Fill in an app name, your email as support contact, and your email again as developer contact
Scopes: add
.../auth/youtube.readonlyTest users: add the Google account whose channel you're tracking
Save — you can leave this in "Testing" status, but read "Why this keeps happening" below before you do
APIs & Services > Credentials > Create Credentials > OAuth client ID:
Application type: Desktop app (important — this is what lets the setup script use an arbitrary local port without pre-registering an exact redirect URI)
Name it whatever you like
Click Create, then copy the Client ID and Client Secret into your
.envfile
Connecting it to Claude / Cowork / any MCP client
The server speaks MCP over Streamable HTTP at:
http://localhost:8787/mcpAdd it as a custom/local MCP server in your client's settings — the exact
menu depends on the app (look for "Add custom connector" / "Add MCP server").
Once connected, tool names will appear prefixed by however your client names
the connection, e.g. mcp__youtube-stats-mcp__list_my_channels.
Multi-channel / brand accounts
The token only grants access to the channel tied to the Google account you authorized in step 3 above. If you (or someone using this repo) manage separate brand-account channels, each one needs its own:
OAuth authorization run (
npm run setup, signed into that brand account)Token file (change
TOKEN_PATHto a different file)Container/port (copy
docker-compose.yml, give it a different service name, host port, andTOKEN_PATH)
Re-authorizing (invalid_grant errors)
If a tool call fails with invalid_grant, your refresh token has expired or
been revoked. Fix it:
npm run reauthThis reuses the client ID/secret already saved in
secrets/youtube_token.json, opens a fresh consent URL, and overwrites the
token file. Then restart the server:
docker compose up -d --buildWhy this keeps happening (invalid_grant)
If your Google Cloud project's OAuth consent screen is still in Testing
publishing status, Google expires refresh tokens for it after 7 days —
no exceptions. This is by far the most common cause of recurring
invalid_grant errors on a self-hosted setup like this one. Two ways to stop
the cycle:
Move the consent screen to "In production" (OAuth consent screen > Publish App). For a personal, narrow-scope (
youtube.readonly) app this does not require Google's formal verification review in practice — tokens then last until you explicitly revoke them or leave them unused for 6 months.Otherwise, budget for running
npm run reauthweekly while in Testing mode.
Other things that produce auth errors, and what they mean:
Error | Likely cause |
| Your OAuth client isn't type "Desktop app" — recreate it as that type, or add the exact printed redirect URI to "Authorized redirect URIs" on a Web app client |
| Your Google account isn't listed as a Test user on the OAuth consent screen (while it's in Testing status) |
| Refresh token expired (see above) or was revoked at myaccount.google.com/permissions |
No | Google only issues a new one on first consent per account+app; remove the app's access at myaccount.google.com/permissions and re-run |
Security
Local-only by default. The server binds to all interfaces on the port you publish, but
docker-compose.ymlonly publishes it to your host'slocalhostunless you change that mapping yourself. Don't expose port 8787 to the public internet without also settingMCP_AUTH_TOKEN.Optional bearer-token auth. Set
MCP_AUTH_TOKENin.envto require a matchingAuthorization: Bearer <token>header on every/mcprequest — useful if you're reaching the server over Tailscale, ngrok, etc.Read-only scope.
youtube.readonlycannot upload, edit, or delete anything on your channel.Credentials never committed.
secrets/and.envare gitignored and excluded from the Docker build context (.dockerignore). Only.env.example(no real values) is tracked.Revoke access anytime at myaccount.google.com/permissions.
Runs as a non-root user inside the container (see
Dockerfile).
Development (without Docker)
npm install
npm startReads the same .env / secrets/youtube_token.json as the Docker setup.
Project structure
youtube-stats-mcp/
├── src/
│ └── index.js # MCP server + YouTube API calls
├── reauth.js # OAuth setup / re-auth script (npm run setup | reauth)
├── secrets/ # gitignored — holds youtube_token.json after setup
├── .env.example
├── docker-compose.yml
├── Dockerfile
└── package.jsonContributing
See CONTRIBUTING.md.
License
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceAn MCP server that allows Claude and other AI assistants to interact with the YouTube API, providing tools to search videos/channels and retrieve detailed information about them.Last updated311MIT
- AlicenseAqualityBmaintenanceMCP server for YouTube creator-ops — video metadata, comments, playlists, channel analytics, plus a ComfyUI bridge for AI thumbnail generation.Last updated1555MIT
- AlicenseAqualityCmaintenanceA local-first MCP server for inspecting and managing a creator-owned YouTube channel, using Google's official YouTube Data API v3 and Analytics API.Last updated1020MIT
- Alicense-qualityBmaintenanceA comprehensive MCP server providing YouTube transcript retrieval, video search, channel browsing, playlist extraction, and upload monitoring for AI agents.Last updated7MIT
Related MCP Connectors
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
An MCP server that gives your AI access to the source code and docs of all public github repos
YouTube MCP — wraps the YouTube Data API v3 (BYO API key)
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/UnpredictablePrashant/YoutubeMCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server