YouTube Uploader MCP Server CLI OAuth2 Token Management
Manage YouTube uploads via MCP server CLI with OAuth2 authentication, automated access and refresh token handling, and a modular Go package structure.
npx -y @anwerj/youtube-uploader-mcpOverview
This MCP (Model Context Protocol) server CLI provides a lightweight, developer-friendly way to manage YouTube uploads and OAuth2 credentials. It wraps the YouTube Data API OAuth2 flow in a small HTTP service and command-line tool so you can obtain, persist, and refresh access tokens automatically — without embedding long-lived secrets in your application code.
The project is implemented in Go with a modular package layout so you can either run the standalone CLI/server or import the authentication and token-management components into other Go services. The server exposes endpoints for initiating authorization, exchanging codes, and serving refreshed access tokens to a trusted client or downstream uploader process, making automated uploads and long-running integrations easier to manage.
Features
- OAuth2 Authorization Code flow for Google / YouTube Data API
- Automatic handling and refreshing of access and refresh tokens
- CLI to run an MCP-compatible server for token management
- Token persistence to disk (JSON or other configurable store)
- Modular Go packages suitable for embedding in other applications
- Minimal HTTP endpoints for initiating and completing OAuth flows
- Local development friendly (open browser/CLI authorization flow)
Installation / Configuration
Install the CLI using Go (Go 1.18+ recommended):
# Install the server CLI (adjust command path if project layout differs)
Alternatively, clone and build locally:
Typical environment variables and configuration:
# Environment variables (example)
Minimal configuration file (JSON example):
Start the server (example flags — adjust to your build/CLI):
When you visit the server’s authorization endpoint (e.g., http://localhost:8080/auth), it will redirect you to Google’s consent screen. After consenting, the server exchanges the code for access and refresh tokens and stores them to the configured token store.
Available Resources
- GitHub repository: https://github.com/anwerj/youtube-uploader-mcp
- Command-line server (mcp-server) — run, authorize, and manage tokens
- Go modules/packages for embedding:
- auth/token manager: obtain, refresh, persist tokens
- http/server: lightweight endpoints for OAuth initiation and callback handling
Example of embedding the token manager (pseudocode):
import "github.com/anwerj/youtube-uploader-mcp/pkg/auth"
// create manager with config
mgr := auth.NewManager(auth.Config)
// get a valid access token (refreshes automatically)
token, err := mgr.GetAccessToken(ctx, "default-profile")
Use Cases
- Continuous video processing: a backend pipeline transcodes videos and uses the MCP server to obtain a valid YouTube access token at upload time without storing refresh tokens inside the pipeline.
- Local development and testing: developers authorize a local account once via the CLI/server; the stored refresh token enables repeated uploads from dev tools and scripts.
- Microservice integration: embed the Go token manager into a microservice that needs ephemeral access tokens; the service delegates refresh logic to the library and reads tokens from a shared token store.
- CI/CD pipelines: obtain short-lived tokens for a job that uploads artifacts to a YouTube channel; the CI job requests a token from the MCP server instead of keeping long-lived credentials in CI secrets.
Configuration Reference
| Option | Description | Example |
|---|---|---|
| client_id | Google OAuth2 client ID | your-client-id.apps.googleusercontent.com |
| client_secret | Google OAuth2 client secret | your-client-secret |
| redirect_url | Authorized redirect URI for OAuth2 flow | http://localhost:8080/oauth2/callback |
| token_store | File path where tokens are persisted | ./tokens.json |
| listen_addr | HTTP address for the local MCP server | :8080 |
Notes and Best Practices
- Use Google API Console to create OAuth2 credentials and configure redirect URIs for local and production environments.
- Protect your token store file (permissions and encryption) because it contains refresh tokens that grant long-term access.
- For production, consider running the server behind TLS and restricting access to the token endpoints to trusted services.
- Review Google’s OAuth2 and YouTube API quotas and scopes; request only the scopes required for uploads (e.g., youtube.upload).
For full source, issues, and examples, see the project on GitHub: https://github.com/anwerj/youtube-uploader-mcp.