YouTube Shorts & Instagram Reels MCP Server

YouTube Shorts & Instagram Reels MCP Server

Enables automated posting of videos to YouTube Shorts and Instagram Reels with OAuth 2.0 authentication, file validation, and comprehensive video processing capabilities. Provides MCP-compatible tools for seamless social media video uploads through a FastAPI server.

Category
Visit Server

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

  1. Install dependencies:
pip install -r requirements.txt
  1. Configure credentials:
cp .env.example .env
# Edit .env with your API credentials (see setup sections below)
  1. Start the server:
python main.py
  1. Test the API:
  • 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

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

  1. 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)
  2. Get OAuth Tokens:

    • Use Google OAuth 2.0 Playground
    • Configure with your Client ID and Secret
    • Select https://www.googleapis.com/auth/youtube.upload scope
    • Complete OAuth flow and get access_token + refresh_token

Instagram API Setup

  1. Facebook Developer Account:

  2. Instagram Business Account:

    • Connect your Instagram Business/Creator account to a Facebook Page
    • Generate access token with proper permissions
    • Get your Instagram User ID
  3. 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,webm

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: 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.py

Error 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

  1. YouTube Authentication Errors

    • Verify OAuth credentials are correct
    • Check if access token has expired (auto-refreshed)
    • Ensure YouTube Data API v3 is enabled
  2. 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.)
  3. 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.py

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

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=60

Error 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.py

Testing 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

  1. YouTube Authentication Errors

    • Verify OAuth credentials are correct
    • Check if access token has expired
    • Ensure YouTube Data API v3 is enabled
  2. Instagram Upload Failures

    • Verify Instagram Business/Creator account is linked
    • Check access token permissions
    • Ensure video meets Instagram requirements
  3. 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.py

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

Support

For issues and questions:

  • Check the troubleshooting section
  • Review API documentation
  • Open an issue on GitHub

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured