File size: 2,123 Bytes
f468451
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b215ec
 
f468451
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/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)