glam/mcp_servers/social_media/setup.sh

146 lines
4 KiB
Bash
Executable file

#!/bin/bash
# Social Media MCP Server - Setup Script (Poetry)
#
# This script sets up the development environment for Social Media MCP server using Poetry.
#
set -e # Exit on error
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "=============================================="
echo " Social Media MCP Server - Setup (Poetry)"
echo "=============================================="
echo ""
# Check for Poetry
echo "Checking Poetry installation..."
if command -v poetry &> /dev/null; then
POETRY_VERSION=$(poetry --version)
echo " Poetry $POETRY_VERSION found"
else
echo " ERROR: Poetry not found"
echo " Install with: curl -sSL https://install.python-poetry.org | python3 -"
exit 1
fi
# Check for Python 3.10+ (Poetry will manage this)
echo ""
echo "Checking Python version..."
if command -v python3 &> /dev/null; then
PYTHON_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
MAJOR=$(echo $PYTHON_VERSION | cut -d. -f1)
MINOR=$(echo $PYTHON_VERSION | cut -d. -f2)
if [ "$MAJOR" -ge 3 ] && [ "$MINOR" -ge 10 ]; then
echo " Python $PYTHON_VERSION found"
else
echo " ERROR: Python 3.10+ required, found $PYTHON_VERSION"
exit 1
fi
else
echo " ERROR: Python 3 not found"
exit 1
fi
# Install dependencies with Poetry
echo ""
echo "Installing dependencies with Poetry..."
poetry install --no-root
echo " Installed: httpx, mcp, yt-dlp, beautifulsoup4"
# Check for yt-dlp system installation (preferred for better codec support)
echo ""
echo "Checking yt-dlp installation..."
if command -v yt-dlp &> /dev/null; then
YTDLP_VERSION=$(yt-dlp --version)
echo " yt-dlp $YTDLP_VERSION found (system)"
else
echo " yt-dlp not found system-wide"
echo " Using Poetry-installed version (may have limited codec support)"
echo " For best results, install with: brew install yt-dlp"
fi
# Create .env template if it doesn't exist
echo ""
echo "Checking environment configuration..."
if [ -f ".env" ]; then
echo " .env file already exists"
else
cat > .env.example << 'EOF'
# YouTube API (optional - falls back to yt-dlp if not set)
YOUTUBE_API_KEY=
# LinkedIn (choose one method)
# Option 1: Session cookie (recommended)
LINKEDIN_COOKIE=
# Option 2: Email/Password (less reliable)
LINKEDIN_EMAIL=
LINKEDIN_PASSWORD=
# Facebook Graph API
FACEBOOK_ACCESS_TOKEN=
FACEBOOK_PAGE_ID=
FACEBOOK_API_VERSION=v19.0
# Instagram Graph API (via Facebook)
INSTAGRAM_ACCESS_TOKEN=
INSTAGRAM_BUSINESS_ACCOUNT_ID=
INSTAGRAM_API_VERSION=v19.0
EOF
echo " Created .env.example template"
echo " Copy to .env and fill in your credentials:"
echo " cp .env.example .env"
fi
# Test that server can start
echo ""
echo "Testing server import..."
poetry run python -c "import server" 2>/dev/null
if [ $? -eq 0 ]; then
echo " Server module imports successfully"
else
echo " WARNING: Server import failed. Check for missing dependencies."
fi
# Print summary
echo ""
echo "=============================================="
echo " Setup Complete!"
echo "=============================================="
echo ""
echo "Next steps:"
echo ""
echo "1. Configure credentials:"
echo " cp .env.example .env"
echo " # Edit .env with your API keys/tokens"
echo ""
echo "2. Test the server:"
echo " poetry run python server.py"
echo ""
echo "3. Add to your MCP client config (OpenCode/Claude Desktop)"
echo " See README.md for configuration examples"
echo ""
echo "Configured platforms:"
if [ -n "$YOUTUBE_API_KEY" ]; then
echo " - YouTube: API Key set"
else
echo " - YouTube: Not configured (will use yt-dlp fallback)"
fi
if [ -n "$LINKEDIN_COOKIE" ]; then
echo " - LinkedIn: Cookie set"
else
echo " - LinkedIn: Not configured"
fi
if [ -n "$FACEBOOK_ACCESS_TOKEN" ]; then
echo " - Facebook: Access token set"
else
echo " - Facebook: Not configured"
fi
if [ -n "$INSTAGRAM_ACCESS_TOKEN" ]; then
echo " - Instagram: Access token set"
else
echo " - Instagram: Not configured"
fi
echo ""