English | 简体中文
This project automates video generation and uploading to multiple platforms:
- YouTube (Data API v3)
- Instagram Reels (Graph API)
- Chinese platforms: Xiaohongshu/小红书 (XHS), Douyin, Toutiao
- Optional AI generation for video topics and scripts
New: Native support for Xiaohongshu uploads via MCP (Model Context Protocol) using the official MCP SDK and the open-source xiaohongshu-mcp server.
Reference: https://github.com/xpzouying/xiaohongshu-mcp
- OAuth 2.0 for YouTube and Instagram
- Automated video generation pipeline (topic → script → voice → render)
- Upload to YouTube, Instagram, and Chinese platforms
- Xiaohongshu (XHS) via MCP SDK (fast, reliable, Claude-compatible transport)
- Environment-based configuration (.env.development, .env.production)
- Email notifications on successful uploads
- Python 3.10+ recommended
- macOS, Windows, or Linux
Install Python dependencies:
pip install -r requirements.txtInstall Playwright browsers if you plan to upload via non-MCP browser automation (optional):
python -m playwright install chromiumThis project uses separate env files based on ENV:
.env.development(default).env.production
Set which file to load by exporting ENV:
# macOS/Linux
export ENV=production
# Windows (PowerShell)
$env:ENV = "production"- OPEN_AI_KEY
- IG_USER_ID, IG_ACCESS_TOKEN (Instagram Upload)
- SMTP credentials if using email notifications
See example.env for guidance and copy values into .env.development or .env.production.
Add these to your env file or export them before running:
XHS_MCP_ENABLED=true— enable MCP mode for XHSXHS_MCP_SERVER_URL=http://<mcp-host>:18060/mcp— MCP HTTP endpointXHS_MCP_VIDEO_DIR=...— absolute directory path on the MCP server where videos are storedHEADLESS=false— optional; iffalse, non-MCP browser automation can show a browser window
Example (Windows MCP host):
set "XHS_MCP_ENABLED=true"
set "XHS_MCP_SERVER_URL=http://192.168.1.9:18060/mcp"
set "XHS_MCP_VIDEO_DIR=C:\\Users\\jack\\Python-Apps\\youtube-uploader\\downloaded_videos\\pending_upload"Example (macOS/Linux shell):
export XHS_MCP_ENABLED=true
export XHS_MCP_SERVER_URL=http://192.168.1.9:18060/mcp
export XHS_MCP_VIDEO_DIR="/mnt/shared/pending_upload" # path as seen by the MCP serverImportant: XHS_MCP_VIDEO_DIR must be a path that exists on the MCP server host. The app downloads the generated video directly into that folder so the MCP server can access it instantly.
From the project root:
# English video: generate + YouTube + Instagram (depending on env flags)
python main.py --language en
# Chinese video: generate + upload to Chinese platforms (XHS via MCP if enabled)
python main.py --language zhWindows helper for Chinese uploads (uses MCP by default and maps paths correctly):
run_cn.batsets the required env vars and runspython main.py --language zh.
This project integrates with the xiaohongshu-mcp server using the official MCP Python SDK.
How it works:
- The app generates your video.
- If MCP mode is enabled, the video is downloaded directly into
XHS_MCP_VIDEO_DIR(a folder on the MCP server host). - The uploader calls the MCP tool
publish_with_videowith the server-side file path. - The MCP server automates the XHS web upload.
- Deploy the server: https://github.com/xpzouying/xiaohongshu-mcp
- Start it with
headless=falseduring debugging to see the browser. - Log in to Xiaohongshu once in that browser session.
- Confirm the server is reachable at
http://<host>:18060/mcp.
Run the MCP test script (path must exist on the MCP server):
python test_mcp_upload.py "C:\\Users\\jack\\Python-Apps\\youtube-uploader\\downloaded_videos\\pending_upload\\example.mp4"The script will:
- Connect to the MCP server
- Verify login (
check_login_status) - Attempt a publish using
publish_with_video
- Browser not visible: ensure the MCP server was started with
headless=false. - "Upload button not present": start with
headless=falseand watch the automation; element locators may need updating on the MCP server side. - Slow upload (much slower than manual): ensure the MCP host has good network and disk performance. Keep the video file on the same machine (we already do by writing into
XHS_MCP_VIDEO_DIR). Disable VPN/Proxy and try during off-peak hours. - Timeout: our client uses a 15-minute publish timeout. If your network is slow, increase it in
platforms/xhs/uploader_mcp_final.pyif needed.
We adjusted dependency versions to align the MCP SDK with httpx/anyio/pydantic:
- httpx:
>=0.27.1,<0.28 - anyio:
>=4.6,<5 - mcp SDK:
>=1.16.0,<2.0 - pydantic:
>=2.10.1,<3
Install:
pip install -r requirements.txtIf Playwright is used by your non-MCP uploaders, install the Chromium runtime:
python -m playwright install chromiummain.py— orchestrates generation and uploads; maps paths for MCP if enabledmain_cn.py— async upload entry for Chinese platformsplatforms/xhs/uploader_mcp_final.py— MCP-based XHS uploader using official SDKtest_mcp_upload.py— test harness for MCP uploadrun_cn.bat— Windows helper to run Chinese/MCP workflowdownloaded_videos/— local downloads (non-MCP) or intermediate files
- Do not commit
.env.*files or secrets - Use separate
.env.developmentand.env.production - Rotate API keys regularly
- Google YouTube Data API, Facebook Graph API
- Chinese platform uploader references from https://github.com/aceliuchanghong/bili_douyin_xhs_uploader
- Xiaohongshu MCP server: https://github.com/xpzouying/xiaohongshu-mcp
MIT. See LICENSE.