Supports Cloudinary as a file hosting service for temporary video storage required by Instagram API uploads
Uses Facebook Developer platform for Instagram API access and managing Instagram Business account connections
Integrates with Google Cloud Console for YouTube API credentials management and OAuth 2.0 setup
Provides direct upload capabilities to Instagram Reels with caption support and Instagram Graph API integration
Enables automated uploading of videos to YouTube with support for titles, descriptions, tags, and OAuth 2.0 authentication
Automatically detects and uploads short-form videos (under 60 seconds) to YouTube Shorts with optimized formatting
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 Shorts & Instagram Reels MCP Serverupload my latest workout video to YouTube Shorts with title 'Morning Routine'"
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 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
Related MCP server: Instagram Video Downloader MCP Server
Quick Start
Install dependencies:
pip install -r requirements.txtConfigure credentials:
cp .env.example .env
# Edit .env with your API credentials (see setup sections below)Start the server:
python main.pyTest the API:
Visit http://localhost:8000/docs for interactive API documentation
Use the
/upload/youtubeand/upload/instagramendpointsAccess MCP tools at http://localhost:8000/mcp
API Endpoints
Upload to YouTube Shorts
POST /upload/youtube
Content-Type: multipart/form-data
file: <video_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: <video_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:
Configure with your Client ID and Secret
Select
https://www.googleapis.com/auth/youtube.uploadscopeComplete OAuth flow and get access_token + refresh_token
Instagram API Setup
Facebook Developer Account:
Go to Facebook Developers
Create a new app (Business type)
Add Instagram Graph API product
Instagram Business Account:
Connect your Instagram Business/Creator account to a Facebook Page
Generate access token with proper permissions
Get your Instagram User ID
File Hosting (Required):
Instagram requires publicly accessible video URLs
Configure AWS S3, Cloudinary, or custom hosting in .env
Videos are temporarily uploaded to hosting service before Instagram API call
Configuration
Environment Variables
Copy .env.example to .env and configure:
# YouTube API Credentials
YOUTUBE_CLIENT_ID=your_client_id.apps.googleusercontent.com
YOUTUBE_CLIENT_SECRET=GOCSPX-your_client_secret
YOUTUBE_ACCESS_TOKEN=ya29.your_access_token
YOUTUBE_REFRESH_TOKEN=1//your_refresh_token
# Instagram API Credentials
INSTAGRAM_ACCESS_TOKEN=IGAAyour_instagram_token
INSTAGRAM_APP_ID=your_app_id
INSTAGRAM_APP_SECRET=your_app_secret
INSTAGRAM_USER_ID=your_user_id
# Server Configuration
HOST=0.0.0.0
PORT=8000
DEBUG=False
# File Upload Configuration
MAX_FILE_SIZE_MB=100
ALLOWED_VIDEO_EXTENSIONS=mp4,mov,avi,mkv,webmFile Requirements
Supported Formats
Video: MP4, MOV, AVI, MKV, WebM
Max Size: 100MB (configurable)
Duration: Recommended under 60 seconds for optimal Shorts detection
YouTube Shorts Criteria
Videos under 60 seconds are automatically tagged as Shorts
Vertical or square aspect ratios work best
Resolution: 1080x1920 (9:16) recommended
Instagram Reels Criteria
Duration: 3-90 seconds
Aspect ratio: 9:16 (vertical) recommended
Resolution: 1080x1920 recommended
Testing
Test the Server
# Test health endpoint
curl http://localhost:8000/health
# Test YouTube upload
curl -X POST "http://localhost:8000/upload/youtube" \
-F "file=@test_video.mp4" \
-F "title=Test Video" \
-F "description=Test Description" \
-F "tags=test,api"
# Test Instagram upload
curl -X POST "http://localhost:8000/upload/instagram" \
-F "file=@test_video.mp4" \
-F "caption=Test reel #test"Run Test Suite
python test_server.pyError Handling
The server provides detailed error responses:
{
"success": false,
"error": "File too large. Maximum size is 100MB"
}Common error scenarios:
Invalid file format
File too large
Authentication failures
API rate limits
Network timeouts
Troubleshooting
Common Issues
YouTube Authentication Errors
Verify OAuth credentials are correct
Check if access token has expired (auto-refreshed)
Ensure YouTube Data API v3 is enabled
Instagram Upload Failures
Verify Instagram Business/Creator account is linked
Check access token permissions
Ensure video meets Instagram requirements
Configure file hosting (AWS S3, Cloudinary, etc.)
File Upload Issues
Check file size limits
Verify file format is supported
Ensure sufficient disk space for temporary files
Logs and Debugging
Enable debug mode for detailed logging:
DEBUG=True python main.pySecurity Considerations
Store credentials in environment variables, never in code
Use HTTPS in production
Implement rate limiting
Validate all file uploads
Monitor API usage quotas
License
MIT License - see LICENSE file for details.
File Requirements
Supported Formats
Video: MP4, MOV, AVI, MKV, WebM
Max Size: 100MB (configurable)
Duration: Recommended under 60 seconds for optimal Shorts detection
YouTube Shorts Criteria
Videos under 60 seconds are automatically tagged as Shorts
Vertical or square aspect ratios work best
Resolution: 1080x1920 (9:16) recommended
Instagram Reels Criteria
Duration: 15-90 seconds
Aspect ratio: 9:16 (vertical) recommended
Resolution: 1080x1920 recommended
Configuration
Environment variables can be customized:
# Server Configuration
HOST=0.0.0.0
PORT=8000
DEBUG=False
# File Upload Configuration
MAX_FILE_SIZE_MB=100
ALLOWED_VIDEO_EXTENSIONS=mp4,mov,avi,mkv,webm
# API Rate Limiting
RATE_LIMIT_REQUESTS_PER_MINUTE=60Error Handling
The server provides detailed error responses:
{
"success": false,
"error": "File too large. Maximum size is 100MB"
}Common error scenarios:
Invalid file format
File too large
Authentication failures
API rate limits
Network timeouts
Security Considerations
Store credentials in environment variables, never in code
Use HTTPS in production
Implement rate limiting
Validate all file uploads
Monitor API usage quotas
Development
Running in Development Mode
DEBUG=True python main.pyTesting the API
# Test health endpoint
curl http://localhost:8000/health
# Test YouTube upload
curl -X POST "http://localhost:8000/upload/youtube" \
-F "file=@test_video.mp4" \
-F "title=Test Video" \
-F "description=Test Description" \
-F "tags=test,api"Troubleshooting
Common Issues
YouTube Authentication Errors
Verify OAuth credentials are correct
Check if access token has expired
Ensure YouTube Data API v3 is enabled
Instagram Upload Failures
Verify Instagram Business/Creator account is linked
Check access token permissions
Ensure video meets Instagram requirements
File Upload Issues
Check file size limits
Verify file format is supported
Ensure sufficient disk space for temporary files
Logs and Debugging
Enable debug mode for detailed logging:
DEBUG=True python main.pyLicense
MIT License - see LICENSE file for details.
Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests
Submit a pull request
Support
For issues and questions:
Check the troubleshooting section
Review API documentation
Open an issue on GitHub