Skip to main content
Glama
test_current_system.pyโ€ข6.81 kB
#!/usr/bin/env python3 """ Test Current MCP System Simple tests to verify what's working """ import requests import json from datetime import datetime def test_server_health(): """Test if server is running.""" print("๐Ÿ” TESTING SERVER HEALTH") print("=" * 50) try: response = requests.get("http://localhost:8000/api/health", timeout=5) if response.status_code == 200: result = response.json() print(f"โœ… Server Status: {result.get('status', 'unknown')}") return True else: print(f"โŒ Server error: {response.status_code}") return False except Exception as e: print(f"โŒ Cannot connect to server: {e}") print("๐Ÿ’ก Make sure to run: python core/mcp_server.py") return False def test_simple_weather(): """Test simple weather query.""" print("\n๐ŸŒค๏ธ TESTING SIMPLE WEATHER QUERY") print("=" * 50) try: response = requests.post( "http://localhost:8000/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', 'unknown')}") print(f"Message: {result.get('message', 'No message')}") print(f"Agent: {result.get('agent_used', 'unknown')}") if result.get('status') == 'success': print("โœ… Weather query successful!") return True else: print("โŒ Weather query failed") return False else: print(f"โŒ HTTP Error: {response.status_code}") return False except Exception as e: print(f"โŒ Weather test error: {e}") return False def test_simple_math(): """Test simple math query.""" print("\n๐Ÿ”ข TESTING SIMPLE MATH QUERY") print("=" * 50) try: response = requests.post( "http://localhost:8000/api/mcp/command", json={"command": "Calculate 20% of 500"}, timeout=10 ) if response.status_code == 200: result = response.json() print(f"Status: {result.get('status', 'unknown')}") print(f"Message: {result.get('message', 'No message')}") print(f"Agent: {result.get('agent_used', 'unknown')}") if result.get('status') == 'success': print("โœ… Math query successful!") return True else: print("โŒ Math query failed") return False else: print(f"โŒ HTTP Error: {response.status_code}") return False except Exception as e: print(f"โŒ Math test error: {e}") return False def test_available_agents(): """Test what agents are available.""" print("\n๐Ÿค– TESTING AVAILABLE AGENTS") print("=" * 50) try: response = requests.get("http://localhost:8000/api/mcp/agents", timeout=5) if response.status_code == 200: result = response.json() agents = result.get("agents", {}) print(f"Total agents: {len(agents)}") for name, info in agents.items(): desc = info.get("description", "No description") print(f" โ€ข {name}: {desc}") return len(agents) > 0 else: print(f"โŒ HTTP Error: {response.status_code}") return False except Exception as e: print(f"โŒ Agent list error: {e}") return False def test_conversation_engine(): """Test if conversation engine is working.""" print("\n๐Ÿ—ฃ๏ธ TESTING CONVERSATION ENGINE") print("=" * 50) try: # Test with a simple query response = requests.post( "http://localhost:8000/api/mcp/command", json={"command": "Hello, are you working?"}, timeout=10 ) if response.status_code == 200: result = response.json() print(f"Status: {result.get('status', 'unknown')}") print(f"Message: {result.get('message', 'No message')[:100]}...") return result.get('status') == 'success' else: print(f"โŒ HTTP Error: {response.status_code}") return False except Exception as e: print(f"โŒ Conversation test error: {e}") return False def main(): """Main test function.""" print("๐Ÿงช CURRENT SYSTEM TEST") print("=" * 80) print("๐ŸŽฏ Testing what's currently working in your MCP system") print("=" * 80) tests = [ ("Server Health", test_server_health), ("Available Agents", test_available_agents), ("Simple Weather", test_simple_weather), ("Simple Math", test_simple_math), ("Conversation Engine", test_conversation_engine) ] passed_tests = 0 for test_name, test_function in tests: try: if test_function(): passed_tests += 1 print(f"โœ… {test_name} PASSED") else: print(f"โŒ {test_name} FAILED") except Exception as e: print(f"โŒ {test_name} ERROR: {e}") print() print("=" * 80) print("๐Ÿ“Š TEST RESULTS") print("=" * 80) print(f"โœ… Passed: {passed_tests}/{len(tests)}") print(f"๐Ÿ“ˆ Success rate: {(passed_tests/len(tests))*100:.1f}%") if passed_tests >= 3: print("\n๐ŸŽ‰ SYSTEM IS MOSTLY WORKING!") print("๐Ÿ’ก Try these working commands:") print(" ๐ŸŒค๏ธ MCP> What is the weather in Mumbai?") print(" ๐Ÿ”ข MCP> Calculate 20% of 500") print(" ๐Ÿ—ฃ๏ธ MCP> Hello, how are you?") print("\n๐Ÿ”ง FOR COMPLEX QUERIES:") print(" Break them into separate commands:") print(" 1. MCP> What is the weather in Mumbai?") print(" 2. MCP> Calculate 20% discount on 500 rupees") print(" 3. MCP> Extract text from image") print(" 4. MCP> Create a story about weather and savings") else: print("\n๐Ÿ”ง SYSTEM NEEDS ATTENTION") print("๐Ÿ’ก Check if the MCP server is running:") print(" python core/mcp_server.py") return passed_tests >= 3 if __name__ == "__main__": try: success = main() if success: print("\n๐ŸŽ‰ System test completed!") else: print("\n๐Ÿ”ง System needs fixes.") except Exception as e: print(f"\nโŒ Test failed: {e}")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tensorwhiz141/MCP2'

If you have feedback or need assistance with the MCP directory API, please join our Discord server