#!/usr/bin/env python3
"""Setup script for MCP Video Analysis Server."""
import os
import sys
import subprocess
import platform
from pathlib import Path
import json
def print_banner():
"""Print welcome banner."""
print("""
ββββββββββββββββββββββββββββββββββββββββββββ
β π¬ MCP Video Analysis Server Setup π¬ β
ββββββββββββββββββββββββββββββββββββββββββββ
""")
def check_python_version():
"""Check Python version."""
print("π Checking Python version...")
version = sys.version_info
if version.major < 3 or (version.major == 3 and version.minor < 9):
print(f"β Python 3.9+ required. You have {version.major}.{version.minor}")
return False
print(f"β
Python {version.major}.{version.minor} detected")
return True
def check_command(command, install_hint):
"""Check if a command is available."""
print(f"π Checking {command}...")
try:
subprocess.run([command, "--version"], capture_output=True, check=False)
print(f"β
{command} is installed")
return True
except FileNotFoundError:
print(f"β {command} not found")
print(f" Install: {install_hint}")
return False
def check_ollama():
"""Check Ollama installation and models."""
print("\nπ Checking Ollama...")
# Check if Ollama is installed
try:
result = subprocess.run(["ollama", "--version"], capture_output=True, text=True)
print("β
Ollama is installed")
except FileNotFoundError:
print("β Ollama not found")
print(" Install from: https://ollama.ai")
return False
# Check if Ollama is running
try:
import httpx
response = httpx.get("http://localhost:11434/api/tags", timeout=5)
if response.status_code == 200:
print("β
Ollama is running")
# Check models
data = response.json()
models = {m["name"] for m in data.get("models", [])}
required = ["llava:latest", "llama2:latest"]
missing = [m for m in required if m not in models]
if missing:
print(f"β οΈ Missing models: {', '.join(missing)}")
print(" Install with:")
for model in missing:
print(f" ollama pull {model}")
return False
else:
print("β
All required models installed")
return True
else:
print("β Ollama is not responding")
print(" Start with: ollama serve")
return False
except Exception as e:
print("β Ollama is not running")
print(" Start with: ollama serve")
return False
def install_dependencies():
"""Install Python dependencies."""
print("\nπ¦ Installing Python dependencies...")
try:
subprocess.run([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"], check=True)
print("β
Dependencies installed")
return True
except subprocess.CalledProcessError:
print("β Failed to install dependencies")
return False
def create_directories():
"""Create necessary directories."""
print("\nπ Creating directories...")
dirs = [
"logs",
"video_data/originals",
"video_data/processed",
"video_data/index"
]
for dir_path in dirs:
Path(dir_path).mkdir(parents=True, exist_ok=True)
print("β
Directories created")
return True
def test_video_processing():
"""Test video processing with sample video."""
print("\nπ§ͺ Testing video processing...")
sample_video = Path("video_data/originals/sample_video.mp4")
if not sample_video.exists():
print("β οΈ Sample video not found")
print(" The sample video should have been downloaded during setup")
return False
print("β
Sample video found")
# Try importing our modules
try:
from src.storage.manager import StorageManager
from src.processors.video import VideoProcessor
print("β
Modules import successfully")
return True
except ImportError as e:
print(f"β Import error: {e}")
return False
def setup_claude_desktop():
"""Run Claude Desktop setup."""
print("\nπ€ Setting up Claude Desktop integration...")
try:
subprocess.run([sys.executable, "scripts/setup_claude_desktop.py"], check=True)
return True
except subprocess.CalledProcessError:
print("β Claude Desktop setup failed")
return False
def main():
"""Main setup function."""
print_banner()
checks = {
"Python version": check_python_version(),
"ffmpeg": check_command("ffmpeg", "brew install ffmpeg (macOS) or apt install ffmpeg (Linux)"),
"Dependencies": install_dependencies(),
"Directories": create_directories(),
"Ollama": check_ollama(),
"Modules": test_video_processing(),
}
# Summary
print("\n" + "="*50)
print("π Setup Summary:")
print("="*50)
all_passed = True
for check, passed in checks.items():
status = "β
" if passed else "β"
print(f"{status} {check}")
if not passed:
all_passed = False
if all_passed:
print("\nπ Setup complete! All checks passed.")
# Ask about Claude Desktop setup
response = input("\nWould you like to set up Claude Desktop integration? (y/n): ")
if response.lower() == 'y':
setup_claude_desktop()
print("\nπ Next steps:")
print("1. Make sure Ollama is running: ollama serve")
print("2. For Claude Desktop: Restart Claude to load the configuration")
print("3. For CLI usage: ./standalone_client/video_client.py --help")
print("\n㪠Try processing the sample video:")
print(" ./standalone_client/video_client.py process video_data/originals/sample_video.mp4")
else:
print("\nβ Setup incomplete. Please fix the issues above and run again.")
sys.exit(1)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\n\nSetup cancelled.")
sys.exit(0)