-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_server.py
More file actions
127 lines (106 loc) · 3.64 KB
/
Copy pathtest_server.py
File metadata and controls
127 lines (106 loc) · 3.64 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
"""
Quick test script for Android Forensics MCP Server
Run this to verify the server is working correctly
"""
import subprocess
import sys
def test_adb_available():
"""Test if ADB is available in system PATH"""
print("Testing ADB availability...")
try:
result = subprocess.run(
["adb", "version"],
capture_output=True,
text=True,
timeout=5
)
if result.returncode == 0:
print("✅ ADB is available")
print(f" Version: {result.stdout.split()[4]}")
return True
else:
print("❌ ADB command failed")
return False
except FileNotFoundError:
print("❌ ADB not found in PATH")
print(" Please install Android Platform Tools")
print(" Download: https://developer.android.com/tools/releases/platform-tools")
return False
except Exception as e:
print(f"❌ Error testing ADB: {e}")
return False
def test_python_version():
"""Test Python version"""
print("\nTesting Python version...")
version = sys.version_info
if version.major == 3 and version.minor >= 13:
print(f"✅ Python {version.major}.{version.minor}.{version.micro}")
return True
else:
print(f"❌ Python {version.major}.{version.minor}.{version.micro}")
print(" Python 3.13+ required")
return False
def test_imports():
"""Test if all required modules can be imported"""
print("\nTesting imports...")
required_modules = [
("mcp.server.fastmcp", "FastMCP"),
("cryptography.hazmat.primitives.ciphers", "Cipher"),
("pydantic", "BaseModel"),
]
all_ok = True
for module_name, class_name in required_modules:
try:
module = __import__(module_name, fromlist=[class_name])
getattr(module, class_name)
print(f"✅ {module_name}.{class_name}")
except ImportError as e:
print(f"❌ {module_name}.{class_name}: {e}")
all_ok = False
return all_ok
def test_server_syntax():
"""Test if main.py has valid syntax"""
print("\nTesting main.py syntax...")
try:
with open("main.py", "r") as f:
code = f.read()
compile(code, "main.py", "exec")
print("✅ main.py syntax is valid")
return True
except SyntaxError as e:
print(f"❌ Syntax error in main.py: {e}")
return False
except Exception as e:
print(f"❌ Error reading main.py: {e}")
return False
def main():
"""Run all tests"""
print("=" * 60)
print("Android Forensics MCP Server - System Check")
print("=" * 60)
results = {
"Python Version": test_python_version(),
"ADB Available": test_adb_available(),
"Module Imports": test_imports(),
"Server Syntax": test_server_syntax(),
}
print("\n" + "=" * 60)
print("Summary:")
print("=" * 60)
for test_name, result in results.items():
status = "✅ PASS" if result else "❌ FAIL"
print(f"{test_name:.<40} {status}")
all_passed = all(results.values())
print("\n" + "=" * 60)
if all_passed:
print("✅ All tests passed! Server is ready to use.")
print("\nNext steps:")
print("1. Connect Android device with USB debugging enabled")
print("2. Run: uv run mcp dev main.py")
print("3. Or integrate with Claude Desktop (see README.md)")
else:
print("❌ Some tests failed. Please fix the issues above.")
print("=" * 60)
return 0 if all_passed else 1
if __name__ == "__main__":
sys.exit(main())