test_final_system.pyโข5.76 kB
#!/usr/bin/env python3
"""
Final System Test
Test the production MCP system functionality
"""
import requests
import json
from datetime import datetime
def test_production_system():
"""Test the production MCP system."""
base_url = "http://localhost:8000"
print("๐งช TESTING PRODUCTION MCP SYSTEM")
print("=" * 60)
print(f"๐ Started at: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print("=" * 60)
# Test 1: Server Health
print("\n๐ Test 1: Server Health")
try:
response = requests.get(f"{base_url}/api/health")
if response.status_code == 200:
health = response.json()
print(f" โ
Server Status: {health.get('status')}")
print(f" โ
Ready: {health.get('ready')}")
print(f" โ
Loaded Agents: {health.get('system', {}).get('loaded_agents', 0)}")
else:
print(f" โ Health check failed: {response.status_code}")
except Exception as e:
print(f" โ Health check error: {e}")
# Test 2: Math Calculation
print("\n๐ข Test 2: Math Calculation")
try:
response = requests.post(
f"{base_url}/api/mcp/command",
json={"command": "Calculate 25 * 4"},
timeout=10
)
if response.status_code == 200:
result = response.json()
print(f" โ
Status: {result.get('status')}")
print(f" ๐ค Agent: {result.get('agent_used')}")
print(f" ๐ Result: {result.get('result', 'N/A')}")
print(f" ๐พ Stored: {result.get('stored_in_mongodb', False)}")
else:
print(f" โ Math test failed: {response.status_code}")
except Exception as e:
print(f" โ Math test error: {e}")
# Test 3: Weather Query
print("\n๐ค๏ธ Test 3: Weather Query")
try:
response = requests.post(
f"{base_url}/api/mcp/command",
json={"command": "What is the weather in Mumbai?"},
timeout=15
)
if response.status_code == 200:
result = response.json()
print(f" โ
Status: {result.get('status')}")
print(f" ๐ค Agent: {result.get('agent_used')}")
print(f" ๐ City: {result.get('city', 'N/A')}")
print(f" ๐พ Stored: {result.get('stored_in_mongodb', False)}")
else:
print(f" โ Weather test failed: {response.status_code}")
except Exception as e:
print(f" โ Weather test error: {e}")
# Test 4: Document Analysis
print("\n๐ Test 4: Document Analysis")
try:
response = requests.post(
f"{base_url}/api/mcp/command",
json={"command": "Analyze this text: Hello world, this is a test document."},
timeout=10
)
if response.status_code == 200:
result = response.json()
print(f" โ
Status: {result.get('status')}")
print(f" ๐ค Agent: {result.get('agent_used')}")
print(f" ๐ Processed: {result.get('total_documents', 0)} documents")
print(f" ๐พ Stored: {result.get('stored_in_mongodb', False)}")
else:
print(f" โ Document test failed: {response.status_code}")
except Exception as e:
print(f" โ Document test error: {e}")
# Test 5: Agent Management
print("\n๐ง Test 5: Agent Management")
try:
response = requests.get(f"{base_url}/api/agents")
if response.status_code == 200:
agents_data = response.json()
summary = agents_data.get('summary', {})
print(f" โ
Total Agents: {summary.get('total_agents', 0)}")
print(f" โ
Loaded Agents: {summary.get('loaded_agents', 0)}")
print(f" โ
Failed Agents: {summary.get('failed_agents', 0)}")
agents = agents_data.get('agents', {})
loaded_agents = [aid for aid, info in agents.items() if info.get('status') == 'loaded']
print(f" ๐ Loaded: {', '.join(loaded_agents)}")
else:
print(f" โ Agent management test failed: {response.status_code}")
except Exception as e:
print(f" โ Agent management test error: {e}")
# Test 6: Agent Discovery
print("\n๐ Test 6: Agent Discovery")
try:
response = requests.get(f"{base_url}/api/agents/discover")
if response.status_code == 200:
discovery = response.json()
discovered = discovery.get('discovered', {})
print(f" โ
Live: {len(discovered.get('live', []))} agents")
print(f" โ
Inactive: {len(discovered.get('inactive', []))} agents")
print(f" โ
Future: {len(discovered.get('future', []))} agents")
print(f" โ
Templates: {len(discovered.get('templates', []))} agents")
else:
print(f" โ Discovery test failed: {response.status_code}")
except Exception as e:
print(f" โ Discovery test error: {e}")
print("\n" + "=" * 60)
print("๐ PRODUCTION SYSTEM TEST COMPLETED")
print("=" * 60)
print(f"๐ Completed at: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print("\n๐ SYSTEM CAPABILITIES:")
print(" โ
Production MCP Server v2.0.0")
print(" โ
Modular Agent Architecture")
print(" โ
Auto-Discovery & Hot-Swapping")
print(" โ
Fault-Tolerant Agent Management")
print(" โ
Health Monitoring & Recovery")
print(" โ
MongoDB Integration")
print(" โ
Inter-Agent Communication")
print(" โ
Scalable Deployment Ready")
if __name__ == "__main__":
test_production_system()