#!/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())