#!/usr/bin/env python3 """ Simple test script to verify the MCP Documentation Server works correctly. """ import json import sys import os def test_data_loading(): """Test that all data files can be loaded correctly.""" print("Testing data loading...") try: # Test chunks data with open('mcp_docs/index/chunks_md.json', 'r', encoding='utf-8') as f: chunks = json.load(f) print(f"[OK] Loaded {len(chunks)} chunks") # Test docs data with open('mcp_docs/index/docs_md.json', 'r', encoding='utf-8') as f: docs = json.load(f) print(f"[OK] Loaded {len(docs)} documents") # Note: FAISS index is no longer required for text-based search print("[INFO] Using text-based search (no FAISS index required)") print("\n[SUCCESS] All data files loaded successfully!") return True except Exception as e: print(f"[ERROR] Error loading data: {e}") return False def test_app_import(): """Test that the app can be imported.""" print("\nTesting app import...") try: # Add current directory to path sys.path.insert(0, os.getcwd()) # Import the app from app import app, load_data print("[OK] App imported successfully") # Test data loading function load_data() print("[OK] Data loading function works") print("[SUCCESS] App is ready to run!") return True except Exception as e: print(f"[ERROR] Error importing app: {e}") return False if __name__ == "__main__": print("MCP Documentation Server - Test Script") print("=" * 50) success = True # Test data loading success &= test_data_loading() # Test app import success &= test_app_import() if success: print("\n[SUCCESS] All tests passed! The server is ready for deployment.") sys.exit(0) else: print("\n[FAILED] Some tests failed. Please check the errors above.") sys.exit(1)