A Model Context Protocol (MCP) compatible FastAPI server that enables automated posting of videos to YouTube Shorts and Instagram Reels.
概览
A Model Context Protocol (MCP) compatible FastAPI server that enables automated posting of videos to YouTube Shorts and Instagram Reels. - 🎬 : Automatic detection and upload of short-form videos to YouTube - 📱 : Direct upload to Instagram Reels with caption support - 🔐 : Secure authentication for both platforms - 🛡️ : Comprehensive file type and size validation - 🔄 : Automatic OAuth token refresh for YouTube - 🎯 : Full MCP tool integration for seamless automation - ⚡ : High-performance async file handling - 📏 : Automatic video duration detection using ffprobe 4. : - Visit http://localhost:8000/docs for interactive API documentation - Use the /upload/youtube and /upload/instagram endpoints - Access MCP tools at http://localhost:8000/mcp The server exposes two MCP tools for programmatic access: 1. : - Go to Google Cloud Console - Create a new project or select existing one - Enable YouTube Data API v3 in the API Library - Create OAuth 2.0 credentials (Desktop application) 2.
README
以下为原文 README 节选,完整内容请查看原文。
YouTube Shorts & Instagram Reels MCP Server
A Model Context Protocol (MCP) compatible FastAPI server that enables automated posting of videos to YouTube Shorts and Instagram Reels.
Features
- 🎬 YouTube Shorts Upload: Automatic detection and upload of short-form videos to YouTube
- 📱 Instagram Reels Upload: Direct upload to Instagram Reels with caption support
- 🔐 OAuth 2.0 Authentication: Secure authentication for both platforms
- 🛡️ File Validation: Comprehensive file type and size validation
- 🔄 Token Refresh: Automatic OAuth token refresh for YouTube
- 🎯 MCP Compatible: Full MCP tool integration for seamless automation
- ⚡ Async Operations: High-performance async file handling
- 📏 Video Processing: Automatic video duration detection using ffprobe
Quick Start
- Install dependencies:
pip install -r requirements.txt
- Configure credentials:
cp .env.example .env
# Edit .env with your API credentials (see setup sections below)
- Start the server:
python main.py
- Test the API:
- Visit http://localhost:8000/docs for interactive API documentation
- Use the
/upload/youtubeand/upload/instagramendpoints - Access MCP tools at http://localhost:8000/mcp
API Endpoints
Upload to YouTube Shorts
POST /upload/youtube
Content-Type: multipart/form-data
file:
title: "My Amazing Short"
description: "Check out this cool video!"
tags: "shorts,viral,amazing"
Response:
{
"success": true,
"video_id": "dQw4w9WgXcQ",
"watch_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}
Upload to Instagram Reels
POST /upload/instagram
Content-Type: multipart/form-data
file:
caption: "Check out my new reel! #viral #reels"
Response:
{
"success": true,
"reel_id": "17841234567890123",
"permalink": "https://www.instagram.com/reel/ABC123def456/"
}
MCP Tool Usage
The server exposes two MCP tools for programmatic access:
post_to_youtube
await post_to_youtube(
title="My Video Title",
description="Video description",
tags=["tag1", "tag2", "tag3"],
video_path="/path/to/video.mp4"
)
post_to_instagram
await post_to_instagram(
caption="My reel caption #hashtag",
video_path="/path/to/video.mp4"
)
Prerequisites & Setup
YouTube API Setup
-
Google Cloud Console:
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable YouTube Data API v3 in the API Library
- Create OAuth 2.0 credentials (Desktop application)
-
Get OAuth Tokens:
- Use Google OAuth 2.0 Playground
- Configure with your Client ID and Secret
- Select
https://www.googleapis.com/auth/youtube.uploadscope - Complete OAuth flow and get access_token + refresh_token
Instagram API Setup
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →