#!/usr/bin/env python3
"""
Diagnostic script for the Enhanced Image Analysis MCP Server
"""
import sys
import os
from pathlib import Path
def check_dependencies():
print("π Enhanced Image Analysis MCP Server Diagnostics")
print("=" * 50)
# Python info
print(f"π Python Version: {sys.version}")
print(f"π Python Executable: {sys.executable}")
print(f"π Current Directory: {os.getcwd()}")
print()
# Check MCP
try:
import mcp
print("β
MCP library: Available")
except ImportError as e:
print(f"β MCP library: Not found ({e})")
print(f" Install with: {sys.executable} -m pip install mcp")
# Check PIL/Pillow
try:
from PIL import Image
print("β
PIL/Pillow library: Available")
# Test basic functionality
try:
# Create a small test image in memory
test_img = Image.new('RGB', (100, 100), color='red')
print("β
PIL basic functionality: Working")
except Exception as e:
print(f"β οΈ PIL basic functionality: Error ({e})")
except ImportError as e:
print(f"β PIL/Pillow library: Not found ({e})")
print(f" Install with: {sys.executable} -m pip install Pillow")
print()
# Check server file
server_path = Path("/Users/anthonyturner/MCPs/image-analysis-server/enhanced_image_analysis_server.py")
if server_path.exists():
print(f"β
Server file: Found at {server_path}")
else:
print(f"β Server file: Not found at {server_path}")
# Check test directory
pictures_dir = Path("/Users/anthonyturner/Pictures")
if pictures_dir.exists():
# Count image files
image_count = len([f for f in pictures_dir.iterdir() if f.suffix.lower() in {'.jpg', '.jpeg', '.png', '.gif', '.bmp', '.tiff', '.webp'}])
print(f"β
Test directory: Found {image_count} images in {pictures_dir}")
else:
print(f"β οΈ Test directory: Pictures folder not found")
print()
# Test server import
try:
sys.path.append(str(server_path.parent))
from enhanced_image_analysis_server import EnhancedImageAnalysisServer
print("β
Server import: Successful")
# Test server initialization
server = EnhancedImageAnalysisServer()
print("β
Server initialization: Successful")
# Test basic functionality
if pictures_dir.exists():
images = server.get_image_files(pictures_dir, False)
print(f"β
Image detection: Found {len(images)} images")
except ImportError as e:
print(f"β Server import: Failed ({e})")
except Exception as e:
print(f"β Server functionality: Error ({e})")
print()
print("π― **RECOMMENDATIONS:**")
# Check if all dependencies are available
mcp_available = True
pil_available = True
try:
import mcp
except ImportError:
mcp_available = False
try:
from PIL import Image
except ImportError:
pil_available = False
if mcp_available and pil_available:
print("β
All dependencies are installed!")
print("π Server should work properly in Claude Desktop")
print("π‘ If still having issues, restart Claude Desktop completely")
elif mcp_available and not pil_available:
print("β οΈ MCP is installed but Pillow is missing")
print(f"π¦ Run: {sys.executable} -m pip install Pillow")
print("π§ Server will work with limited functionality until Pillow is installed")
elif not mcp_available and pil_available:
print("β οΈ Pillow is installed but MCP is missing")
print(f"π¦ Run: {sys.executable} -m pip install mcp")
else:
print("β Both MCP and Pillow are missing")
print(f"π¦ Run: {sys.executable} -m pip install mcp Pillow")
print()
print("π§ **TROUBLESHOOTING:**")
print("1. If using Homebrew Python, try: /opt/homebrew/bin/python3 -m pip install mcp Pillow")
print("2. If using system Python, try: /usr/bin/python3 -m pip install mcp Pillow")
print("3. Update Claude config to use the correct Python path")
print("4. Restart Claude Desktop after installing dependencies")
if __name__ == "__main__":
check_dependencies()