"""Test script to verify Zoho Timeline MCP installation."""
import sys
from pathlib import Path
def test_imports():
"""Test that all required packages can be imported."""
print("Testing imports...")
tests = {
"mcp": "MCP protocol library",
"PIL": "Pillow image library",
"mss": "Screenshot library",
"anthropic": "Anthropic API client",
}
failed = []
for module, description in tests.items():
try:
__import__(module)
print(f" ✓ {description}")
except ImportError as e:
print(f" ✗ {description}: {e}")
failed.append(module)
return len(failed) == 0
def test_tesseract():
"""Test Tesseract OCR installation."""
print("\nTesting Tesseract OCR...")
try:
import subprocess
result = subprocess.run(
["tesseract", "--version"],
capture_output=True,
text=True,
timeout=5
)
if result.returncode == 0:
version = result.stdout.split('\n')[0]
print(f" ✓ Tesseract found: {version}")
return True
else:
print(" ✗ Tesseract command failed")
return False
except FileNotFoundError:
print(" ✗ Tesseract not found in PATH")
print(" Install from: https://github.com/UB-Mannheim/tesseract/wiki")
return False
except Exception as e:
print(f" ✗ Error checking Tesseract: {e}")
return False
def test_api_key():
"""Test Anthropic API key."""
print("\nTesting Anthropic API key...")
import os
api_key = os.getenv("ANTHROPIC_API_KEY")
if not api_key:
print(" ✗ ANTHROPIC_API_KEY not set")
print(" Set with: setx ANTHROPIC_API_KEY 'your-key-here'")
return False
elif not api_key.startswith("sk-ant-"):
print(" ⚠ API key doesn't look valid (should start with 'sk-ant-')")
return False
else:
print(f" ✓ API key found (starts with {api_key[:10]}...)")
return True
def test_screenshot():
"""Test screenshot capture capability."""
print("\nTesting screenshot capture...")
try:
from zoho_timeline_mcp.screenshot import ScreenshotManager
manager = ScreenshotManager()
# Try to capture a screenshot
screenshot_id, filepath = manager.capture_screenshot()
if filepath.exists():
print(f" ✓ Screenshot captured: {filepath}")
# Clean up
filepath.unlink()
return True
else:
print(" ✗ Screenshot file not created")
return False
except Exception as e:
print(f" ✗ Screenshot capture failed: {e}")
return False
def test_module_import():
"""Test that the MCP server module can be imported."""
print("\nTesting MCP server module...")
try:
from zoho_timeline_mcp import ZohoTimelineMCPServer
print(" ✓ MCP server module imported successfully")
return True
except Exception as e:
print(f" ✗ Failed to import MCP server: {e}")
return False
def main():
"""Run all tests."""
print("=" * 60)
print("Zoho Timeline MCP Server - Installation Test")
print("=" * 60)
results = {
"Imports": test_imports(),
"Tesseract": test_tesseract(),
"API Key": test_api_key(),
"Module Import": test_module_import(),
"Screenshot": test_screenshot(),
}
print("\n" + "=" * 60)
print("Test Results")
print("=" * 60)
for test_name, passed in results.items():
status = "✓ PASS" if passed else "✗ FAIL"
print(f"{test_name:20} {status}")
all_passed = all(results.values())
print("\n" + "=" * 60)
if all_passed:
print("✓ All tests passed! You're ready to use the MCP server.")
print("\nNext step: Configure Claude Desktop")
print("See README.md for instructions")
else:
print("✗ Some tests failed. Please fix the issues above.")
print("\nSee README.md for troubleshooting help")
print("=" * 60)
return 0 if all_passed else 1
if __name__ == "__main__":
sys.exit(main())