test_server.pyโข2.06 kB
#!/usr/bin/env python3
"""
Test harness for SCS MCP Server
"""
import json
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
def test_imports():
"""Test that all modules can be imported"""
print("๐งช Testing imports...")
try:
from src.core.search import SmartCodeSearch
print(" โ
SmartCodeSearch imported")
from src.server import SCSMCPServer
print(" โ
SCSMCPServer imported")
return True
except Exception as e:
print(f" โ Import failed: {e}")
return False
def test_search_instance():
"""Test creating a search instance"""
print("๐งช Testing search instance creation...")
try:
from src.core.search import SmartCodeSearch
instance = SmartCodeSearch(".", quiet=True)
print(" โ
Search instance created")
return True
except Exception as e:
print(f" โ Failed to create instance: {e}")
return False
def test_server_creation():
"""Test creating the MCP server"""
print("๐งช Testing MCP server creation...")
try:
from src.server import SCSMCPServer
server = SCSMCPServer()
print(" โ
MCP server created")
print(f" ๐ Tools registered: {len(server.project_instances)} projects cached")
return True
except Exception as e:
print(f" โ Failed to create server: {e}")
return False
def main():
print("๐ SCS MCP Server Test Suite\n")
tests = [
test_imports,
test_search_instance,
test_server_creation
]
passed = 0
failed = 0
for test in tests:
if test():
passed += 1
else:
failed += 1
print()
print(f"๐ Results: {passed} passed, {failed} failed")
if failed == 0:
print("โจ All tests passed!")
return 0
else:
print("โ Some tests failed")
return 1
if __name__ == "__main__":
sys.exit(main())