|
|
#!/bin/bash |
|
|
|
|
|
# MCP Image Recognition Server Startup Script |
|
|
# This script sets up the environment and starts the server |
|
|
|
|
|
set -e # Exit on error |
|
|
|
|
|
# Get the directory where this script is located |
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
|
|
cd "$SCRIPT_DIR" |
|
|
|
|
|
echo "🚀 Starting MCP Image Recognition Server..." |
|
|
echo "📁 Working directory: $SCRIPT_DIR" |
|
|
|
|
|
# Check if virtual environment exists |
|
|
if [ ! -d "venv" ]; then |
|
|
echo "📦 Virtual environment not found. Creating..." |
|
|
python3 -m venv venv |
|
|
echo "✅ Virtual environment created" |
|
|
fi |
|
|
|
|
|
# Activate virtual environment |
|
|
echo "🔧 Activating virtual environment..." |
|
|
source venv/bin/activate |
|
|
|
|
|
# Check if dependencies are installed |
|
|
if ! python -c "import fastmcp" 2>/dev/null; then |
|
|
echo "📥 Installing dependencies..." |
|
|
pip install -q -r requirements.txt |
|
|
echo "✅ Dependencies installed" |
|
|
else |
|
|
echo "✅ Dependencies already installed" |
|
|
fi |
|
|
|
|
|
# Check for OpenAI API key |
|
|
if [ -z "$OPENAI_API_KEY" ] || [ "$OPENAI_API_KEY" = "your-openai-api-key-here" ]; then |
|
|
echo "⚠️ Warning: OPENAI_API_KEY not set or using placeholder" |
|
|
echo " Server will run with basic image metadata only" |
|
|
echo " To enable AI descriptions, set OPENAI_API_KEY environment variable" |
|
|
else |
|
|
echo "✅ OpenAI API key configured" |
|
|
fi |
|
|
|
|
|
# Start the server |
|
|
echo "🎯 Starting server..." |
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
|
|
python -m image_recognition_server.server |